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!