Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm not entirely sure what you are looking for due to the vagueness of your question, but here is a response that might help.

One way to encode a linear programming problem is:

p=MixedIntegerLinearProgram()
x=p.new_variable()
p.add_constraint(-3*x[0]+x[1]<=2)
p.add_constraint(x[1]<=11)
p.add_constraint(x[0]-x[1]<=3)
p.add_constraint(x[0]<=6)
p.set_objective(x[0]+2*x[1])

To display the objective function and constraints, use:

p.show()

To solve the LP problem, use:

p.solve()
p.get_values(x)

To display the feasible region in the 2d case, use:

p.polyhedron().show()

You can also enter the LP constraints using a matrix formulation as follows:

A=matrix([[-3,1],[0,1],[1,-1],[1,0]])
b=vector([2,11,3,6])
p=MixedIntegerLinearProgram()
x=p.new_variable()
p.set_objective(x[0]+2*x[1])
p.add_constraint(A*x<=b)