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

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

EXAMPLE:<br />

sage: p = MixedIntegerLinearProgram(solver="GLPK")<br />

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

sage: p.set_objective(x[1] + x[2])<br />

sage: p.add_constraint(-3*x[1] + 2*x[2], max=2,name="OneConstraint")<br />

sage: p.write_mps(os.path.join(SAGE_TMP, "lp_problem.mps"))<br />

Writing problem data to ...<br />

17 records were written<br />

For information about the MPS file format : http://en.wikipedia.org/wiki/MPS_%28format%29<br />

sage.numerical.mip.Sum(x)<br />

Only for legacy support, use MixedIntegerLinearProgram.sum() instead.<br />

EXAMPLES:<br />

sage: from sage.numerical.mip import Sum<br />

sage: Sum([])<br />

doctest:...: DeprecationWarning: use MixedIntegerLinearProgram.sum() instead<br />

See http://trac.sagemath.org/13646 for details.<br />

sage: p = MixedIntegerLinearProgram()<br />

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

sage: Sum([ x[0]+x[1], x[1]+x[2], x[2]+x[3] ])<br />

x_0 + 2*x_1 + 2*x_2 + x_3<br />

# deprecation is only shown once<br />

2.2. Classes and methods 31

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

Saved successfully!

Ooh no, something went wrong!