Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
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 />
... p.add_constraint(b[u] + b[v], max=1)<br />
sage: p.set_binary(b)<br />
sage: p.solve(objective_only=True)<br />
4.0<br />
Constraints in the objective function are respected:<br />
sage: p = MixedIntegerLinearProgram()<br />
sage: x, y = p[0], p[1]<br />
sage: p.add_constraint(2*x + 3*y, max = 6)<br />
sage: p.add_constraint(3*x + 2*y, max = 6)<br />
sage: p.set_objective(x + y + 7)<br />
sage: p.set_integer(x); p.set_integer(y)<br />
sage: p.solve()<br />
9.0<br />
solver_parameter(name, value=None)<br />
Return or define a solver parameter<br />
The solver parameters are by essence solver-specific, which means their meaning heavily depends on the<br />
solver used.<br />
(If you do not know which solver you are using, then you use use GLPK).<br />
Aliases:<br />
Very common parameters have aliases making them solver-independent. For example, the following:<br />
sage: p = MixedIntegerLinearProgram(solver = "GLPK")<br />
sage: p.solver_parameter("timelimit", 60)<br />
Sets the solver to stop its computations after 60 seconds, and works with GLPK, CPLEX and Gurobi.<br />
•"timelimit" – defines the maximum time spent on a computation. Measured in seconds.<br />
Solver-specific parameters:<br />
•GLPK : We have implemented very close to comprehensive coverage of the GLPK solver parameters<br />
for the simplex and integer optimization methods. For details, see the documentation of<br />
GLPKBackend.solver_parameter.<br />
•CPLEX’s parameters are identified by a string. Their list is available on ILOG’s website.<br />
The command<br />
sage: p = MixedIntegerLinearProgram(solver = "CPLEX") # optional - CPLEX<br />
sage: p.solver_parameter("CPX_PARAM_TILIM", 60) # optional - CPLEX<br />
works as intended.<br />
•Gurobi’s parameters should all be available through this method. Their list is available on Gurobi’s<br />
website http://www.gurobi.com/documentation/5.5/reference-manual/node798.<br />
INPUT:<br />
•name (string) – the parameter<br />
•value – the parameter’s value if it is to be defined, or None (default) to obtain its current value.<br />
EXAMPLE:<br />
2.2. Classes and methods 29