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 />
sage: p.add_col(range(5), range(5))<br />
sage: p.nrows()<br />
5<br />
# optional - Nonexistent_LP_solver<br />
# optional - Nonexistent_LP_solver<br />
add_linear_constraint(coefficients, lower_bound, upper_bound, name=None)<br />
Add a linear constraint.<br />
INPUT:<br />
•coefficients an iterable with (c,v) pairs where c is a variable index (integer) and v is a value<br />
(real value).<br />
•lower_bound - a lower bound, either a real value or None<br />
•upper_bound - an upper bound, either a real value or None<br />
•name - an optional name for this row (default: None)<br />
EXAMPLE:<br />
sage: from sage.numerical.backends.generic_backend import get_solver<br />
sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver<br />
sage: p.add_variables(5)<br />
# optional - Nonexistent_LP_solver<br />
4<br />
sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0) # optional - Nonexistent_LP<br />
sage: p.row(0)<br />
# optional - Nonexistent_LP_solver<br />
([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0]) # optional - Nonexistent_LP_solver<br />
sage: p.row_bounds(0)<br />
# optional - Nonexistent_LP_solver<br />
(2.0, 2.0)<br />
sage: p.add_linear_constraint( zip(range(5), range(5)), 1.0, 1.0, name=’foo’) # optional - N<br />
sage: p.row_name(-1)<br />
# optional - N<br />
"foo"<br />
add_linear_constraints(number, lower_bound, upper_bound, names=None)<br />
Add constraints.<br />
INPUT:<br />
•number (integer) – the number of constraints to add.<br />
•lower_bound - a lower bound, either a real value or None<br />
•upper_bound - an upper bound, either a real value or None<br />
•names - an optional list of names (default: None)<br />
EXAMPLE:<br />
sage: from sage.numerical.backends.generic_backend import get_solver<br />
sage: p = get_solver(solver = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver<br />
sage: p.add_variables(5)<br />
# optional - Nonexistent_LP_solver<br />
5<br />
sage: p.add_linear_constraints(5, None, 2)<br />
# optional - Nonexistent_LP_solver<br />
sage: p.row(4)<br />
# optional - Nonexistent_LP_solver<br />
([], [])<br />
sage: p.row_bounds(4)<br />
# optional - Nonexistent_LP_solver<br />
(None, 2.0)<br />
add_variable(lower_bound=None, upper_bound=None, binary=False, continuous=True, integer=False,<br />
obj=None, name=None)<br />
Add a variable.<br />
This amounts to adding a new column to the matrix. By default, the variable is both positive and real.<br />
50 Chapter 5. LP Solver backends