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

([4, 3, 2, 1], [4.0, 3.0, 2.0, 1.0])<br />

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

(2.0, 2.0)<br />

# optional - Nonexistent_LP_solver<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 = "Nonexistent_LP_solver") # optional - Nonexistent_LP_solver<br />

sage: p.add_linear_constraints(1, 2, None, name="Empty constraint 1") # optional - Nonexist<br />

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

# optional - Nonexistent_LP_solver<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 />

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.set_objective([1, 1, 2, 1, 3])<br />

# optional - Nonexistent_LP_solver<br />

sage: map(lambda x :p.objective_coefficient(x), range(5)) # optional - Nonexistent_LP_solve<br />

[1.0, 1.0, 2.0, 1.0, 3.0]<br />

Constants in the objective function are respected:<br />

sage: p = MixedIntegerLinearProgram(solver=’Nonexistent_LP_solver’) # optional - Nonexistent<br />

sage: x,y = p[0], p[1]<br />

# optional - Nonexistent_LP_solver<br />

sage: p.add_constraint(2*x + 3*y, max = 6)<br />

# optional - Nonexistent_LP_solver<br />

sage: p.add_constraint(3*x + 2*y, max = 6)<br />

# optional - Nonexistent_LP_solver<br />

sage: p.set_objective(x + y + 7)<br />

# optional - Nonexistent_LP_solver<br />

sage: p.set_integer(x); p.set_integer(y)<br />

# optional - Nonexistent_LP_solver<br />

sage: p.solve()<br />

# optional - Nonexistent_LP_solver<br />

9.0<br />

set_sense(sense)<br />

Set the direction (maximization/minimization).<br />

INPUT:<br />

•sense (integer) :<br />

EXAMPLE:<br />

–+1 => Maximization<br />

–-1 => Minimization<br />

5.1. Generic Backend for LP solvers 57

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

Saved successfully!

Ooh no, something went wrong!