C++ Reference: class MPConstraint

This documentation is automatically generated.

The class for constraints of a Mathematical Programming (MP) model. A constraint is represented as a linear equation or inequality.
Method
basis_status

Return type: MPSolver::BasisStatus

Advanced usage: returns the basis status of the constraint (only available for continuous problems). Note that if a constraint "linear_expression in [lb, ub]" is transformed into "linear_expression + slack = 0" with slack in [-ub, -lb], then this status is the same as the status of the slack variable with AT_UPPER_BOUND and AT_LOWER_BOUND swapped. @see MPSolver::BasisStatus.

Clear

Return type: void

Clears all variables and coefficients. Does not clear the bounds.

dual_value

Return type: double

Advanced usage: returns the dual value of the constraint in the current solution (only available for continuous problems).

GetCoefficient

Return type: double

Arguments: const MPVariable* const var

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

index

Return type: int

Returns the index of the constraint in the MPSolver::constraints_.

is_lazy

Return type: bool

Advanced usage: returns true if the constraint is "lazy" (see below).

lb

Return type: double

Returns the lower bound.

name

Return type: const std::string&

Returns the name of the constraint.

set_is_lazy

Return type: void

Arguments: bool laziness

Advanced usage: sets the constraint "laziness". *** This is only supported for SCIP and has no effect on other solvers. *** When 'laziness' is true, the constraint is only considered by the Linear Programming solver if its current solution violates the constraint. In this case, the constraint is definitively added to the problem. This may be useful in some MIP problems, and may have a dramatic impact on performance. For more info see: http://tinyurl.com/lazy-constraints.

SetBounds

Return type: void

Arguments: double lb, double ub

Sets both the lower and upper bounds.

SetCoefficient

Return type: void

Arguments: const MPVariable* const var, double coeff

Sets the coefficient of the variable on the constraint. If the variable does not belong to the solver, the function just returns, or crashes in non-opt mode.

SetLB

Return type: void

Arguments: double lb

Sets the lower bound.

SetUB

Return type: void

Arguments: double ub

Sets the upper bound.

ub

Return type: double

Returns the upper bound.

Enviar comentarios sobre…