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 class
Exception thrown when parallel arrays have mismatched lengths.static class
Exception thrown when an array has a wrong length. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddEnforcedEquality
(LinearArgument expr, double value, Variable iVar, boolean iValue) Addsivar == iValue => expr == value
.addEnforcedEquality
(LinearArgument left, LinearArgument right, Variable iVar, boolean iValue) Addsivar == iValue => left == right
.addEnforcedGreaterOrEqual
(LinearArgument expr, double value, Variable iVar, boolean iValue) Addsivar == iValue => expr >= value
.addEnforcedGreaterOrEqual
(LinearArgument left, LinearArgument right, Variable iVar, boolean iValue) Addsivar == iValue => left >= right
.addEnforcedLessOrEqual
(LinearArgument expr, double value, Variable iVar, boolean iValue) Addsivar == iValue => expr <= value
.addEnforcedLessOrEqual
(LinearArgument left, LinearArgument right, Variable iVar, boolean iValue) Addsivar == iValue => left <= right
.addEnforcedLinearConstraint
(LinearArgument expr, double lb, double ub, Variable iVar, boolean iValue) Addsivar == iValue => lb <= expr <= ub
.addEquality
(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
.constraintFromIndex
(int index) Rebuilds a linear constraint from its index.enforcedConstraintFromIndex
(int index) Rebuilds a linear constraint from its index.boolean
exportToFile
(String file) Write the model as a protocol buffer to 'file'.exportToLpString
(boolean obfuscate) exportToMpsString
(boolean obfuscate) getClone()
Returns a cloned modelReturns the model builder helper.getName()
Returns the name of the model.boolean
importFromFile
(String file) import the model from protocol buffer 'file'.boolean
importFromLpFile
(String lpFile) boolean
importFromLpString
(String lpString) boolean
importFromMpsFile
(String mpsFile) boolean
importFromMpsString
(String mpsString) void
maximize
(LinearArgument obj) Minimize expressionvoid
minimize
(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 a continuous variable with domain [lb, ub].Creates a variable with domain [lb, ub].int
Returns the number of constraints in the model.int
Returns the number of variables in the model.void
optimize
(LinearArgument obj, boolean maximize) Sets the objective expression.void
Sets the name of the model.varFromIndex
(int index) Rebuilds a variable from its index.boolean
writeToMpsFile
(String filename, boolean obfuscate)
-
Constructor Details
-
ModelBuilder
public ModelBuilder()Main constructor
-
-
Method Details
-
getClone
Returns a cloned model -
newVar
-
newNumVar
-
newIntVar
-
newBoolVar
-
newConstant
Creates a constant variable. -
varFromIndex
Rebuilds a variable from its index. -
addLinearConstraint
Addslb <= expr <= ub
. -
addEquality
Addsexpr == value
. -
addEquality
Addsleft == right
. -
addLessOrEqual
Addsexpr <= value
. -
addLessOrEqual
Addsleft <= right
. -
addGreaterOrEqual
Addsexpr >= value
. -
addGreaterOrEqual
Addsleft >= right
. -
constraintFromIndex
Rebuilds a linear constraint from its index. -
addEnforcedLinearConstraint
public EnforcedLinearConstraint addEnforcedLinearConstraint(LinearArgument expr, double lb, double ub, Variable iVar, boolean iValue) Addsivar == iValue => lb <= expr <= ub
. -
addEnforcedEquality
public EnforcedLinearConstraint addEnforcedEquality(LinearArgument expr, double value, Variable iVar, boolean iValue) Addsivar == iValue => expr == value
. -
addEnforcedEquality
public EnforcedLinearConstraint addEnforcedEquality(LinearArgument left, LinearArgument right, Variable iVar, boolean iValue) Addsivar == iValue => left == right
. -
addEnforcedLessOrEqual
public EnforcedLinearConstraint addEnforcedLessOrEqual(LinearArgument expr, double value, Variable iVar, boolean iValue) Addsivar == iValue => expr <= value
. -
addEnforcedLessOrEqual
public EnforcedLinearConstraint addEnforcedLessOrEqual(LinearArgument left, LinearArgument right, Variable iVar, boolean iValue) Addsivar == iValue => left <= right
. -
addEnforcedGreaterOrEqual
public EnforcedLinearConstraint addEnforcedGreaterOrEqual(LinearArgument expr, double value, Variable iVar, boolean iValue) Addsivar == iValue => expr >= value
. -
addEnforcedGreaterOrEqual
public EnforcedLinearConstraint addEnforcedGreaterOrEqual(LinearArgument left, LinearArgument right, Variable iVar, boolean iValue) Addsivar == iValue => left >= right
. -
enforcedConstraintFromIndex
Rebuilds a linear constraint from its index. -
minimize
Minimize expression -
maximize
Minimize expression -
optimize
Sets the objective expression. -
numVariables
public int numVariables()Returns the number of variables in the model. -
numConstraints
public int numConstraints()Returns the number of constraints in the model. -
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.
-
importFromFile
import the model from protocol buffer 'file'.- Parameters:
file
- file to read the model from.- Returns:
- true if the model was correctly loaded.
-
exportToMpsString
-
exportToLpString
-
writeToMpsFile
-
importFromMpsString
-
importFromMpsFile
-
importFromLpString
-
importFromLpFile
-
getHelper
Returns the model builder helper.
-