Fix variables to real values when using lsqnonlin optimizing
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Alan Weiss
am 10 Dez. 2012
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 Kommentare
Alan Weiss
am 11 Dez. 2012
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
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!