# Linear programing variable dependancy Anonymous

Solving a linear programming problem there input constrains and addition constraints my be generated during solving the problem.

I am only interested in constrains of the form x <= y.

Does sage provide a method to the all the constrains between the variables? How easy is it to represent the constrain visually?

edit retag close merge delete

Sort by » oldest newest most voted

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.set_objective(x+2*x)


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+2*x)

more

If the system p is 3D, can I fix one parameter to get a 2D system without start a new instance of MixedIntegerLinearProgram()?

You can add a constraint: p.add_constraint(x == 75)