fmincon, find integer values as optimal values
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohamed Musni
am 1 Feb. 2018
Kommentiert: Mohamed Musni
am 1 Feb. 2018
f =@(fr)(50*fr(1)^2 + 100)/fr(1) + (175*fr(2)^2 + 150)/fr(2) + (160*fr(3)^2 + 250)/fr(3)
lb = [0,0,0];
ub = [5,5,5];
A = [];
b = [];
Aeq = [];
beq = [];
fr0 = [1,1,1];
fr = fmincon(f,fr0,A,b,Aeq,beq,lb,ub)
output:
f =
function_handle with value:
@(fr)(50*fr(1)^2+100)/fr(1)+(175*fr(2)^2+150)/fr(2)+(160*fr(3)^2+250)/fr(3)
Local minimum possible. Constraints satisfied.
fmincon stopped because the size of the current step is less than
the default value of the step size tolerance and constraints are
satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
fr =
1.4142 0.9258 1.2500
I want to find positive integer values rather than decimal values for my variables. is there any way to include this condition with fmincon? any help will be highly appreciated. thank you
0 Kommentare
Akzeptierte Antwort
Sean de Wolski
am 1 Feb. 2018
Bearbeitet: Sean de Wolski
am 1 Feb. 2018
fmincon is not designed to deal with integer x values. You should try ga() which has an IntCon option or patternsearch() with a round() on the input values.
Of course for a small problem like this there are only 216 unique combinations of x so you could easily brute force it.
[rr,cc,pp] = ndgrid(0:5);
v = (50*rr.^2 + 100)./rr + (175*cc.^2 + 150)./cc + (160*pp.^2 + 250)./pp;
[val, idx] = min(v(:));
[rr(idx) cc(idx) pp(idx)]
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!