Message Boards Message Boards

0
|
7170 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Maximization Problem

Posted 9 years ago

Dear friends,

I am a newcomer to Mathematica and I need yout help urgently. For university I am trying to solve a linear maximization problem. Unfortunately, there occur errors.....

This is my function to solve:

NMaximize [{20*y1+10*y2+5*y3,{9*x1+50*x2+1*x3-20*y1-10*y2-5*y3>=0, 10*x1+18*x2+10*x3-10*y1-15*y2-7*y3>=0, 9*x1+30*x2+3*x3-8*y1-20*y2-2*y3>=0, 8*x1+25*x2+1*x3-20*y1-20*y2-10*y3>=0, 10*x1+40*x2+5*x3-15*y1-20*y2-5*y3>=0, 7*x1+35*x2+2*x3-35*y1-10*y2-5*y3>=0, 7*x1+30*x2+3*x3-10*y1-25*y2-8*y3>=0, 12*x1+40*x2+4+x3-20*y1-25*y2-4*y3>=0, 9*x1+25*x2+2*x3-10*y1-10*y2-5*y3>=0, 10*x1+50*x2+1*x3-20*y1-15*y2-9*y3>=0, 9*x1+50*x2+1*x3=1}},{y1,y2,y3}]

**Errors**
**Set::write: Tag Plus in 9 x1+50 x2+x3 is Protected. >>**

**NMaximize::bcons: The following constraints are not valid: {1,10 x1+50 x2+x3-20 y1-15 y2-9 y3,8 x1+25 x2+x3-20 y1-20 y2-10 y3>=0,7 x1+30 x2+3 x3-10 y1-25 y2-8 y3>=0,10 x1+18 x2+10 x3-10 y1-15 y2-7 y3>=0,10 x1+40 x2+5 x3-15 y1-20 y2-5 y3>=0,7 x1+35 x2+2 x3-35 y1-10 y2-5 y3>=0,9 x1+50 x2+x3-20 y1-10 y2-5 y3>=0,9 x1+25 x2+2 x3-10 y1-10 y2-5 y3>=0,4+12 x1+40 x2+x3-20 y1-25 y2-4 y3>=0,9 x1+30 x2+3 x3-8 y1-20 y2-2 y3>=8 x1+25 x2+x3-20 y1-20 y2-10 y3}. Constraints should be equalities, inequalities, or domain specifications involving the variables. >>**

Thank you for your help!!!

POSTED BY: Dominik Braun
4 Replies
Posted 9 years ago

Mathematica rule number one: If everything else fails, look at the error message! I have to confess that one of my best teachers was Prof. dr. Error Message!

