Octave can solve Linear Programming problems using the
function. That is, Octave can solve
subject to the linear constraints A*x = b where x ≥ 0.
glpk function also supports variations of this problem.
Solve a linear program using the GNU GLPK library. Given three
glpk solves the following standard LP:
A*x = b x >= 0
but may also solve problems of the form
[ min | max ] C'*x
A*x [ "=" | "<=" | ">=" ] b x >= LB x <= UB
A column array containing the objective function coefficients.
A matrix containing the constraints coefficients.
A column array containing the right-hand side value for each constraint in the constraint matrix.
An array containing the lower bound on each of the variables. If lb is not supplied, the default lower bound for the variables is zero.
An array containing the upper bound on each of the variables. If ub is not supplied, the default upper bound is assumed to be infinite.
An array of characters containing the sense of each constraint in the constraint matrix. Each element of the array may be one of the following values
A free (unbounded) constraint (the constraint is ignored).
An inequality constraint with an upper bound (
A(i,:)*x <= b(i)).
An equality constraint (
A(i,:)*x = b(i)).
An inequality with a lower bound (
A(i,:)*x >= b(i)).
An inequality constraint with both upper and lower bounds
A(i,:)*x >= -b(i) and (
A(i,:)*x <= b(i)).
A column array containing the types of the variables.
A continuous variable.
An integer variable.
If sense is 1, the problem is a minimization. If sense is -1, the problem is a maximization. The default value is 1.
A structure containing the following parameters used to define the behavior of solver. Missing elements in the structure take on default values, so you only need to set the elements that you wish to change from the default.
msglev (default: 1)
Level of messages output by solver routines:
Error and warning messages only.
Full output (includes informational messages).
scale (default: 16)
Scaling option. The values can be combined with the bitwise OR operator and may be the following:
Geometric mean scaling.
Round scale factors to power of two.
Skip if problem is well scaled.
Alternatively, a value of 128 (
GLP_SF_AUTO) may be also
specified, in which case the routine chooses the scaling options
dual (default: 1)
Simplex method option:
Use two-phase primal simplex.
Use two-phase dual simplex, and if it fails, switch to the primal simplex.
Use two-phase dual simplex.
price (default: 34)
Pricing option (for both primal and dual simplex):
Steepest edge pricing.
itlim (default: intmax)
Simplex iterations limit. It is decreased by one each time when one simplex iteration has been performed, and reaching zero value signals the solver to stop the search.
outfrq (default: 200)
Output frequency, in iterations. This parameter specifies how frequently the solver sends information about the solution to the standard output.
branch (default: 4)
Branching technique option (for MIP only):
First fractional variable.
Last fractional variable.
Most fractional variable.
Heuristic by Driebeck and Tomlin.
Hybrid pseudocost heuristic.
btrack (default: 4)
Backtracking technique option (for MIP only):
Depth first search.
Breadth first search.
Best local bound.
Best projection heuristic.
presol (default: 1)
If this flag is set, the simplex solver uses the built-in LP presolver. Otherwise the LP presolver is not used.
lpsolver (default: 1)
Select which solver to use. If the problem is a MIP problem this flag will be ignored.
Revised simplex method.
Interior point method.
rtest (default: 34)
Ratio test technique:
Harris’ two-pass ratio test.
tmlim (default: intmax)
Searching time limit, in milliseconds.
outdly (default: 0)
Output delay, in seconds. This parameter specifies how long the solver should delay sending information about the solution to the standard output.
save (default: 0)
If this parameter is nonzero, save a copy of the problem in CPLEX LP format to the file "outpb.lp". There is currently no way to change the name of the output file.
tolbnd (default: 1e-7)
Relative tolerance used to check if the current basic solution is primal feasible. It is not recommended that you change this parameter unless you have a detailed understanding of its purpose.
toldj (default: 1e-7)
Absolute tolerance used to check if the current basic solution is dual feasible. It is not recommended that you change this parameter unless you have a detailed understanding of its purpose.
tolpiv (default: 1e-10)
Relative tolerance used to choose eligible pivotal elements of the simplex table. It is not recommended that you change this parameter unless you have a detailed understanding of its purpose.
objll (default: -DBL_MAX)
Lower limit of the objective function. If the objective function reaches this limit and continues decreasing, the solver stops the search. This parameter is used in the dual simplex method only.
objul (default: +DBL_MAX)
Upper limit of the objective function. If the objective function reaches this limit and continues increasing, the solver stops the search. This parameter is used in the dual simplex only.
tolint (default: 1e-5)
Relative tolerance used to check if the current basic solution is integer feasible. It is not recommended that you change this parameter unless you have a detailed understanding of its purpose.
tolobj (default: 1e-7)
Relative tolerance used to check if the value of the objective function is not better than in the best known integer feasible solution. It is not recommended that you change this parameter unless you have a detailed understanding of its purpose.
The optimizer (the value of the decision variables at the optimum).
The optimum value of the objective function.
Objective function lower limit reached.
Objective function upper limit reached.
Iterations limit exhausted.
Time limit exhausted.
No primal feasible solution.
No dual feasible solution.
Root LP optimum not provided.
Search terminated by application.
Relative MIP gap tolerance reached.
No primal/dual feasible solution.
Result out of range.
A data structure containing the following fields:
Time (in seconds) used for solving LP/MIP problem.
Status of the optimization.
Solution status is undefined.
Solution is feasible.
Solution is infeasible.
Problem has no feasible solution.
Solution is optimal.
Problem has no unbounded solution.
c = [10, 6, 4]'; A = [ 1, 1, 1; 10, 4, 5; 2, 2, 6]; b = [100, 600, 300]'; lb = [0, 0, 0]'; ub = ; ctype = "UUU"; vartype = "CCC"; s = -1; param.msglev = 1; param.itlim = 100; [xmin, fmin, status, extra] = ... glpk (c, A, b, lb, ub, ctype, vartype, s, param);