I am trying to use NMaximize
to find the maximum value of a variable that satisfies the given constraints. Since the constraints aren't straightforward, I am using the function.
I can see the constraints are such that the value is bounded but I get the below warning messages:
NMaximize::cvmit: Failed to converge to the requested accuracy or precision within 100000 iterations.
NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
The constraint and the way I am using the function is as below:
constraint = (x | y) \[Element]
Integers && ((x == 0 && 1. <= y <= 12720.) || (1. <= x <= 10712. &&
0 <= y <
2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
2.8484*10^-43 Sqrt[
4.98614*10^92 + 4.65469*10^88 x -
3.63201*10^84 x^2]) || (10713. <= x <= 19762. &&
2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
2.8484*10^-43 Sqrt[
4.98614*10^92 + 4.65469*10^88 x - 3.63201*10^84 x^2] < y <
2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
2.8484*10^-43 Sqrt[
4.98614*10^92 + 4.65469*10^88 x - 3.63201*10^84 x^2]))
maxX =
NMaximize[{x, constraint}, {x, y}, MaxIterations -> 100000]
I have increased the MaxIterations
from 100 to 100000 but it doesn't seem to converge. I am not sure if increasing the MaxIterations
is the solution. Can you please guide me with this?
constraint /. x -> 19762
results iny \[Element] Integers && 7229.16 < y < 7344.29
andconstraint /. x -> 19763
results inFalse
. $\endgroup$x
,y
isn't needed. Thanks for pointing this out. But if I am trying to maximizey
, I need to maximize over both the variables sincey
is an expression ofx
, right? $\endgroup$