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: 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.is_maximization()<br />

# optional - Nonexistent_LP_solver<br />

True<br />

sage: p.set_sense(-1)<br />

# optional - Nonexistent_LP_solver<br />

sage: p.is_maximization()<br />

# optional - Nonexistent_LP_solver<br />

False<br />

set_variable_type(variable, vtype)<br />

Set the type of a variable<br />

INPUT:<br />

•variable (integer) – the variable’s id<br />

•vtype (integer) :<br />

EXAMPLE:<br />

–1 Integer<br />

–0 Binary<br />

– -1 Continuous<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.ncols()<br />

# optional - Nonexistent_LP_solver<br />

0<br />

sage: p.add_variable()<br />

# optional - Nonexistent_LP_solver<br />

1<br />

sage: p.set_variable_type(0,1)<br />

# optional - Nonexistent_LP_solver<br />

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

# optional - Nonexistent_LP_solver<br />

True<br />

set_verbosity(level)<br />

Set the log (verbosity) level<br />

INPUT:<br />

•level (integer) – From 0 (no verbosity) to 3.<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.set_verbosity(2)<br />

# optional - Nonexistent_LP_solver<br />

solve()<br />

Solve the problem.<br />

Note: This method raises MIPSolverException exceptions when the solution can not be computed<br />

for any reason (none exists, or the LP solver was not able to find it, etc...)<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_linear_constraints(5, 0, None)<br />

# optional - Nonexistent_LP_solver<br />

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

# optional - Nonexistent_LP_solver<br />

sage: p.solve()<br />

# optional - Nonexistent_LP_solver<br />

58 Chapter 5. LP Solver backends

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

Saved successfully!

Ooh no, something went wrong!