When using Fmincon, how to avoid using "max", "if-else-end" in the constraints?

3 Ansichten (letzte 30 Tage)
Tao
Tao am 28 Jan. 2016
Kommentiert: Tao am 28 Jan. 2016
I have some functions which will be called by the constraints, for example:
mx = 1.4 - 1.1*10^(-4)*Jz - 0.2*10^(-8)*Jz^2;
It could be that Jz is quite big and mx will be smaller than 0. Is that OK to modify this function like below ?
mx = max(1.4 - 1.1*10^(-4)*Jz - 0.2*10^(-8)*Jz^2, 0);
Will Fmincon like this? If not, how to avoid it? Thank you!

Antworten (1)

Walter Roberson
Walter Roberson am 28 Jan. 2016
If Jz is one of the inputs, then split the task into three pieces,
Jz < -27500-2500*sqrt(233)
Jz > -27500+2500*sqrt(233)
-27500-2500*sqrt(233) <= Jz <= -27500+2500*sqrt(233)
In the first two cases, the constraint function should hard-code mz as 0; in the third case, use your current calculation. Run all three cases, and take the best of the results.
  3 Kommentare
Walter Roberson
Walter Roberson am 28 Jan. 2016
I was asking if Jz is one of the variables being optimized.
Is it possible to place a linear constraint on the variables being optimized, so that Jz will not exceed the range I indicated?
Yes, I did mean run the three cases independently using fmincon()
Using min() or max() or if/else in a nonlinear constraint is not always a problem. However, when the boundary cannot be expressed as a linear combination of the variables being optimized, you run the risk that you are breaking up the input space into non-continguous regions, and if that happens then fmincon's algorithms will fail. If the nonlinear constraints are acting to create a dividing hyperplane that is just difficult to express linearly, then you are probably okay.
Tao
Tao am 28 Jan. 2016
It looks like this:
Unknown variables: x(1), x(2),..., x(10), x(11)
Objective function: -x(10)
low bounds for x: lb = [0;0;0;0;0;0;0;0;(-1);(0);(-1)];
high bounds for x: ub = [1;1;1;1;1;1;1;1;( 1);(1);( 1)];
Constraints: Jz = Function_1(x);
Fxy = mx(Jz);
c = Function_2 (Fxy);
ceq = Function_3 (x);

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by