Class ModelBuilder

java.lang.Object
com.google.ortools.modelbuilder.ModelBuilder

public final class ModelBuilder extends Object
Main modeling class.

Proposes a factory to create all modeling objects understood by the SAT solver.

  • Constructor Details

    • ModelBuilder

      public ModelBuilder()
  • Method Details

    • newVar

      public Variable newVar(double lb, double ub, boolean isIntegral, String name)
      Creates a variable with domain [lb, ub].
    • newNumVar

      public Variable newNumVar(double lb, double ub, String name)
      Creates an continuous variable with domain [lb, ub].
    • newIntVar

      public Variable newIntVar(double lb, double ub, String name)
      Creates an integer variable with domain [lb, ub].
    • newBoolVar

      public Variable newBoolVar(String name)
      Creates a Boolean variable with the given name.
    • newConstant

      public Variable newConstant(double value)
      Creates a constant variable.
    • varFromIndex

      public Variable varFromIndex(int index)
      Rebuilds a variable from its index.
    • addLinearConstraint

      public LinearConstraint addLinearConstraint(LinearArgument expr, double lb, double ub)
      Adds lb <= expr <= ub.
    • numVariables

      public int numVariables()
      Returns the number of variables in the model.
    • addEquality

      public LinearConstraint addEquality(LinearArgument expr, double value)
      Adds expr == value.
    • addEquality

      public LinearConstraint addEquality(LinearArgument left, LinearArgument right)
      Adds left == right.
    • addLessOrEqual

      public LinearConstraint addLessOrEqual(LinearArgument expr, double value)
      Adds expr <= value.
    • addLessOrEqual

      public LinearConstraint addLessOrEqual(LinearArgument left, LinearArgument right)
      Adds left <= right.
    • addGreaterOrEqual

      public LinearConstraint addGreaterOrEqual(LinearArgument expr, double value)
      Adds expr >= value.
    • addGreaterOrEqual

      public LinearConstraint addGreaterOrEqual(LinearArgument left, LinearArgument right)
      Adds left >= right.
    • numConstraints

      public int numConstraints()
      Returns the number of constraints in the model.
    • minimize

      public void minimize(LinearArgument obj)
      Minimize expression
    • maximize

      public void maximize(LinearArgument obj)
      Minimize expression
    • optimize

      public void optimize(LinearArgument obj, boolean maximize)
      Sets the objective expression.
    • getName

      public String getName()
      Returns the name of the model.
    • setName

      public void setName(String name)
      Sets the name of the model.
    • exportToFile

      public boolean exportToFile(String file)
      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

      public String exportToMpsString(boolean obfuscate)
    • exportToLpString

      public String exportToLpString(boolean obfuscate)
    • importFromMpsString

      public boolean importFromMpsString(String mpsString)
    • importFromMpsFile

      public boolean importFromMpsFile(String mpsFile)
    • importFromLpString

      public boolean importFromLpString(String lpString)
    • importFromLpFile

      public boolean importFromLpFile(String lpFile)
    • getHelper

      public ModelBuilderHelper getHelper()
      Returns the model builder helper.