How to get the optimum answer for this problem?
显示 更早的评论
I solved the following problem using linprog and got optimum results,
A= [-(1/0.07) 0 0 0 0 1;
0 -(1/0.45) 0 0 0 1;
0 0 -(1/0.37) 0 0 1;
0 0 0 -(1/0.88) 0 1;
0 0 0 0 -(1/0.38) 1;
1 1 1 1 1 0];
b=[0;0;0;0;0;30];
lb=[0;0;0;0;0;0];
ub=[30;30;30;30;30;30];
f=-[0;0;0;0;0;1];
[x_1]=linprog(f,A,b,[],[],lb,ub)
but for the want of integer results I’l have to solve it using genetic algorithm. I tried the following code,
A= [-(1/0.07) 0 0 0 0 1; 0 -(1/0.45) 0 0 0 1; 0 0 -(1/0.37) 0 0 1;...
0 0 0 -(1/0.88) 0 1; 0 0 0 0 -(1/0.38) 1; 1 1 1 1 1 0];
b=[0;0;0;0;0;30];
lb=[0;0;0;0;0;0];
ub=[30;30;30;30;30;30];
IntCon=[1 2 3 4 5];
opts = gaoptimset('StallGenLimit',1000,'TolFun',1e-10,...
'Generations',500,'PlotFcns',@gaplotbestf);
[x] = ga(@data,6,A,b,[],[],lb,ub,[],IntCon,opts)
(function declaration in a separate file)
function scores = data(f)
f=[0;0;0;0;0;1];
scores = max(f);
but could not get an optimum result. Don’t know where I’ve gone wrong. Please help solving this one. Thank you
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Programming and Mixed-Integer Linear Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!