In Matlab solution form linear programming of the formula:
wherein the object comprises optimizing f '* x, inequality constraints, equality constraints and bounds constraints variables.
Providing linprog function in Matlab solving linear optimization:
EG:
[X, FVAL, exitflag, Output, the lambda] = linprog (f, A, B, Aeq, BEQ, LB, UB, Options)
enter the f function, optimization of the object that is f, a, b, Aeq, beq, lb, ub are specifically expressed in the above formula. The last options is to optimize process parameters, mainly include:
options = optimoptions(‘linprog’,‘Algorithm’,‘interior-point’,‘Display’,‘iter’,‘MaxIterations’,10)
Selection optimization: linear optimization
selection method: the interior point method (linear optimization algorithms provide further)
: Displays the cycle number
limit cycles
There are other parameters can be set: specific search Optimization Options Matlab reference obtained in Reference.
For example:
we solve the following linear programming problem:
f = [-2;-1;1];
A = [1 4 -1; 2 -2 1];
b = [4;12];
Aeq = [1 1 2];
beq = 6;
lb = zeros(3,1);
To give the corresponding optimization parameters set and solved:
options = optimoptions('linprog','Algorithm','dual-simplex','Display','iter','MaxIterations',10)
[x,fval,exitflag,output,lambda] = linprog(f,A,b,Aeq,beq,lb,ub,options)
We can obtain the following results:
options =
linprog options:
Options used by current Algorithm ('dual-simplex'):
(Other available algorithms: 'interior-point', 'interior-point-legacy')
Set properties:
Algorithm: 'dual-simplex'
Display: 'iter'
MaxIterations: 10
Default properties:
ConstraintTolerance: 1.0000e-04
MaxTime: Inf
OptimalityTolerance: 1.0000e-07
LP preprocessing removed 0 inequalities, 0 equalities,
0 variables, and added 0 non-zero elements.
Iter Time Fval Primal Infeas Dual Infeas
0 0.001 0.000000e+00 6.999174e+00 1.113300e+00
2 0.002 -1.080000e+01 1.750843e+00 0.000000e+00
4 0.002 -8.666667e+00 0.000000e+00 0.000000e+00
Optimal solution found.
x =
4.6667
0
0.6667
fval =
-8.6667
exitflag =
1
output =
struct with fields:
iterations: 4
constrviolation: 8.8818e-16
message: 'Optimal solution found.'
algorithm: 'dual-simplex'
firstorderopt: 7.4015e-16
lambda =
struct with fields:
lower: [3×1 double]
upper: [3×1 double]
eqlin: 0.3333
ineqlin: [2×1 double]
Wherein the parameter comprises a display, data of each step of the cycle, and the final value of the function value of the most advantageous.