linprog
linprog
Purpose ● Solve a linear programming problem ·min f'x such that 。A·X≤b 。Aeg·X=beg ·Ib≤X≤ub where f,x,b,beg,Ib,and ub are vectors and A and Aeg are matrices
Purpose • Solve a linear programming problem • min fTx such that • A · x≤ b • Aeq · x = beq • lb ≤ x ≤ ub • where f, x, b, beq, lb, and ub are vectors and A and Aeq are matrices
Syntax .x linprog(f,A,b,Aeq,beq) .x linprog(f,A,b,Aeq,beq,lb,ub) .x linprog(f,A,b,Aeg,beq,lb,ub,x0) .x linprog(f,A,b,Aeg,beq,lb,ub,x0,options) 。[x,fval=linprog(.…) [x,fval,exitflag]linprog(...) [x,fval,exitflag,output]linprog(...) [x,fval,exitflag,output,lambda]=linprog(...)
Syntax • x = linprog(f,A,b,Aeq,beq) • x = linprog(f,A,b,Aeq,beq,lb,ub) • x = linprog(f,A,b,Aeq,beq,lb,ub,x0) • x = linprog(f,A,b,Aeq,beq,lb,ub,x0,options) • [x,fval] = linprog(...) • [x,fval,exitflag] = linprog(...) • [x,fval,exitflag,output] = linprog(...) • [x,fval,exitflag,output,lambda] = linprog(...)
Description linprog solves linear programming problems. x linprog(f,A,b)solves min f*x such that A*x <=b. x linprog(f,A,b,Aeg,beg)solves the problem above while additionally satisfying the equality constraints Aeq*x beq.Set A=[]and b=[]if no inequalities exist. x linprog(f,A,b,Aeq,beg,lb,ub)defines a set of lower and upper bounds on the design variables,x,so that the solution is always in the range lb <=x <ub.Set Aeq=[]and beq=[]if no equalities exist
Description linprog solves linear programming problems. • x = linprog(f,A,b) solves min f'*x such that A*x <= b. • x = linprog(f,A,b,Aeq,beq) solves the problem above while additionally satisfying the equality constraints Aeq*x = beq. Set A=[] and b=[] if no inequalities exist. • x = linprog(f,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on the design variables, x, so that the solution is always in the range lb <= x <= ub. Set Aeq=[] and beq=[] if no equalities exist
Description [x,fval]linprog(...)returns the value of the objective function fun at the solution x: fval f*x. [x,lambda,exitflag]linprog(...)returns a value exitflag that describes the exit condition. [x,lambda,exitflag,output]linprog(...) returns a structure output that contains information about the optimization
Description • [x,fval] = linprog(...) returns the value of the objective function fun at the solution x: fval = f'*x. • [x,lambda,exitflag] = linprog(...) returns a value exitflag that describes the exit condition. • [x,lambda,exitflag,output] = linprog(...) returns a structure output that contains information about the optimization
Example min f ()=-5x1-4x2-6X3 subject to X1-X2+X3≤20 3X1+2X2+4x3≤42 3X1+2X2≤30 0≤X1,0≤2,0≤X3 First.enter the coefficients f=[-5;-4;-6]; A=[1-11 324 320]: b=[20;42;30] lb zeros(3,1);
Example • min f ( x ) = –5 x 1 – 4 x2 – 6 x3 subject to x 1 – x2 + x3 ≤ 20 3 x 1 + 2 x2+ 4 x3 ≤ 42 3 x 1 + 2 x2 ≤ 30 0 ≤ x 1, 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);
Example Next,call a linear programming routine: [x,fval,exitflag]linprog(f,A,b,[][,lb); Entering x,fval gets: X= 0.0000 15.0000 3.0000 fval=
Example • Next, call a linear programming routine: [x,fval,exitflag] = linprog(f,A,b,[],[],lb); • Entering x, fval gets: x = 0.0000 15.0000 3.0000 fval=