3
$\begingroup$
Maximize[{91 x1 + 71 x2 + 105 x3 + 103 x4 + 96 x5, 
  2.36 x1 + 2.12 x2 + 1.89 x3 + 3.77 x4 + 2.87 x5 <= 50, 0 <= x1 <= 3,
   1 <= x3 <= 5, 1 <= x4, 2 <= x3 + x4 <= 5}, {x1, x2, x3, x4, 
  x5}, NonNegativeIntegers]

Because the Maximize function sometimes returns the local optimal value, I want to use the NMaximize function to solve it. But the NMaximize function cannot use the non negative integer field as the solution condition:

NMaximize[-x^4 - 3 x^2 + x, x∈ 
      Reals]  
NMaximize[-x^4 - 3 x^2 + x, x∈ 
       NonNegativeReals]  
NMaximize[{91 x1 + 71 x2 + 105 x3 + 103 x4 + 96 x5, 
      2.36 x1 + 2.12 x2 + 1.89 x3 + 3.77 x4 + 2.87 x5 <= 50, 0 <= x1 <= 3,
       0 <= x2, 1 <= x3 <= 5, 1 <= x4, 
      2 <= x3 + x4 <= 5}, {x1, x2, x3, x4, x5} ∈ 
      NonNegativeIntegers]
$\endgroup$
7
$\begingroup$

Use {x1, x2, x3, x4, x5} ∈ NonNegativeIntegers as condition to NMaximize:

NMaximize[{91 x1 + 71 x2 + 105 x3 + 103 x4 + 96 x5, 
2.36 x1 + 2.12 x2 + 1.89 x3 + 3.77 x4 + 2.87 x5 <= 50, 0 <= x1 <= 3,
0 <= x2, 1 <= x3 <= 5, 1 <= x4, 
2 <= x3 + x4 <= 5, {x1, x2, x3, x4, x5} ∈ NonNegativeIntegers},
{x1, x2, x3, x4, x5}]

{1852., {x1 -> 3, x2 -> 0, x3 -> 4, x4 -> 1, x5 -> 11}}

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.