Class MPObjective

java.lang.Object
com.google.ortools.linearsolver.MPObjective

public class MPObjective extends Object
A class to express a linear objective.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MPObjective(long cPtr, boolean cMemoryOwn)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the best objective bound.

    In case of minimization, it is a lower bound on the objective value of the
    optimal integer solution.
    void
    Clears the offset, all variables and coefficients, and the optimization
    direction.
    void
     
    protected void
     
    double
    Gets the coefficient of a given variable in the objective

    It returns 0 if the variable does not appear in the objective).
    protected static long
     
    boolean
    Is the optimization direction set to maximize?
    boolean
    Is the optimization direction set to minimize?
    double
    Gets the constant term in the objective.
    void
    setCoefficient(MPVariable var, double coeff)
    Sets the coefficient of the variable in the objective.

    If the variable does not belong to the solver, the function just returns,
    or crashes in non-opt mode.
    void
    Sets the optimization direction to maximize.
    void
    Sets the optimization direction to minimize.
    void
    setOffset(double value)
    Sets the constant term in the objective.
    void
    setOptimizationDirection(boolean maximize)
    Sets the optimization direction (maximize: true or minimize: false).
    protected static long
     
    double
    Returns the objective value of the best solution found so far.

    It is the optimal objective value if the problem has been solved to
    optimality.

    Note: the objective value may be slightly different than what you could
    compute yourself using MPVariable::solution_value(); please use the
    --verify_solution flag to gain confidence about the numerical stability of
    your solution.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • swigCMemOwn

      protected transient boolean swigCMemOwn
  • Constructor Details

    • MPObjective

      protected MPObjective(long cPtr, boolean cMemoryOwn)
  • Method Details

    • getCPtr

      protected static long getCPtr(MPObjective obj)
    • swigRelease

      protected static long swigRelease(MPObjective obj)
    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • delete

      public void delete()
    • clear

      public void clear()
      Clears the offset, all variables and coefficients, and the optimization
      direction.
    • setCoefficient

      public void setCoefficient(MPVariable var, double coeff)
      Sets the coefficient of the variable in the objective.

      If the variable does not belong to the solver, the function just returns,
      or crashes in non-opt mode.
    • getCoefficient

      public double getCoefficient(MPVariable var)
      Gets the coefficient of a given variable in the objective

      It returns 0 if the variable does not appear in the objective).
    • setOffset

      public void setOffset(double value)
      Sets the constant term in the objective.
    • offset

      public double offset()
      Gets the constant term in the objective.
    • setOptimizationDirection

      public void setOptimizationDirection(boolean maximize)
      Sets the optimization direction (maximize: true or minimize: false).
    • setMinimization

      public void setMinimization()
      Sets the optimization direction to minimize.
    • setMaximization

      public void setMaximization()
      Sets the optimization direction to maximize.
    • maximization

      public boolean maximization()
      Is the optimization direction set to maximize?
    • minimization

      public boolean minimization()
      Is the optimization direction set to minimize?
    • value

      public double value()
      Returns the objective value of the best solution found so far.

      It is the optimal objective value if the problem has been solved to
      optimality.

      Note: the objective value may be slightly different than what you could
      compute yourself using MPVariable::solution_value(); please use the
      --verify_solution flag to gain confidence about the numerical stability of
      your solution.
    • bestBound

      public double bestBound()
      Returns the best objective bound.

      In case of minimization, it is a lower bound on the objective value of the
      optimal integer solution. Only available for discrete problems.