一种
clear
p=optimproblem('ObjectiveSense','max');
c=[3100,3800,3500,2850];
a=[18,15,23,12];b=[480,650,580,390];
d=[10,16,8];e=[6800,8700,5300];
x=optimvar('x',4,3,'LowerBound',0);
p.Objective=c*sum(x,2);
p.Constraints.c1=[sum(x,2)<=a';sum(x,1)'<=d';(b*x)'<=e'];
p.Constraints.c2=[sum(x(:,1))/10==sum(x(:,2))/16
sum(x(:,2))/16==sum(x(:,3))/8];
[s,v]=solve(p)
xx=s.x
第二种
clear
p=optimproblem('ObjectiveSense','max');
c=[3100,3800,3500,2850];
a=[18,15,23,12];b=[480,650,580,390];
d=[10,16,8];e=[6800,8700,5300];
x=optimvar('x',4,3,'LowerBound',0);
p.Objective=c*sum(x,2);
p.Constraints.c1=sum(x,2)<=a';
P.Constraints.c2=sum(x,1)'<=d';
P.Constraints.c3=(b*x)'<=e';
p.Constraints.c4=[sum(x(:,1))/10==sum(x(:,2))/16
sum(x(:,2))/16==sum(x(:,3))/8];
[s,v]=solve(p)
xx=s.x