Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Numerical</strong> <strong>Optimization</strong>, Release 6.1.1<br />
get_min(v)<br />
Returns the minimum value of a variable.<br />
INPUT:<br />
•v – a variable (not a MIPVariable, but one of its elements).<br />
OUTPUT:<br />
Minimum value of the variable, or None if the variable has no lower bound.<br />
EXAMPLE:<br />
sage: p = MixedIntegerLinearProgram()<br />
sage: v = p.new_variable()<br />
sage: p.set_objective(v[1])<br />
sage: p.get_min(v[1])<br />
0.0<br />
sage: p.set_min(v[1],6)<br />
sage: p.get_min(v[1])<br />
6.0<br />
sage: p.set_min(v[1], None)<br />
sage: p.get_min(v[1])<br />
get_values(*lists)<br />
Return values found by the previous call to solve().<br />
INPUT:<br />
•Any instance of MIPVariable (or one of its elements), or lists of them.<br />
OUTPUT:<br />
•Each instance of MIPVariable is replaced by a dictionary containing the numerical values found<br />
for each corresponding variable in the instance.<br />
•Each element of an instance of a MIPVariable is replaced by its corresponding numerical value.<br />
Note: While a variable may be declared as binary or integer, its value as returned by the solver is of type<br />
float.<br />
EXAMPLE:<br />
sage: p = MixedIntegerLinearProgram()<br />
sage: x = p.new_variable()<br />
sage: y = p.new_variable(dim=2)<br />
sage: p.set_objective(x[3] + 3*y[2][9] + x[5])<br />
sage: p.add_constraint(x[3] + y[2][9] + 2*x[5], max=2)<br />
sage: p.solve()<br />
6.0<br />
To return the optimal value of y[2][9]:<br />
sage: p.get_values(y[2][9])<br />
2.0<br />
To get a dictionary identical to x containing optimal values for the corresponding variables<br />
sage: x_sol = p.get_values(x)<br />
sage: x_sol.keys()<br />
[3, 5]<br />
18 Chapter 2. Mixed integer linear programming