Rel: MonStgElt Default: "eq"
Add some constraints to the LP problem L. All constraints will have the same relation, given by Rel, which may be set to "eq" for strict equality (the default), "le" for less-or-equal constraints, or "ge" for greater-or-equal constraints.Constraints are of the form ∑j = 1nlhsij Rel rhsi1 where lhs and rhs are described in Section Explicit LP Solving Functions.
The number of constraints in the LP problem L.
The number of variables in the LP problem L.
Evaluate the objective function of the LP problem L at the point p given by a matrix.
The LHS, RHS and relation (-1 for ≤, 0 for =, 1 for ≥) of the n-th constraint of the LP problem L.
Sequence of indices of the variables in the LP problem L to be solved in integers.
The objective function of the LP problem L.
Returns true if the LP problem L is set to maximise its objective function, false if set to minimise.
Remove the n-th constraint from the LP problem L.
Set the variables of the LP problem L indexed by elements of the sequence I to be solved in integers if m is true, or in the usual ring if false.
Set the lower bound on the n-th variable in the LP problem L to b.Note that for all LP problems in Magma there is an implicit constraint that all variables are ≥0. This constraint is overridden if a lower bound is specified by using this function (e.g., specifying a lower bound of -5 works as expected), but the lower bound can currently not be completely removed.
Set the LP problem L to maximise its objective function if m is true, or to minimise the objective function if m is false.
Set the objective function of the LP problem L to the matrix F.
Set the upper bound on the n-th variable in the LP problem L to b.
Solve the LP problem L; returns a point representing an optimal solution, and an integer representing the state of the solution.
Remove any bounds on all variables in the LP problem L.Note that this reactivates the implicit constraint that all variables are ≥0.
> R := RealField( ); > L := LPProcess(R, 2); > SetObjectiveFunction(L, Matrix(R, 1, 2, [3,13])); > lhs := Matrix(R, 2, 2, [2, 9, 11, -8]); > rhs := Matrix(R, 2, 1, [40, 82]); > AddConstraints(L, lhs, rhs : Rel := "le"); > SetMaximiseFunction(L, true); > L; LP <Real Field, 2 variables> Maximising objective function: [ 3 13] Subject to constraints: 1 : [2 9] <= [40] 2 : [11 -8] <= [82] Variables bounded above by: [ ] Variables bounded below by: [ ] Solving in integers for variables [ ] > Solution(L); [9.199999999999999289 2.400000000000000355] 0Now, we place some bounds on y:
> SetUpperBound(L, 2, R!2); > SetLowerBound(L, 2, R!1); > Solution(L); [8.909090909090908283 2.000000000000000000] 0And find integer solutions:
> SetIntegerSolutionVariables(L, [1,2], true); > Solution(L); [8.000000000000000000 2.000000000000000000] 0Now, removing the 2nd constraint:
> RemoveConstraint(L, 2); > L; LP <Real Field, 2 variables> Maximising objective function: [ 3 13] Subject to constraints: 1 : [2 9] <= [40] Variables bounded above by: [ 2:2 ] Variables bounded below by: [ 2:1 ] Solving in integers for variables [ 1, 2 ] > Solution(L); [11.00000000000000000 2.000000000000000000] 0And removing the restriction to Integer values for y,
> SetIntegerSolutionVariables(L, [2], false); > Solution(L); [15.00000000000000000 1.111111111111111160] 0