Optimization of multiple variables without any toolbox
Afficher commentaires plus anciens
I have 5 variables, say l1,l2,g1,g2,g3. I want to optimize the gi (i=1,2,3) inside the two loops of l1 and l2 i.e. for each combination of l1 and l2, I want an optimal set of g_i for which the computed value should show a maximum and so on for the next values of l1 and l2. I don't have any tool box for this and I want to optimize without those.
fid = fopen( sprintf(.......))
for l1=0:0.01:1
for l2:0:0.01:1
% optimization of gi
for g1=0:0.01:0.5
x2=[];
for g2=0:0.01:0.5
for g3=0:0.01:0.5
maxen=.....%some calculations
x2=[x2;g2 g3 maxen];
end
[p, q]=max(x2(:,3));% max with indices
end
x3=x2(q,1);%g2
x4=x2(q,2);%g3
x5=x2(q,3);%maxen
end
fprintf(fid,'%f %f %f %f %f\t %f %f \r\n',l1,l2,g1,x3,x4,x5,maxen);
end
end
fclose(fid);
I tried for a simple case for fixed l2 and fixed g1 but the result of maxen and x5 doesnt match while writing x2=[] outside g2 to get proper indices of g2 and g3 for that maximum value of maxen (writing in the .dat file). However, if write x2=[] inside g2, I lost the precise value of g2 as it shows end values only but with optimal g3 and equal maxen and x5 there. How can I optimize gi and find this optimal set there for maximum of maxen for each value of two outer loops (l1,l2)?.
if optimization is not possible with this way, do I need to use any algorithms for this?
Please suggest other alternates for the same.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Get Started with Optimization Toolbox 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!