www.gusucode.com > optim 案例源码 matlab代码程序 > optim/LinearProgramLinearInequalityConstraintsExample.m
%% Linear Program, Linear Inequality Constraints % Solve a simple linear program defined by linear inequalities. % Copyright 2015 The MathWorks, Inc. %% % For this example, use these linear inequality constraints: % % $$ x(1) + x(2) \le 2$$ % % $$x(1) + x(2)/4 \le 1$$ % % $$x(1) - x(2) \le 2$$ % % $$-x(1)/4 - x(2) \le 1$$ % % $$-x(1) - x(2) \le -1$$ % % $$-x(1) + x(2) \le 2.$$ A = [1 1 1 1/4 1 -1 -1/4 -1 -1 -1 -1 1]; b = [2 1 2 1 -1 2]; %% % Use the objective function $-x(1) - x(2)/3$. f = [-1 -1/3]; %% % Solve the linear program. x = linprog(f,A,b)