** Error Message is : NMaximize::bcons : 
  The following constraints are not valid : {***1 + 8 r***, 
     20 u1 + 10 u2 + 5 u3 == 1, ... ... .....

You can see that the first "constraint" is not an equality nor inequality. I changed it to 1+8r>=0 (== or <= seems to give a conflict) and got this:

In[193]:= NMaximize[{100 v1 + 
   25 v2, {9 w1 + 50 w2 + 1 w3 - 20 u1 - 10 u2 - 5 u3 >= 0, 
   10 w1 + 18 w2 + 10 w3 - 10 u1 - 15 u2 - 7 u3 >= 0, 
   9 w1 + 30 w2 + 3 w3 - 8 u1 - 20 u2 - 2 u3 >= 0, 
   8 w1 + 25 w2 + 1 w3 - 20 u1 - 20 u2 - 10 u3 >= 0, 
   10 w1 + 40 w2 + 5 w3 - 15 u1 - 20 u2 - 5 u3 >= 0, 
   7 w1 + 35 w2 + 2 w3 - 35 u1 - 10 u2 - 5 u3 >= 0, 
   7 w1 + 30 w2 + 3 w3 - 10 u1 - 25 u2 - 8 u3 >= 0, 
   12 w1 + 40 w2 + 4 w3 - 20 u1 - 25 u2 - 4 u3 >= 0, 
   9 w1 + 25 w2 + 2 w3 - 10 u1 - 10 u2 - 5 u3 >= 0, 
   9 w1 + 50 w2 + 1 w3 - 20 u1 - 10 u2 - 5 u3 >= 0, 
   10 w1 + 50 w2 + 1 w3 - 20 u1 - 15 u2 - 9 u3 >= 0, 
   8 r + .99 (20 u1 + 10 u2 + 5 u3) - 100 v1 - 25 v2 >= 0, 
   10 r + .98 (10 u1 + 15 u2 + 7 u3) - 70 v1 - 20 v2 >= 0, 
   8 r + 1 >= 0, 22 (8 u1 + 20 u2 + 2 u3) - 96 v1 - 30 v2 >= 0, 
   10 r + .96 (20 u1 + 20 u2 + 10 u3) - 80 v1 - 20 v2 >= 0, 
   15 r + 1.43 (15 u1 + 20 u2 + 5 u3) - 85 v1 - 15 v2 >= 0, 
   5 r + .94 (35 u1 + 10 u2 + 5 u3) - 90 v1 - 35 v2 >= 0, 
   10 r + .93 (10 u1 + 25 u2 + 8 u3) - 100 v1 - 30 v2 >= 0, 
   8 r + 1.22 (20 u1 + 25 u2 + 4 u3) - 120 v1 - 10 v2 >= 0, 
   15 r + 1.91 (10 u1 + 10 u2 + 5 u3) - 110 v1 - 15 v2 >= 0, 
   10 r + .90 (20 u1 + 15 u2 + 9 u3) - 110 v1 - 15 v2 >= 0, 
   8 r + .99 (20 u1 + 10 u2 + 5 u3) - 100 v1 - 25 v2 >= 0, 
   10 r + .98 (10 u1 + 15 u2 + 7 u3) - 70 v1 - 20 v2 >= 0, 
   8 r + 1.22 (8 u1 + 20 u2 + 2 u3) - 96 v1 - 30 v2 >= 0, 
   10 r + .96 (20 u1 + 20 u2 + 10 u3) - 80 v1 - 20 v2 >= 0, 
   15 r + 1.43 (15 u1 + 20 u2 + 5 u3) - 85 v1 - 15 v2 >= 0, 
   5 r + .94 (35 u1 + 10 u2 + 5 u3) - 90 v1 - 35 v2 >= 0, 
   10 r + .93 (10 u1 + 25 u2 + 8 u3) - 100 v1 - 30 v2 >= 0, 
   8 r + 1.22 (20 u1 + 25 u2 + 4 u3) - 120 v1 - 10 v2 >= 0, 
   15 r + 1.91 (10 u1 + 10 u2 + 5 u3) - 110 v1 - 15 v2 >= 0, 
   10 r + .90 (20 u1 + 15 u2 + 9 u3) - 80 v1 - 20 v2 >= 0, 
   9 w1 + 50 w2 + 1 w3 == 1, 20 u1 + 10 u2 + 5 u3 == 1, 
   8 r + .99*(20 u1 + 10 u2 + 5 u3) == 1, v1 >= 0, v2 >= 0, w1 >= 0, 
   w2 >= 0, w3 >= 0, u1 >= 0, u2 >= 0, u3 >= 0, r >= 0}}, {w1, w2, w3,
   u1, u2, u3, r, v1, v2}]


Out[193]= {0.4775, {w1 -> 9.6964*10^-15, w2 -> 0., w3 -> 1., 
  u1 -> 0.05, u2 -> -1.1473*10^-15, u3 -> 0., r -> 0.00125, 
  v1 -> 0.004775, v2 -> 0.}}
POSTED BY: Erik Mahieu
Posted 9 years ago

Can you just check and help me with this last problem, please?? I cannot find the mistake....

NMaximize [{100v1+25v2,{9w1+50w2+1w3-20u1-10u2-5u3? 0, 10w1+18w2+10w3-10u1-15u2-7u3? 0, 9w1+30w2+3w3-8u1-20u2-2u3? 0, 8w1+25w2+1w3-20u1-20u2-10u3? 0, 10w1+40w2+5w3-15u1-20u2-5u3?0, 7w1+35w2+2w3-35u1-10u2-5u3? 0, 7w1+30w2+3w3-10u1-25u2-8u3? 0, 12w1+40w2+4w3-20u1-25u2-4u3? 0, 9w1+25w2+2w3-10u1-10u2-5u3? 0, 9w1+50w2+1w3-20u1-10u2-5u3? 0, 10w1+50w2+1w3-20u1-15u2-9u3? 0, 8r+ .99(20u1+10u2+5u3)-100v1-25v2? 0, 10r+ .98(10u1+15u2+7u3)-70v1-20v2? 0, 8r+1,22(8u1+20u2+2u3)-96v1-30v2? 0, 10r+ .96(20u1+20u2+10u3)-80v1-20v2? 0, 15r+ 1.43(15u1+20u2+5u3)-85v1-15v2? 0, 5r+ .94(35u1+10u2+5u3)-90v1-35v2? 0, 10r+ .93(10u1+25u2+8u3)-100v1-30v2? 0, 8r+ 1.22(20u1+25u2+4u3)-120v1-10v2? 0, 15r+ 1.91(10u1+10u2+5u3)-110v1-15v2? 0, 10r+ .90(20u1+15u2+9u3)-110v1-15v2?0, 8r+ .99(20u1+10u2+5u3)-100v1-25v2? 0, 10r+ .98(10u1+15u2+7u3)-70v1-20v2? 0, 8r+1.22(8u1+20u2+2u3)-96v1-30v2? 0, 10r+ .96(20u1+20u2+10u3)-80v1-20v2? 0, 15r+ 1.43(15u1+20u2+5u3)-85v1-15v2? 0, 5r+ .94(35u1+10u2+5u3)-90v1-35v2? 0, 10r+ .93(10u1+25u2+8u3)-100v1-30v2? 0, 8r+ 1.22(20u1+25u2+4u3)-120v1-10v2? 0, 15r+ 1.91(10u1+10u2+5u3)-110v1-15v2? 0, 10r+ .90(20u1+15u2+9u3)-80v1-20v2?0, 9w1+50w2+1w3 == 1, 20u1+10u2+5u3 == 1, 8r+ .99*(20u1+10u2+5u3) == 1,v1? 0, v2? 0, w1? 0, w2? 0, w3? 0, u1? 0, u2? 0, u3? 0, r? 0 }}, {w1, w2, w3, u1, u2, u3, r, v1, v2}]

**Error Message is: NMaximize::bcons: The following constraints are not valid: {1+8 r,20 u1+10 u2+5 u3==1,8 r+0.99 (20 u1+10 u2+5 u3)==1,9 w1+50 w2+w3==1,r>=0,u1>=0,u2>=0,u3>=0,v1>=0,5 r+0.94 (35 u1+10 u2+5 u3)-90 v1-35 v2>=0,10 r+0.93 (10 u1+25 u2+8 u3)-100 v1-30 v2>=0,<<13>>,w3>=0,-20 u1-20 u2-10 u3+8 w1+25 w2+w3>=0,-20 u1-10 u2-5 u3+9 w1+50 w2+w3>=0,-20 u1-15 u2-9 u3+10 w1+50 w2+w3>=0,-10 u1-10 u2-5 u3+9 w1+25 w2+2 w3>=0,-35 u1-10 u2-5 u3+7 w1+35 w2+2 w3>=0,-10 u1-25 u2-8 u3+7 w1+30 w2+3 w3>=0,-8 u1-20 u2-2 u3+9 w1+30 w2+3 w3>=0,-20 u1-25 u2-4 u3+12 w1+40 w2+4 w3>=0,-15 u1-20 u2-5 u3+10 w1+40 w2+5 w3>=0,-10 u1-15 u2-7 u3+10 w1+18 w2+10 w3>=0}. Constraints should be equalities, inequalities, or domain specifications involving the variables. >>**

POSTED BY: Dominik Braun
Posted 9 years ago

Yo used "=" io "==" "=" is an assignment, "==" is an equality

In[4]:= NMaximize[{20 y1 + 10 y2 + 5 y3, {9 x1 + 50 x2 + 1 x3 - 20 y1 - 10 y2 - 5 y3 >= 0, 10 x1 + 18 x2 + 10 x3 - 10 y1 - 15 y2 - 7 y3 >= 0, 9 x1 + 30 x2 + 3 x3 - 8 y1 - 20 y2 - 2 y3 >= 0, 8 x1 + 25 x2 + 1 x3 - 20 y1 - 20 y2 - 10 y3 >= 0, 10 x1 + 40 x2 + 5 x3 - 15 y1 - 20 y2 - 5 y3 >= 0, 7 x1 + 35 x2 + 2 x3 - 35 y1 - 10 y2 - 5 y3 >= 0, 7 x1 + 30 x2 + 3 x3 - 10 y1 - 25 y2 - 8 y3 >= 0, 12 x1 + 40 x2 + 4 + x3 - 20 y1 - 25 y2 - 4 y3 >= 0, 9 x1 + 25 x2 + 2 x3 - 10 y1 - 10 y2 - 5 y3 >= 0, 10 x1 + 50 x2 + 1 x3 - 20 y1 - 15 y2 - 9 y3 >= 0, 9 x1 + 50 x2 + 1 x3 == 1}}, {x1, x2, x3, y1, y2, y3}]

Out[4]= {1., {x1 -> 0.778846, x2 -> -0.120192, x3 -> 0., y1 -> 0.0163462, y2 -> 0.0673077, y3 -> 0.}}

POSTED BY: Erik Mahieu
Posted 9 years ago

Thank you so much! Made my day!

POSTED BY: Dominik Braun
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract