Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have a partial answer for you. I can get the matrix constraints to work as in the following example:

p = MixedIntegerLinearProgram(maximization = True, solver='GLPK')
x = p.new_variable(real=True,nonnegative=True)
M=Matrix([[1,0.2],[1.5,3]])
v = vector([4,4])
u = vector([1,5])
p.add_constraint(M*x <= v)
p.show()

Unfortunately, I cannot get the objective function to work so nicely with vectors. I cannot seem to get set_objective to let me do a vector calculation inside the command.

Another option is to work with linear_program as found at http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/optimize.html

I have a partial answer for you. I can get the matrix constraints to work as in the following example:

p = MixedIntegerLinearProgram(maximization = True, solver='GLPK')
x = p.new_variable(real=True,nonnegative=True)
M=Matrix([[1,0.2],[1.5,3]])
v = vector([4,4])
u = vector([1,5])
p.add_constraint(M*x <= v)
p.show()

Unfortunately, I cannot get the objective function to work so nicely with vectors. I cannot seem to get set_objective to let me do a vector calculation inside the command.

Another option is to work with linear_program as found at http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/optimize.html

I think @Nathann is one of the experts on the linear programming in Sage.

I have a partial answer for you. I can get the matrix constraints to work as in the following example:

p = MixedIntegerLinearProgram(maximization = True, solver='GLPK')
x = p.new_variable(real=True,nonnegative=True)
M=Matrix([[1,0.2],[1.5,3]])
v = vector([4,4])
u = vector([1,5])
p.add_constraint(M*x <= v)
p.show()

Unfortunately, I cannot get the objective function to work so nicely with vectors. I cannot seem to get set_objective to let me do a vector calculation inside the command.

Another option is to work with linear_program as found at http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/optimize.html

I think @Nathann is one of the experts on the linear programming in Sage.Sage. He definitely would know more.

For the linear_program command, here is some sample code:

M=Matrix(RDF,[[-1,0],[0,-1],[-1,-1] ])
v = vector(RDF,[-5.5,-3.5,-7.5])
u = vector(RDF,[3,4])
sol=linear_program(u,M,v)
sol['x']

This solves: $M x \ge v$ with the objective function $u^t x$.

I have a partial answer for you. I can get the matrix constraints to work as in the following example:

p = MixedIntegerLinearProgram(maximization = True, solver='GLPK')
x = p.new_variable(real=True,nonnegative=True)
M=Matrix([[1,0.2],[1.5,3]])
v = vector([4,4])
u = vector([1,5])
p.add_constraint(M*x <= v)
p.show()

Unfortunately, I cannot get the objective function to work so nicely with vectors. I cannot seem to get set_objective to let me do a vector calculation inside the command.

Another option is to work with linear_program as found at http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/optimize.html

I think @Nathann is one of the experts on the linear programming in Sage. He definitely would know more.

For the linear_program command, here is some sample code:

M=Matrix(RDF,[[-1,0],[0,-1],[-1,-1] ])
v = vector(RDF,[-5.5,-3.5,-7.5])
u = vector(RDF,[3,4])
sol=linear_program(u,M,v)
sol['x']

This solves: minimizes: $M x \ge v$ with the objective function $u^t x$.

I have a partial answer for you. I can get the matrix constraints to work as in the following example:

p = MixedIntegerLinearProgram(maximization = True, solver='GLPK')
x = p.new_variable(real=True,nonnegative=True)
M=Matrix([[1,0.2],[1.5,3]])
v = vector([4,4])
u = vector([1,5])
p.add_constraint(M*x <= v)
p.show()

Unfortunately, I cannot get the objective function to work so nicely with vectors. I cannot seem to get set_objective to let me do a vector calculation inside the command.

Another option is to work with linear_program as found at http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/optimize.html

I think @Nathann is one of the experts on the linear programming in Sage. He definitely would know more.

For the linear_program command, here is some sample code:

M=Matrix(RDF,[[-1,0],[0,-1],[-1,-1] ])
v = vector(RDF,[-5.5,-3.5,-7.5])
u = vector(RDF,[3,4])
sol=linear_program(u,M,v)
sol['x']

This minimizes: $M x \ge v$ with minimizes the objective function $u^t x$.x$ with constraint $M x \ge v$.