fsolve with solution constraints

6 次查看(过去 30 天)
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 个评论
dror meidan
dror meidan 2017-5-3
Hi, try to choose the initial point near the requested points (x1,x2,x3,x4)
Huiying Zhao
Huiying Zhao 2017-5-3
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."

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2017-5-3
编辑:John D'Errico 2017-5-3
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 个评论
Huiying Zhao
Huiying Zhao 2017-5-8
Thank you so much John and Alan. I think I got it. Thank you!
Supitcha Mamuangbon
Could you please show me the solution of your broblem.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by