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 = MixedIntegerLinearProgram(solver = "GLPK")<br />

sage: p.solver_parameter("timelimit", 60)<br />

sage: p.solver_parameter("timelimit")<br />

60.0<br />

sum(L)<br />

Efficiently computes the sum of a sequence of LinearFunction elements<br />

INPUT:<br />

•mip – the MixedIntegerLinearProgram parent.<br />

•L – list of LinearFunction instances.<br />

Note: The use of the regular sum function is not recommended as it is much less efficient than this one<br />

EXAMPLES:<br />

sage: p = MixedIntegerLinearProgram()<br />

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

The following command:<br />

sage: s = p.sum([v[i] for i in xrange(90)])<br />

is much more efficient than:<br />

sage: s = sum([v[i] for i in xrange(90)])<br />

write_lp(filename)<br />

Write the linear program as a LP file.<br />

This function export the problem as a LP file.<br />

INPUT:<br />

•filename – The file in which you want the problem to be written.<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)<br />

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

Writing problem data to ...<br />

9 lines were written<br />

For more information about the LP file format : http://lpsolve.sourceforge.net/5.5/lp-format.htm<br />

write_mps(filename, modern=True)<br />

Write the linear program as a MPS file.<br />

This function export the problem as a MPS file.<br />

INPUT:<br />

•filename – The file in which you want the problem to be written.<br />

•modern – Lets you choose between Fixed MPS and Free MPS<br />

–True – Outputs the problem in Free MPS<br />

–False – Outputs the problem in Fixed MPS<br />

30 Chapter 2. Mixed integer linear programming

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

Saved successfully!

Ooh no, something went wrong!