fmincon, find integer values as optimal values
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sean de Wolski
2018-2-1
编辑:Sean de Wolski
2018-2-1
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)]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!