How to do 'less than but not equal to' nonlinear constraints in fmincon?

9 Ansichten (letzte 30 Tage)
Lex
Lex am 15 Sep. 2020
Kommentiert: Lex am 16 Sep. 2020
How can I set the constraints for the solution (x1,x2,x3,x4) so that it has a non-linear constraint (x1*x2)/(x3*x4)<1 a.k.a. c = (x1*x2)/(x3*x4)-1?
I already have a separate time I test the non-linear constraint (ceq) (x1*x2)/(x3*x4)=1, and I do not want the solution of the less-than condition to necessarily overlap with the equals condition since it's usually c(x)<=0.
I am using Matlab r2019a or b.

Antworten (2)

Ameer Hamza
Ameer Hamza am 16 Sep. 2020
Numerical optimization algorithms already satisfy constraints with a tolerance value, so the less than (<) or less than equal to (<=) constraints are not fundamentally different. If you want to avoid (x1*x2)/(x3*x4)=1, then you will need to manually set the other constraint like this (x1*x2)/(x3*x4)<=0.99.

Walter Roberson
Walter Roberson am 16 Sep. 2020
A/B < 1 implies A < B implies A - B < 0,
A-B < 0 implies A - B + epsilon <= 0 for positive epsilon and epsilon goes to 0.
So... we arrive at the constraint
x1*x2 - x3*x4 + eps(realmin)
with implied <= 0
But keep in mind that two different ways of calculating the same "algebraic" number do not necessarily give the same result in floating point.
For example let x1 = 25 and x2 = 1/3, and let x3 = 1 and x4 = 25/3 . Then algebraically 25 * 1/3 should equal 1 * 25/3 . But 25 * (1/3) - 25/3 = -1.77635683940025e-15 in double precision, because 1/3 cannot be exactly represented in binary floating point. The above calculation x1*x2 - x3*x4 + eps(realmin) is negative so the constraint would be satisfied, and yet "morally" the constraint should not be satisfied, since "morally" the two expressions should be equal. If you were to switch the variables then x1*x2 - x3*x4 would be positive instead of 0 so the constraint would fail, but "accidentally" so.
  1 Kommentar
Lex
Lex am 16 Sep. 2020
Thank you for your answer. I am confused though on how to avoid the issue you bring up. Are you saying then I should run the optimization for case where x1*x2-x3*x4+eps(realmin) would be negative separate from when the variables would be switch and would be positive instead?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Systems of Nonlinear Equations finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by