1 | initial version |
The names x_i
indicate the order in which the variables x[i]
are accessed first. You can see it if you set parameter name
of method new_variable
.
sage: p = MixedIntegerLinearProgram(maximization=False, solver="GLPK")
....: x = p.new_variable(real=True, nonnegative=True, name="x")
....: p.set_integer(x[2])
....: p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
....: p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
....: p.add_constraint(2*x[2] - 6*x[3] <= 0)
....: p.add_constraint(x[0] - x[1] - x[2] >= 0)
....: p.add_constraint(x[3] >= 1)
....: p.set_objective(3*x[1] + 6*x[2] - 3*x[3])
....: p.show()
Minimization:
6.0 x[2] + 3.0 x[1] -3.0 x[3]
Constraints:
3.0 x[2] + 2.0 x[0] + 2.0 x[1] - 10.0 x[3] <= 0.0
-4.0 x[2] - 6.0 x[1] + 11.0 x[3] <= 0.0
2.0 x[2] - 6.0 x[3] <= 0.0
x[2] - x[0] + x[1] <= 0.0
- x[3] <= -1.0
Variables:
x[2] = x_0 is an integer variable (min=0.0, max=+oo)
x[0] = x_1 is a continuous variable (min=0.0, max=+oo)
x[1] = x_2 is a continuous variable (min=0.0, max=+oo)
x[3] = x_3 is a continuous variable (min=0.0, max=+oo)
2 | No.2 Revision |
The names x_i
indicate the order in which the variables x[i]
are accessed first. You can see it if you set parameter name
of method new_variable
. So variable x[2]
is correctly sets to integer, although it's internal name is x_0
.
sage: p = MixedIntegerLinearProgram(maximization=False, solver="GLPK")
....: x = p.new_variable(real=True, nonnegative=True, name="x")
....: p.set_integer(x[2])
....: p.add_constraint(2*x[0] + 2*x[1] + 3*x[2] - 10*x[3] <= 0)
....: p.add_constraint(6*x[1] + 4*x[2] - 11*x[3] >= 0)
....: p.add_constraint(2*x[2] - 6*x[3] <= 0)
....: p.add_constraint(x[0] - x[1] - x[2] >= 0)
....: p.add_constraint(x[3] >= 1)
....: p.set_objective(3*x[1] + 6*x[2] - 3*x[3])
....: p.show()
Minimization:
6.0 x[2] + 3.0 x[1] -3.0 x[3]
Constraints:
3.0 x[2] + 2.0 x[0] + 2.0 x[1] - 10.0 x[3] <= 0.0
-4.0 x[2] - 6.0 x[1] + 11.0 x[3] <= 0.0
2.0 x[2] - 6.0 x[3] <= 0.0
x[2] - x[0] + x[1] <= 0.0
- x[3] <= -1.0
Variables:
x[2] = x_0 is an integer variable (min=0.0, max=+oo)
x[0] = x_1 is a continuous variable (min=0.0, max=+oo)
x[1] = x_2 is a continuous variable (min=0.0, max=+oo)
x[3] = x_3 is a continuous variable (min=0.0, max=+oo)