Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Numerical</strong> <strong>Optimization</strong>, Release 6.1.1<br />
EXAMPLE:<br />
sage: from sage.numerical.backends.generic_backend import get_solver<br />
sage: p = get_solver(solver = "GLPK")<br />
sage: p.add_variables(5)<br />
4<br />
sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2)<br />
sage: p.row(0)<br />
([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0])<br />
sage: p.row_bounds(0)<br />
(2.0, 2.0)<br />
row_bounds(index)<br />
Return the bounds of a specific constraint.<br />
INPUT:<br />
•index (integer) – the constraint’s id.<br />
OUTPUT:<br />
A pair (lower_bound, upper_bound). Each of them can be set to None if the constraint is not<br />
bounded in the corresponding direction, and is a real value otherwise.<br />
EXAMPLE:<br />
sage: from sage.numerical.backends.generic_backend import get_solver<br />
sage: p = get_solver(solver = "GLPK")<br />
sage: p.add_variables(5)<br />
4<br />
sage: p.add_linear_constraint(zip(range(5), range(5)), 2, 2)<br />
sage: p.row(0)<br />
([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0])<br />
sage: p.row_bounds(0)<br />
(2.0, 2.0)<br />
row_name(index)<br />
Return the index th row name<br />
INPUT:<br />
•index (integer) – the row’s id<br />
EXAMPLE:<br />
sage: from sage.numerical.backends.generic_backend import get_solver<br />
sage: p = get_solver(solver = "GLPK")<br />
sage: p.add_linear_constraints(1, 2, None, names=[’Empty constraint 1’])<br />
sage: p.row_name(0)<br />
’Empty constraint 1’<br />
set_objective(coeff, d=0.0)<br />
Set the objective function.<br />
INPUT:<br />
•coeff - a list of real values, whose ith element is the coefficient of the ith variable in the objective<br />
function.<br />
•d (double) – the constant term in the linear function (set to 0 by default)<br />
EXAMPLE:<br />
72 Chapter 5. LP Solver backends