首页 > 代码库 > matlab线性规划

matlab线性规划

clc;
clear all;
close all;

%% =========linprog()=========
% min(z) =cX
%st. AX <=b
%    Aeq <=beq;
%%=========================
c= [3, -1, -1];
A = [1,-2,1;4,-1,-1];
b = [1,-3];
Aeq = [-2,0,1];
beq = 1;
x = linprog(c,A,b,Aeq,beq);
%%=================
c =[1,2,3,4,1,2,3,4];
Aeq=[1, -1,-1, 1, -1, 1, 1, -1;
           1, -1, 1, -3, -1, 1, -1, 3;
           1, -1,- 2, 3, -1, 1,-2, -3]
beq = [0; 1; -1/2];
lb =zeros(8,1);
uv0 = ones(8,1);
options = optimset(LargeScale, off, ...
               Simplex, on,Diagnostics,on,MaxIter,1000);
[uv,fval,exitflag,output,lambda]=linprog(c,[],[],Aeq,beq,lb,[],uv0,options);

 

matlab线性规划