C++ Reference: class MPObjective

This documentation is automatically generated.

A class to express a linear objective.
Method
AddLinearExpr

Return type: void

Arguments: const LinearExpr& linear_expr

Adds linear_expr to the current objective, does not change the direction.

AddOffset

Return type: void

Arguments: double value

Adds a constant term to the objective. Note: please use the less ambiguous SetOffset() if possible! TODO(user): remove this.

BestBound

Return type: double

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.

Clear

Return type: void

Clears the offset, all variables and coefficients, and the optimization direction.

GetCoefficient

Return type: double

Arguments: const MPVariable* const var

Gets the coefficient of a given variable in the objective (which is 0 if the variable does not appear in the objective).

maximization

Return type: bool

Is the optimization direction set to maximize?

MaximizeLinearExpr

Return type: void

Arguments: const LinearExpr& linear_expr

minimization

Return type: bool

Is the optimization direction set to minimize?

MinimizeLinearExpr

Return type: void

Arguments: const LinearExpr& linear_expr

offset

Return type: double

Gets the constant term in the objective.

OptimizeLinearExpr

Return type: void

Arguments: const LinearExpr& linear_expr, bool is_maximize

Resets the current objective to take the value of linear_expr, and sets the objective direction to maximize if "is_maximize", otherwise minimizes.

SetCoefficient

Return type: void

Arguments: const MPVariable* const 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.

SetMaximization

Return type: void

Sets the optimization direction to maximize.

SetMinimization

Return type: void

Sets the optimization direction to minimize.

SetOffset

Return type: void

Arguments: double value

Sets the constant term in the objective.

SetOptimizationDirection

Return type: void

Arguments: bool maximize

Sets the optimization direction (maximize: true or minimize: false).

Value

Return type: 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.

Enviar comentarios sobre…