How to get the optimum answer for this problem?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!