Skip to main content
2 of 3
added 141 characters in body
Jason B.
  • 70.2k
  • 3
  • 144
  • 297

Problem with inequality constraint

I'm using NMinimize to solve the following objective function.

S1 = 0.874334;

S2 = 0.125666;

Wd11[R_] := Exp[-((R - 6.491541)/34.9807)^1.506582];

V11[R_] := Wd11[R]*S1;

Wd12[Q_, R_] := Exp[-(((R + ((1 - 0.5)*Q)) - 14.19834)/53.64985)^1.701898];

V12[Q_, R_] := Wd12[Q, R]*S1;

Wd21[Q_, R_] := Exp[-(((R + 0.5*Q) - 13.3108)/45.07249)^1.690368];

V21[Q_, R_] := Wd21[Q, R]*S2;

Wd22[R_] := Exp[-((R - 10.4539)/39.29455)^1.617706];

V22[R_] := Wd22[R]*S2;

a := V11[R] + V12[R, Q] + V21[R, Q] + V22[R];

f[Q_] := If[1 <= Q <= 1000, 75, 
   If[1000 < Q <= 3000, 74, 
    If[3000 < Q <= 7000, 73, 
     If[7000 < Q <= 15000, 71.5, 
      If[15000 < Q <= 26000, 70.5, If[Q > 26000, 69, 0]]]]]];

T[Q_] := 850*1.6*(IntegerPart[(Q*22*0.5)/45000]) + (850*1.6*0.7^
     Log[2, 45000/(FractionalPart[(Q*0.5*22)/45000]*45000)]);

The objective function is:

OB[Q_, R_] := ((3650*f[Q]) + (3650/Q*(T[Q] + T[Q])) + (3650/
       Q (50 + 2*50)) + (0.25*
       f[Q]*(Q/2 - (0.5*10*(6 - 4)) + (R - (4*10)))) + (0.18*
       f[Q]*(3*10)))*15;

So,

NMinimize[{OB[Q, R], Q >= 1, R >= 1, a <= 0.02}, {Q, R}]

but it results in the following errors:

LessEqual::nord: Invalid comparison with 1.93457 +0.143499 I attempted. >>

NMinimize::bcons: The following constraints are not valid: {Q>=1,R>=1,0.874334 E^(-0.00113881 (-14.1983+Q+Times[<<2>>])^1.7019)+0.125666 E^(-0.00160059 (-13.3108+Q+Times[<<2>>])^1.69037)+0.125666 E^(-0.00263535 (-10.4539+R)^1.61771)+0.874334 E^(-0.00472167 (-6.49154+R)^1.50658)<=0.02}. Constraints should be equalities, inequalities, or domain specifications involving the variables. >>

I've checked this error on many pages and tried different solutions, but it still doesn't work. The problem actually arises from the third constraint (a <= 0.02). When I place a == 0.02, it gives an output, but I'm not sure if this output is correct. Anyway, why shouldn't it give me the output when a <= 0.02?

Thank you

Mahdi
  • 11
  • 1