![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
Main modeling class. More...
Main modeling class.
Proposes a factory to create all modeling objects understood by the Solver.
Definition at line 31 of file ModelBuilder.cs.
Public Member Functions | |
| Model () | |
| Main constructor. | |
| Model | Clone () |
| Returns a cloned model. | |
| Variable | NewVar (double lb, double ub, bool isIntegral, String name) |
| Integer variables. | |
| Variable | NewNumVar (double lb, double ub, String name) |
| Creates a continuous variable with domain [lb, ub]. | |
| Variable | NewIntVar (double lb, double ub, String name) |
| Creates an integer variable with domain [lb, ub]. | |
| Variable | NewBoolVar (String name) |
| Creates a bool variable with the given name. | |
| Variable | NewConstant (double value) |
| Creates a constant variable. | |
| Variable | VarFromIndex (int index) |
| Rebuilds a variable from its index. | |
| LinearConstraint | Add (BoundedLinearExpression lin) |
| Adds a Linear constraint to the model. | |
| LinearConstraint | AddLinearConstraint (LinearExpr expr, double lb, double ub) |
| Adds the constraint expr in [lb, ub]. | |
| LinearConstraint | ConstraintFromIndex (int index) |
| Rebuilds a linear constraint from its index. | |
| EnforcedLinearConstraint | AddEnforced (BoundedLinearExpression lin, Variable iVar, bool iValue) |
| Adds an enforced Linear constraint to the model. | |
| EnforcedLinearConstraint | AddEnforcedLinearConstraint (LinearExpr expr, double lb, double ub, Variable iVar, bool iValue) |
| Adds the constraint iVar == iValue => expr in [lb, ub]. | |
| EnforcedLinearConstraint | EnforcedConstraintFromIndex (int index) |
| Rebuilds a linear constraint from its index. | |
| void | Minimize (LinearExpr obj) |
| Objective. | |
| void | Maximize (LinearExpr obj) |
| Maximize expression. | |
| void | Optimize (LinearExpr obj, bool maximize) |
| Sets the objective expression. | |
| void | ClearHints () |
| Remove all hints from the model. | |
| void | AddHint (Variable var, double value) |
| Adds var == value as a hint to the model. Note that variables must not appear more than once in the list of hints. | |
| int | VariablesCount () |
| Returns the number of variables in the model. | |
| int | ConstraintsCount () |
| Returns the number of constraints in the model. | |
| bool | ExportToFile (String file) |
| Write the model as a protocol buffer to 'file'. | |
| bool | ImportFromFile (String file) |
| load the model as a protocol buffer from 'file'. | |
| String | ExportToMpsString (bool obfuscate) |
| String | ExportToLpString (bool obfuscate) |
| bool | WriteToMpsFile (String filename, bool obfuscate) |
| bool | ImportFromMpsString (String mpsString) |
| bool | ImportFromMpsFile (String mpsFile) |
| bool | ImportFromLpString (String lpString) |
| bool | ImportFromLpFile (String lpFile) |
Properties | |
| double | ObjectiveOffset [get, set] |
| The offset of the objective. | |
| String | Name [get, set] |
| The name of the model. | |
| ModelBuilderHelper | Helper [get] |
| The model builder helper. | |
|
inline |
Main constructor.
Definition at line 36 of file ModelBuilder.cs.
|
inline |
Adds a Linear constraint to the model.
| lin | A bounded linear expression |
| ArgumentException | Throw when the constraint is not supported by the linear solver |
Definition at line 136 of file ModelBuilder.cs.
|
inline |
Adds an enforced Linear constraint to the model.
| lin | A bounded linear expression |
| iVar | The indicator variable of the constraint. |
| iValue | The indicator value of the constraint. |
| ArgumentException | Throw when the constraint is not supported by the linear solver |
Definition at line 205 of file ModelBuilder.cs.
|
inline |
Adds the constraint iVar == iValue => expr in [lb, ub].
| expr | The constrained expression |
| lb | the lower bound of the constraint |
| ub | the upper bound of the constraint |
| iVar | the indicator variable of the constraint |
| iValue | the indicator value of the constraint |
Definition at line 233 of file ModelBuilder.cs.
|
inline |
Adds var == value as a hint to the model. Note that variables must not appear more than once in the list of hints.
Definition at line 338 of file ModelBuilder.cs.
|
inline |
Adds the constraint expr in [lb, ub].
| expr | The constrained expression |
| lb | the constrained lower bound of the expression |
| ub | the constrained upper bound of the expression |
Definition at line 162 of file ModelBuilder.cs.
|
inline |
Remove all hints from the model.
Definition at line 329 of file ModelBuilder.cs.
|
inline |
Returns a cloned model.
Definition at line 48 of file ModelBuilder.cs.
|
inline |
Rebuilds a linear constraint from its index.
Definition at line 192 of file ModelBuilder.cs.
|
inline |
Returns the number of constraints in the model.
Definition at line 354 of file ModelBuilder.cs.
|
inline |
Rebuilds a linear constraint from its index.
Definition at line 266 of file ModelBuilder.cs.
|
inline |
Write the model as a protocol buffer to 'file'.
| file | file to write the model to. If the filename ends with 'txt', the model will be written as a text file, otherwise, the binary format will be used. |
Definition at line 378 of file ModelBuilder.cs.
|
inline |
Definition at line 398 of file ModelBuilder.cs.
|
inline |
Definition at line 393 of file ModelBuilder.cs.
|
inline |
load the model as a protocol buffer from 'file'.
| file | file to read the model from. |
Definition at line 388 of file ModelBuilder.cs.
|
inline |
Definition at line 423 of file ModelBuilder.cs.
|
inline |
Definition at line 418 of file ModelBuilder.cs.
|
inline |
Definition at line 413 of file ModelBuilder.cs.
|
inline |
Definition at line 408 of file ModelBuilder.cs.
|
inline |
Maximize expression.
| obj | the linear expression to maximize |
Definition at line 286 of file ModelBuilder.cs.
|
inline |
Objective.
Minimize expression.
| obj | the linear expression to minimize |
Definition at line 277 of file ModelBuilder.cs.
|
inline |
Creates a bool variable with the given name.
| name | The name of the variable |
Definition at line 103 of file ModelBuilder.cs.
|
inline |
Creates a constant variable.
| value | the value of the constant variable |
Definition at line 113 of file ModelBuilder.cs.
|
inline |
Creates an integer variable with domain [lb, ub].
| lb | The lower bound of the variable |
| ub | The upper bound of the variable |
| name | The name of the variable |
Definition at line 93 of file ModelBuilder.cs.
|
inline |
Creates a continuous variable with domain [lb, ub].
| lb | The lower bound of the variable |
| ub | The upper bound of the variable |
| name | The name of the variable |
Definition at line 81 of file ModelBuilder.cs.
|
inline |
Integer variables.
reates a variable with domain [lb, ub].
| lb | The lower bound of the variable |
| ub | The upper bound of the variable |
| isIntegral | Indicates if the variable is restricted to take only integral values |
| name | The name of the variable |
Definition at line 69 of file ModelBuilder.cs.
|
inline |
Sets the objective expression.
| obj | the linear expression to optimize |
| maximize | the direction of the optimization |
Definition at line 296 of file ModelBuilder.cs.
|
inline |
Rebuilds a variable from its index.
Definition at line 125 of file ModelBuilder.cs.
|
inline |
Returns the number of variables in the model.
Definition at line 346 of file ModelBuilder.cs.
|
inline |
Definition at line 403 of file ModelBuilder.cs.
|
get |
The model builder helper.
Definition at line 431 of file ModelBuilder.cs.
|
getset |
The name of the model.
Definition at line 362 of file ModelBuilder.cs.
|
getset |
The offset of the objective.
Definition at line 316 of file ModelBuilder.cs.