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

Obviously, it also works with variables of higher dimension:<br />

sage: y_sol = p.get_values(y)<br />

We could also have tried<br />

sage: [x_sol, y_sol] = p.get_values(x, y)<br />

Or:<br />

sage: [x_sol, y_sol] = p.get_values([x, y])<br />

is_binary(e)<br />

Tests whether the variable e is binary. Variables are real by default.<br />

INPUT:<br />

•e – A variable (not a MIPVariable, but one of its elements.)<br />

OUTPUT:<br />

True if the variable e is binary; False otherwise.<br />

EXAMPLE:<br />

sage: p = MixedIntegerLinearProgram()<br />

sage: v = p.new_variable()<br />

sage: p.set_objective(v[1])<br />

sage: p.is_binary(v[1])<br />

False<br />

sage: p.set_binary(v[1])<br />

sage: p.is_binary(v[1])<br />

True<br />

is_integer(e)<br />

Tests whether the variable is an integer. Variables are real by default.<br />

INPUT:<br />

•e – A variable (not a MIPVariable, but one of its elements.)<br />

OUTPUT:<br />

True if the variable e is an integer; False otherwise.<br />

EXAMPLE:<br />

sage: p = MixedIntegerLinearProgram()<br />

sage: v = p.new_variable()<br />

sage: p.set_objective(v[1])<br />

sage: p.is_integer(v[1])<br />

False<br />

sage: p.set_integer(v[1])<br />

sage: p.is_integer(v[1])<br />

True<br />

is_real(e)<br />

Tests whether the variable is real. Variables are real by default.<br />

INPUT:<br />

•e – A variable (not a MIPVariable, but one of its elements.)<br />

OUTPUT:<br />

2.2. Classes and methods 19

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

Saved successfully!

Ooh no, something went wrong!