Error using GA in MATLAB for nonlinear constrained optimization
古いコメントを表示
I am using GA in MATLAB to minimize a convex function. I am getting the following error,
Error using constrValidate (line 59)
Constraint function must return real value.
But when in the cost.m the system called "sys" is created (which is a global variable), then the constr function computes its H_\infty norm which is a real value. Still I don't understand why I am getting this error.
My codes are attached.
Any help is really appreciated.
Thanks
採用された回答
その他の回答 (1 件)
Sebastian Castro
2018 年 3 月 23 日
0 投票
Pretty sure it's because hinfnorm can return an Inf value if the input system is unstable...
So you're going to have to handle that case and, as the error message said, return a real (or finite) number. Easiest thing is probably to limit the value of your constraint function to some really large value, keeping in mind that the optimizer just needs to keep this value <= 0.
- Sebastian
3 件のコメント
Mohammad
2018 年 3 月 23 日
Sebastian Castro
2018 年 3 月 24 日
Hmm... then maybe some of those input variables (c or gamma2) are returning complex numbers.
Have you tried putting a breakpoint in your function and seeing what comes out?
- Sebastian
Mohammad
2018 年 3 月 24 日
カテゴリ
ヘルプ センター および File Exchange で Solver Outputs and Iterative Display についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!