fsolve with solution constraints

6 Ansichten (letzte 30 Tage)
Huiying Zhao
Huiying Zhao am 3 Mai 2017
Hi, I am solving a list of nonlinear equations with part of the solutions having constraints. For example, the solution is consist of [x1, x2,x3,x4] with x3 and x4 should within [0,1] and x1 and x2 should be bigger than 0.
I try to search this kind of topic and seems that fsolve cannot solve this kind of problem. I should try fmincon or lsqnonlin. But the result of fmincon or lsqnonlin require that all solution have the same constraints. But in my situation, my solution has different constraints.
I am not sure whether my understanding is correct.
Thanks!
  2 Kommentare
dror meidan
dror meidan am 3 Mai 2017
Hi, try to choose the initial point near the requested points (x1,x2,x3,x4)
Huiying Zhao
Huiying Zhao am 3 Mai 2017
I find the way to provide different constraints. But my problem is not a square problem ( number of equations is smaller than number of variables). So I should have multiple solutions, but when I try to solve by lsqnonlin, I got an error that "Error using lsqncommon (line 67) The Levenberg-Marquardt algorithm does not handle bound constraints and the trust-region-reflective algorithm requires at least as many equations as variables; aborting."

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

John D'Errico
John D'Errico am 3 Mai 2017
Bearbeitet: John D'Errico am 3 Mai 2017
You claim that fmincon and lsqnonlin require the SAME constraints. This is completely false. Read the help for LB and UB.
In the case you describe,
LB = [0, 0, 0, 0];
UB = [inf, inf, 1, 1];
That applies to either fmincon or lsqnonlin.
Be careful here, since you state bigger than zero for two variables. Constraints in tools like these cannot be formulated as a strict inequality (>). Worse, the tolerance on a constraint may allow a variable to fail the constraint by a small amount.
Fsolve does not allow bound constraints, although you could solve the problem in an fsolve context using transformations of the variables. There is no reason to do so, since lsqnonlin applies directly, at least in theory. (That said until I read your comment that the problem is underdetermined.) One nice thing about the transformative approach to constraints is you can indeed formulate a strict inequality.
A problem arises since there are fewer constraints then unknowns. So that means there will be in general an infinite number of solutions. As such the problem is poorly posed for lsqnonlin.
What you have not told us is how many equations do you have? This could be pertinent.
Regardless, the simple solution seems to be to formulate it as an fmincon problem, as the sum of squares of residuals. It should be able to find some solution from the set of infinitely many solutions.
  3 Kommentare
Huiying Zhao
Huiying Zhao am 8 Mai 2017
Thank you so much John and Alan. I think I got it. Thank you!
Supitcha Mamuangbon
Supitcha Mamuangbon am 25 Mär. 2020
Could you please show me the solution of your broblem.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Quadratic Programming and Cone Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by