Package com.google.ortools.modelbuilder
Class ModelBuilder
java.lang.Object
com.google.ortools.modelbuilder.ModelBuilder
Main modeling class.
Proposes a factory to create all modeling objects understood by the SAT solver.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown when parallel arrays have mismatched lengths.static classException thrown when an array has a wrong length. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddEquality(LinearArgument expr, double value) Addsexpr == value.addEquality(LinearArgument left, LinearArgument right) Addsleft == right.addGreaterOrEqual(LinearArgument expr, double value) Addsexpr >= value.addGreaterOrEqual(LinearArgument left, LinearArgument right) Addsleft >= right.addLessOrEqual(LinearArgument expr, double value) Addsexpr <= value.addLessOrEqual(LinearArgument left, LinearArgument right) Addsleft <= right.addLinearConstraint(LinearArgument expr, double lb, double ub) Addslb <= expr <= ub.booleanexportToFile(String file) Write the model as a protocol buffer to 'file'.exportToLpString(boolean obfuscate) exportToMpsString(boolean obfuscate) Returns the model builder helper.getName()Returns the name of the model.booleanimportFromLpFile(String lpFile) booleanimportFromLpString(String lpString) booleanimportFromMpsFile(String mpsFile) booleanimportFromMpsString(String mpsString) voidmaximize(LinearArgument obj) Minimize expressionvoidminimize(LinearArgument obj) Minimize expressionnewBoolVar(String name) Creates a Boolean variable with the given name.newConstant(double value) Creates a constant variable.Creates an integer variable with domain [lb, ub].Creates an continuous variable with domain [lb, ub].Creates a variable with domain [lb, ub].intReturns the number of constraints in the model.intReturns the number of variables in the model.voidoptimize(LinearArgument obj, boolean maximize) Sets the objective expression.voidSets the name of the model.varFromIndex(int index) Rebuilds a variable from its index.
-
Constructor Details
-
ModelBuilder
public ModelBuilder()
-
-
Method Details
-
newVar
Creates a variable with domain [lb, ub]. -
newNumVar
Creates an continuous variable with domain [lb, ub]. -
newIntVar
Creates an integer variable with domain [lb, ub]. -
newBoolVar
Creates a Boolean variable with the given name. -
newConstant
Creates a constant variable. -
varFromIndex
Rebuilds a variable from its index. -
addLinearConstraint
Addslb <= expr <= ub. -
numVariables
public int numVariables()Returns the number of variables in the model. -
addEquality
Addsexpr == value. -
addEquality
Addsleft == right. -
addLessOrEqual
Addsexpr <= value. -
addLessOrEqual
Addsleft <= right. -
addGreaterOrEqual
Addsexpr >= value. -
addGreaterOrEqual
Addsleft >= right. -
numConstraints
public int numConstraints()Returns the number of constraints in the model. -
minimize
Minimize expression -
maximize
Minimize expression -
optimize
Sets the objective expression. -
getName
Returns the name of the model. -
setName
Sets the name of the model. -
exportToFile
Write the model as a protocol buffer to 'file'.- Parameters:
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.- Returns:
- true if the model was correctly written.
-
exportToMpsString
-
exportToLpString
-
importFromMpsString
-
importFromMpsFile
-
importFromLpString
-
importFromLpFile
-
getHelper
Returns the model builder helper.
-