Class ModelSolver

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

public final class ModelSolver extends Object
Model solver class
  • Constructor Details

    • ModelSolver

      public ModelSolver(String solverName)
      Creates the solver with the supplied solver backend.
  • Method Details

    • solve

      public SolveStatus solve(ModelBuilder model)
      Solves given model, and returns the status of the response.
    • enableOutput

      public void enableOutput(boolean enable)
      Enables or disables the underlying solver output.
    • setTimeLimit

      public void setTimeLimit(Duration limit)
      Sets the time limit for the solve in seconds.
    • setSolverSpecificParameters

      public void setSolverSpecificParameters(String parameters)
      Sets solver specific parameters as string.
    • solverIsSupported

      public boolean solverIsSupported()
      Returns whether solver specified during the ctor was found and correctly installed.
    • interruptSolve

      public boolean interruptSolve()
      Tries to interrupt the solve. Returns true if the feature is supported.
    • hasResponse

      public boolean hasResponse()
      Returns true if solve() was called, and a response was returned.
    • hasSolution

      public boolean hasSolution()
      Returns true if solve() was called, and a solution was returned.
    • getObjectiveValue

      public double getObjectiveValue()
      Checks that the solver has found a solution, and returns the objective value.
    • getBestObjectiveBound

      public double getBestObjectiveBound()
      Checks that the solver has found a solution, and returns the objective value.
    • getValue

      public double getValue(Variable var)
      Checks that the solver has found a solution, and returns the value of the given variable.
    • getReducedCost

      public double getReducedCost(Variable var)
      Checks that the solver has found a solution, and returns the reduced cost of the given variable.
    • getDualValue

      public double getDualValue(LinearConstraint ct)
      Checks that the solver has found a solution, and returns the dual value of the given constraint.
    • getActivity

      public double getActivity(LinearConstraint ct)
      Checks that the solver has found a solution, and returns the activity of the given constraint.
    • setLogCallback

      public void setLogCallback(Consumer<String> cb)
      Sets the log callback for the solver.
    • getWallTime

      public double getWallTime()
      Returns the elapsed time since the creation of the solver.
    • getUserTime

      public double getUserTime()
      Returns the user time since the creation of the solver.