I've got a problem with optimization and using a variable for exponent

Here is my matlab codeR
x = optimvar('x','type','integer','LowerBound',0,'UpperBound',48);
y = optimvar('y','type','integer','LowerBound',0,'UpperBound',48);
obj = fcn2optimexpr(@objfunx,x,y);
prob = optimproblem('Objective',obj);
con1 = x <= 48; prob.Constraints.constr = con1;
con2 = y <= 48; prob.Constraints.constr = con2;
con3 = (1-((0.2.^x))) + ((0.2.^x)).*(1-((0.3.^y))) >= 0.99;
prob.Constraints.constr = con3;
x0.x = 0; x0.y = 0;
show(prob)
function f = objfunx(x,y)
f =(60).*(x) + ((0.2.^x)).*(y).*(20);
end
and I got this error message
Error using optim.internal.problemdef.Power
Exponent must be a finite real numeric scalar.
Error in .^
Error in Test (line 8)
I want to get solution x, y
how can I solve this problem? I'm going to appreciate if you give me whole code

 採用された回答

Alan Weiss
Alan Weiss 2020 年 2 月 27 日
編集済み: Alan Weiss 2020 年 2 月 27 日

0 投票

Optimization Toolbox™ does not support general nonlinear integer programming. Use ga or surrogateopt for nonlinear integer programming.
Or, for this problem, you could do exhaustive search; there are fewer than 2500 = 50^2 possibilities.
Alan Weiss
MATLAB mathematical toolbox documentation

1 件のコメント

Minsu Seo
Minsu Seo 2020 年 2 月 28 日
Thanks Alan Weiss, I already solved this problem with exhaustive search you mentioned.
I just wondered if I could solve that problem using some internal function that the MATLAB provides.
Your answer is really helpful for me and thank you again.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019b

質問済み:

2020 年 2 月 26 日

コメント済み:

2020 年 2 月 28 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by