Trouble with optimization options - equation problem example

HI there,
I"m trying to change the opimset options for a fsolve function and I keep getting what I believe are syntax errors, or maybe an issue with an equation problem format. As an example, I want to turn off the final displayed information after running fsolve, but the options code does not see 'Display' as an argument. I am trying to work with other option arguments as well and get the same kind of error. Any help is appreciated!
Fsolve does work when I don't call for the additional options.
C = optimvar('C',4); %Optimal vector of unknowns
eq1 = B == C(4)/C(3)/C(2);
eq2 = K == C(1)*C(3)/((C(4)*C(4));
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
eq3 = C(3) == 1 - C(1) - 2*C(2);
eq4 = C(2) == C(1) - 2*C(3); %
prob = eqnproblem; %Created an equation problem
prob.Equations.eq1 = eq1;
prob.Equations.eq2 = eq2;
prob.Equations.eq3 = eq3;
prob.Equations.eq4 = eq4;
options = optimset('Display','off');
C0.C = [a b c d]; %initial guess for unknowns
[sol,~,~] = solve(prob,C0,options);
Error using optim.internal.problemdef.ProblemImpl/solveImpl
'Display' is not a recognized parameter. For a list of valid name-value pair arguments, see the documentation for this function.
Error in optim.problemdef.EquationProblem/solve
Error in Fxn(line 65)
[sol,~,~] = solve(prob,C0,options);

1 件のコメント

Matt J
Matt J 2023 年 2 月 16 日
Notice the error message in red in your post above.

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

 採用された回答

Matt J
Matt J 2023 年 2 月 16 日
編集済み: Matt J 2023 年 2 月 16 日

0 投票

options = optimoptions(prob);
options.Display='off';
[sol,~,~] = solve(prob,C0,'Options',options);

2 件のコメント

Jennifer Wade
Jennifer Wade 2023 年 2 月 16 日
There it is! It was the ,'Options', options in the solve function that was not handled correctly.
Thanks for helping me quickly sort this out!
Matt J
Matt J 2023 年 2 月 16 日
Yes, that was the main problem, but you should probably also discontinue using optimset. I don't know how much longer it will be supported.

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

その他の回答 (0 件)

カテゴリ

質問済み:

2023 年 2 月 16 日

コメント済み:

2023 年 2 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by