fsolve with solution constraints

6 ビュー (過去 30 日間)
Huiying Zhao
Huiying Zhao 2017 年 5 月 3 日
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
Supitcha Mamuangbon 2020 年 3 月 25 日
Could you please show me the solution of your broblem.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeQuadratic 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