09.02.2015 Views

Sage Reference Manual: Numerical Optimization - Mirrors

Sage Reference Manual: Numerical Optimization - Mirrors

Sage Reference Manual: Numerical Optimization - Mirrors

SHOW MORE
SHOW LESS

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 />

sage: p.add_col(range(5), range(5))<br />

sage: p.nrows()<br />

5<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<br />

value (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 = "PPL")<br />

sage: p.add_variables(5)<br />

4<br />

sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0)<br />

sage: p.row(0)<br />

([1, 2, 3, 4], [1, 2, 3, 4])<br />

sage: p.row_bounds(0)<br />

(2.00000000000000, 2.00000000000000)<br />

sage: p.add_linear_constraint( zip(range(5), range(5)), 1.0, 1.0, name=’foo’)<br />

sage: p.row_name(-1)<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 = "PPL")<br />

sage: p.add_variables(5)<br />

4<br />

sage: p.add_linear_constraints(5, None, 2)<br />

sage: p.row(4)<br />

([], [])<br />

sage: p.row_bounds(4)<br />

(None, 2)<br />

add_variable(lower_bound=0, upper_bound=None, binary=False, continuous=True, integer=False,<br />

obj=0, 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 />

5.4. PPL Backend 93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!