1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| prob = optimproblem('ObjectiveSense','max');
x = optimvar('x',4,5,'LowerBound',0);
prob.Objective = 1.15*x(1,4)+1.25*x(2,3)+1.4*x(3,2)+1.06*x(4,5);
prob.Constraints.cons1 = x(1,1)+x(4,1)==10; prob.Constraints.cons2 = x(1,2)+x(3,2)+x(4,2)==1.06*x(4,1); prob.Constraints.cons3 = x(1,3)+x(2,3)+x(4,3)==1.15*x(1,1)+1.06*x(4,2); prob.Constraints.cons4 = x(1,4)+x(4,4)==1.15*x(1,2)+1.06*x(4,3); prob.Constraints.cons5 = x(4,5)==1.15*x(1,3)+1.06*x(4,4); prob.Constraints.cons6 = x(2,3)<=3; prob.Constraints.cons7 = x(3,2)<=4;
show(prob)
[sol,fval] = solve(prob);
fval sol.x
|