Message Boards Message Boards

GROUPS:

Solve the following non-linear integer max-problem with NMaximize?

Posted 1 month ago
260 Views
|
8 Replies
|
1 Total Likes
|

Hi! I have tried to solve the following non-linear integer max-problem, without setting some lower (positive) bounds on Q1, Q2 & Q3, just being positive. Mathematica fails to find the optimal solotion, unless I increase the lower bounds for Q2 & Q3 to about 40. I have solved the same problem in LINGO and found the global solution {P -> 60., Q1 -> 0, Q2 -> 52., Q3 -> 60., y1 -> 0, y2 -> 1, y3 -> 1, \z1 -> 0, z2 -> 0, z3 -> 1} in less than a second. Any suggestions?

NMaximize[{(Q1 + Q2 + Q3) (P - 20) + 3*0.5 (80 - P) Q1*z1 + 
   2*0.5 (100 - 0.8 P) Q2*z2 + 2*0.5 (90 - 0.5 P) Q3*z3, 
  z1 + z2 + z3 == 1 && Q1 == (80 - P) y1 && Q2 == (100 - 0.8 P) y2 && 
   Q3 == (90 - 0.5 P) y3 && 2 <= y1 + y2 + y3 <= 3 && 
   3 <= y1 + y2 + y3 + z1 + z2 + z3 <= 4 && 
   2 <= y1 + y2 + y3 + z1 <= 3 && 2 <= y1 + y2 + y3 + z2 <= 3 && 
   2 <= y1 + y2 + y3 + z3 <= 3 && Q1 >= 0 && Q2 >= 0 && Q3 >= 0 && 
   1 >= y1 >= 0 && 1 >= y2 >= 0 && 1 >= y3 >= 0 && z1 >= 0 && 
   z2 >= 0 && z3 >= 0 && 80 > P > 20 && y1 \[Element] Integers && 
   y2 \[Element] Integers && y3 \[Element] Integers && 
   z1 \[Element] Integers && z2 \[Element] Integers && 
   z3 \[Element] Integers}, {P, Q1, Q2, Q3, y1, y2, y3, z1, z2, z3}]
Attachments:
8 Replies

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

enter image description here

Hi! I followed the standard code by Mathematica. I have solved more than thousand problems with NMaximize, without any problem before. I do not think there is a problem with the code (which is attached). My question is why I need to tighten the lower bounds in Q2>=40 & Q3>=40 in order to get a solution, (as you can see in the file), while in LINGO such a strengthening is not required. I have the feeling that Mathematica is fast around the zero values in Q2, Q3, and does not search for the global solution.

Attachments:

Hello

NMaximize with standard options Fail yes is True .From this tutorial a get answer what LINGO gave you.

Other helpful things.

Ordinary user,Regards MI.

Attachments:

Thanks very much Mariusz! It was as I expected. However, I am surprised one should need to select the method for NMaximize for such a relatively "easy" problem and the solution provided by Mathematica was very bad indeed. For LINGO, I did not need to select their methods, it found it very fast!

Christos

According to the documentation:

If f and cons are linear, NMaximize can always find global maxima, over both real and integer values. Otherwise, NMaximize may sometimes find only a local maximum.

I did not have time to look into your code in detail to find better options/approach yet but your expressions are not linear so you cannot guarantee the global maximum.

Regards

Neil

I've found that using Simulated Annealing for NMinimize and NMaximize often works better than the default Nelder Mead method.

Hi Frank! I have tried "Simulated Annealing" with many different options according to tutorial, but I did not get the correct one! On the other hand, the "Differential Evolution" suggested by Mariusz above works fine (but still a little bit slower than LINGO).

It's probably a good idea to always try several different methods.

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