clc cd v:\cursos\pos\otimiza\aulas A=[2 1;4 1] A = 2 1 4 1 c=[-6;-2] c = -6 -2 b=[8;10] b = 8 10 lb=[0;0] lb = 0 0 help linprog LINPROG Linear programming. X=LINPROG(f,A,b) solves the linear programming problem: min f'*x subject to: A*x <= b x X=LINPROG(f,A,b,Aeq,beq) solves the problem above while additionally satisfying the equality constraints Aeq*x = beq. 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 in the range LB <= X <= UB. Use empty matrices for LB and UB if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below; set UB(i) = Inf if X(i) is unbounded above. X=LINPROG(f,A,b,Aeq,beq,LB,UB,X0) sets the starting point to X0. This option is only available with the active-set algorithm. The default interior point algorithm will ignore any non-empty starting point. X=LINPROG(f,A,b,Aeq,Beq,LB,UB,X0,OPTIONS) minimizes with the default optimization parameters replaced by values in the structure OPTIONS, an argument created with the OPTIMSET function. See OPTIMSET for details. Use options are Display, Diagnostics, TolFun, LargeScale, MaxIter. Currently, only 'final' and 'off' are valid values for the parameter Display when LargeScale is 'off' ('iter' is valid when LargeScale is 'on'). [X,FVAL]=LINPROG(f,A,b) returns the value of the objective function at X: FVAL = f'*X. [X,FVAL,EXITFLAG] = LINPROG(f,A,b) returns EXITFLAG that describes the exit condition of LINPROG. If EXITFLAG is: > 0 then LINPROG converged with a solution X. 0 then LINPROG reached the maximum number of iterations without converging. < 0 then the problem was infeasible or LINPROG failed. [X,FVAL,EXITFLAG,OUTPUT] = LINPROG(f,A,b) returns a structure OUTPUT with the number of iterations taken in OUTPUT.iterations, the type of algorithm used in OUTPUT.algorithm, the number of conjugate gradient iterations (if used) in OUTPUT.cgiterations. [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(f,A,b) returns the set of Lagrangian multipliers LAMBDA, at the solution: LAMBDA.ineqlin for the linear inequalities A, LAMBDA.eqlin for the linear equalities Aeq, LAMBDA.lower for LB, and LAMBDA.upper for UB. NOTE: the LargeScale (the default) version of LINPROG uses a primal-dual method. Both the primal problem and the dual problem must be feasible for convergence. Infeasibility messages of either the primal or dual, or both, are given as appropriate. The primal problem in standard form is min f'*x such that A*x = b, x >= 0. The dual problem is max b'*y such that A'*y + s = f, s >= 0. op=optimset('linprog') op = ActiveConstrTol: [] DerivativeCheck: [] Diagnostics: 'off' DiffMaxChange: [] DiffMinChange: [] Display: 'final' GoalsExactAchieve: [] GradConstr: [] GradObj: [] Hessian: [] HessMult: [] HessPattern: [] HessUpdate: [] Jacobian: [] JacobMult: [] JacobPattern: [] LargeScale: 'on' LevenbergMarquardt: [] LineSearchType: [] MaxFunEvals: [] MaxIter: 85 MaxPCGIter: [] MeritFunction: [] MinAbsMax: [] Preconditioner: [] PrecondBandWidth: [] ShowStatusWindow: [] TolCon: [] TolFun: 1.0000e-008 TolPCG: [] TolX: [] TypicalX: [] op=optimset(op,'LargeScale','off') op = ActiveConstrTol: [] DerivativeCheck: [] Diagnostics: 'off' DiffMaxChange: [] DiffMinChange: [] Display: 'final' GoalsExactAchieve: [] GradConstr: [] GradObj: [] Hessian: [] HessMult: [] HessPattern: [] HessUpdate: [] Jacobian: [] JacobMult: [] JacobPattern: [] LargeScale: 'off' LevenbergMarquardt: [] LineSearchType: [] MaxFunEvals: [] MaxIter: 85 MaxPCGIter: [] MeritFunction: [] MinAbsMax: [] Preconditioner: [] PrecondBandWidth: [] ShowStatusWindow: [] TolCon: [] TolFun: 1.0000e-008 TolPCG: [] TolX: [] TypicalX: [] help linprog LINPROG Linear programming. X=LINPROG(f,A,b) solves the linear programming problem: min f'*x subject to: A*x <= b x X=LINPROG(f,A,b,Aeq,beq) solves the problem above while additionally satisfying the equality constraints Aeq*x = beq. 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 in the range LB <= X <= UB. Use empty matrices for LB and UB if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below; set UB(i) = Inf if X(i) is unbounded above. X=LINPROG(f,A,b,Aeq,beq,LB,UB,X0) sets the starting point to X0. This option is only available with the active-set algorithm. The default interior point algorithm will ignore any non-empty starting point. X=LINPROG(f,A,b,Aeq,Beq,LB,UB,X0,OPTIONS) minimizes with the default optimization parameters replaced by values in the structure OPTIONS, an argument created with the OPTIMSET function. See OPTIMSET for details. Use options are Display, Diagnostics, TolFun, LargeScale, MaxIter. Currently, only 'final' and 'off' are valid values for the parameter Display when LargeScale is 'off' ('iter' is valid when LargeScale is 'on'). [X,FVAL]=LINPROG(f,A,b) returns the value of the objective function at X: FVAL = f'*X. [X,FVAL,EXITFLAG] = LINPROG(f,A,b) returns EXITFLAG that describes the exit condition of LINPROG. If EXITFLAG is: > 0 then LINPROG converged with a solution X. 0 then LINPROG reached the maximum number of iterations without converging. < 0 then the problem was infeasible or LINPROG failed. [X,FVAL,EXITFLAG,OUTPUT] = LINPROG(f,A,b) returns a structure OUTPUT with the number of iterations taken in OUTPUT.iterations, the type of algorithm used in OUTPUT.algorithm, the number of conjugate gradient iterations (if used) in OUTPUT.cgiterations. [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(f,A,b) returns the set of Lagrangian multipliers LAMBDA, at the solution: LAMBDA.ineqlin for the linear inequalities A, LAMBDA.eqlin for the linear equalities Aeq, LAMBDA.lower for LB, and LAMBDA.upper for UB. NOTE: the LargeScale (the default) version of LINPROG uses a primal-dual method. Both the primal problem and the dual problem must be feasible for convergence. Infeasibility messages of either the primal or dual, or both, are given as appropriate. The primal problem in standard form is min f'*x such that A*x = b, x >= 0. The dual problem is max b'*y such that A'*y + s = f, s >= 0. [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(c,A,b,[],[],lb,[],[0 0],op) Optimization terminated successfully. X = 1.0000 6.0000 FVAL = -18 EXITFLAG = 1 OUTPUT = iterations: 2 algorithm: 'medium-scale: activeset' firstorderopt: [] cgiterations: [] LAMBDA = lower: [2x1 double] upper: [2x1 double] eqlin: [0x1 double] ineqlin: [2x1 double] LAMBDA.ineqlin ans = 1.0000 1.0000 A=[0.8 0.44;0.05 0.1;0.1 0.36] A = 0.8000 0.4400 0.0500 0.1000 0.1000 0.3600 b=[24000;2000;6000] b = 24000 2000 6000 c=[-8.1;-10.8] c = -8.1000 -10.8000 lb=[0;0] lb = 0 0 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(c,A,b,[],[],lb,[],[0 0],op) Optimization terminated successfully. X = 1.0e+004 * 2.6207 0.6897 FVAL = -2.8676e+005 EXITFLAG = 1 OUTPUT = iterations: 3 algorithm: 'medium-scale: activeset' firstorderopt: [] cgiterations: [] LAMBDA = lower: [2x1 double] upper: [2x1 double] eqlin: [0x1 double] ineqlin: [3x1 double] LAMBDA.ineqlin ans = 4.6552 87.5172 0 4.655*2400 ans = 11172 87.5*200 ans = 17500 4.655*24000*.05 ans = 5586 87.5*2000*.05 ans = 8750 4.655*2400 ans = 11172 87.5*200-4.655*2400 ans = 6328 24000-200 ans = 23800 87.5*200-4.655*200 ans = 16569 b=[24000-200;2000+200;6000] b = 23800 2200 6000 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(c,A,b,[],[],lb,[],[0 0],op) Optimization terminated successfully. X = 1.0e+004 * 2.4345 0.9828 FVAL = -3.0333e+005 EXITFLAG = 1 OUTPUT = iterations: 3 algorithm: 'medium-scale: activeset' firstorderopt: [] cgiterations: [] LAMBDA = lower: [2x1 double] upper: [2x1 double] eqlin: [0x1 double] ineqlin: [3x1 double] FVAL-286758 ans = -5.9009e+005 FVAL+286758 ans = -1.6573e+004 c c = -8.1000 -10.8000 c=[-8.1;-7.5] c = -8.1000 -7.5000 b=[24000;2000;6000] b = 24000 2000 6000 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(c,A,b,[],[],lb,[],[0 0],op) Optimization terminated successfully. X = 1.0e+004 * 2.6207 0.6897 FVAL = -264000 EXITFLAG = 1 OUTPUT = iterations: 3 algorithm: 'medium-scale: activeset' firstorderopt: [] cgiterations: [] LAMBDA = lower: [2x1 double] upper: [2x1 double] eqlin: [0x1 double] ineqlin: [3x1 double] LAMBDA.ineqlin ans = 7.5000 42.0000 0 c=[-8.1;-5.5] c = -8.1000 -5.5000 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(c,A,b,[],[],lb,[],[0 0],op) Optimization terminated successfully. X = 1.0e+004 * 2.6207 0.6897 FVAL = -2.5021e+005 EXITFLAG = 1 OUTPUT = iterations: 2 algorithm: 'medium-scale: activeset' firstorderopt: [] cgiterations: [] LAMBDA = lower: [2x1 double] upper: [2x1 double] eqlin: [0x1 double] ineqlin: [3x1 double] c=[-8.1;-2.5] c = -8.1000 -2.5000 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(c,A,b,[],[],lb,[],[0 0],op) Optimization terminated successfully. X = 30000 0 FVAL = -243000 EXITFLAG = 1 OUTPUT = iterations: 3 algorithm: 'medium-scale: activeset' firstorderopt: [] cgiterations: [] LAMBDA = lower: [2x1 double] upper: [2x1 double] eqlin: [0x1 double] ineqlin: [3x1 double] c c = -8.1000 -2.5000 c=[-8.1;-10.8] c = -8.1000 -10.8000 lbu=[0;0;0] lbu = 0 0 0 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(b,-A',c,[],[],lbu,[],[],op) Optimization terminated successfully. X = 4.6552 87.5172 0 FVAL = 2.8676e+005 EXITFLAG = 1 OUTPUT = iterations: 3 algorithm: 'medium-scale: activeset' firstorderopt: [] cgiterations: [] LAMBDA = lower: [3x1 double] upper: [3x1 double] eqlin: [0x1 double] ineqlin: [2x1 double] LAMBDA.ineqlin ans = 1.0e+004 * 2.6207 0.6897 quit