Fix variables to real values when using lsqnonlin optimizing
12 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I'm using lsqnonlin (with levenberg-marquardt) to optimize a non linear least square problem, however, the solver sometimes returns complex numbers.
Is there a way to limit the values to real numbers? I tried adding up and lower bounds at [0] and [inf] but that didn't change anything.
0 件のコメント
採用された回答
Alan Weiss
2012 年 12 月 10 日
The solver returns complex numbers only when your objective function returns complex numbers. There might be something you can do to keep the objective function real, such as bounding the range of the decision variables, but I cannot tell what the appropriate range is without seeing your objective function.
In fact, the levenberg-marquardt algorithm in lsqnonlin handles complex-valued data appropriately, so there might not be a problem.
If you insist that the solver never consider a complex value, you can use fmincon with the interior-point or sqp algorithms. But then you lose the efficiency of least squares solvers.
Alan Weiss
MATLAB mathematical toolbox documentation
2 件のコメント
Alan Weiss
2012 年 12 月 11 日
As I said before, the solver does not introduce complex numbers. Your objective function does.
mn can easily be complex, if abs(Teta1(13)) > 1. This leads to err being complex.
As documented here, the lsqnonlin trust-region-reflective algorithm satisfies constraints at all iterations. So use that algorithm, along with appropriate bounds on Teta1(13).
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!