优质解答
1.yep,you are right.
2.x0:starting point
options:
x = linprog(f,A,b,Aeq,beq,lb,ub,x0,options) minimizes with the optimization options specified in the structure options.Use optimset to set these options.
3.That's OK.Just let the coefficient of x1 to be zero.
4.I think that's fine.But I'm not sure.
Examples
Find x that minimizes
f(x) = –5x1 – 4x2 –6x3,
subject to
x1 – x2 + x3 ≤ 20
3x1 + 2x2 + 4x3 ≤ 42
3x1 + 2x2 ≤ 30
0 ≤ x1,0 ≤ x2,0 ≤ x3.
First,enter the coefficients
f = [-5; -4; -6]
A = [1 -1 1
3 2 4
3 2 0];
b = [20; 42; 30];
lb = zeros(3,1);
Next,call a linear programming routine.
[x,fval,exitflag,output,lambda] = linprog(f,A,b,[],[],lb);
Entering x,lambda.ineqlin,and lambda.lower gets
x =
0.0000
15.0000
3.0000
lambda.ineqlin =
0
1.5000
0.5000
lambda.lower =
1.0000
0
0
Nonzero elements of the vectors in the fields of lambda indicate active constraints at the solution.In this case,the second and third inequality constraints (in lambda.ineqlin) and the first lower bound constraint (in lambda.lower) are active constraints (i.e.,the solution is on their constraint boundaries).