Fix variables to real values when using lsqnonlin optimizing
8 次查看(过去 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!