NMaximize is not converging to a solution The 2019 Stack Overflow Developer Survey Results Are InDeclaration of variables in large Linear Programming model with NMaximizeHow trustworthy is NMaximize?Numeric range: present or notMaximalBy[#, “votes”] & not equal to MaximalBy[“votes”]?Maximimize not working properly?Does fitting data get stuck by non-homogeneous interval of data?How to find maximum (not with numbers,but with parameters) of 2-variables function under constraints?Hot to single out numeric values from NMaximizeNSum: Summand (or its derivative) is not numerical at pointProblem with constraints of NMaximize

Is bread bad for ducks?

Can't find the latex code for the ⍎ (down tack jot) symbol

Carnot-Caratheodory metric

Is flight data recorder erased after every flight?

What is this 4-propeller plane?

Limit the amount of RAM Mathematica may access?

Why Did Howard Stark Use All The Vibranium They Had On A Prototype Shield?

Falsification in Math vs Science

What is the steepest angle that a canal can be traversable without locks?

The difference between dialogue marks

It's possible to achieve negative score?

Why could you hear an Amstrad CPC working?

Can distinct morphisms between curves induce the same morphism on singular cohomology?

Inflated grade on resume at previous job, might former employer tell new employer?

Is this food a bread or a loaf?

Where to refill my bottle in India?

How to create dashed lines/arrows in Illustrator

How to make payment on the internet without leaving a money trail?

What is a mixture ratio of propellant?

Should I use my personal or workplace e-mail when registering to external websites for work purpose?

Why isn't airport relocation done gradually?

How to deal with fear of taking dependencies

Dual Citizen. Exited the US on Italian passport recently

I see my dog run



NMaximize is not converging to a solution



The 2019 Stack Overflow Developer Survey Results Are InDeclaration of variables in large Linear Programming model with NMaximizeHow trustworthy is NMaximize?Numeric range: present or notMaximalBy[#, “votes”] & not equal to MaximalBy[“votes”]?Maximimize not working properly?Does fitting data get stuck by non-homogeneous interval of data?How to find maximum (not with numbers,but with parameters) of 2-variables function under constraints?Hot to single out numeric values from NMaximizeNSum: Summand (or its derivative) is not numerical at pointProblem with constraints of NMaximize










3












$begingroup$


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?










share|improve this question









$endgroup$











  • $begingroup$
    Could try maximizing over individual regions of the piecewise set-up. But the machine precision values will make validation of inequalities kind of iffy.
    $endgroup$
    – Daniel Lichtblau
    Apr 5 at 17:44






  • 1




    $begingroup$
    I'm not seeing what $y$ has to do with this. Wouldn't the maximum value of $x$ be 19762? constraint /. x -> 19762 results in y [Element] Integers && 7229.16 < y < 7344.29 and constraint /. x -> 19763 results in False.
    $endgroup$
    – JimB
    Apr 5 at 17:51











  • $begingroup$
    @JimB, I think for x, y isn't needed. Thanks for pointing this out. But if I am trying to maximize y, I need to maximize over both the variables since y is an expression of x, right?
    $endgroup$
    – gaganso
    Apr 5 at 18:06










  • $begingroup$
    Yes, if that's what you want. The general solution appears to be $x = 19762$ and $7230leq y leq 7344$. So to maximize $y$ you'd choose $7344$.
    $endgroup$
    – JimB
    Apr 5 at 18:49







  • 1




    $begingroup$
    OK. I was assuming that you were conditioning on the maximum value of $x$.
    $endgroup$
    – JimB
    Apr 5 at 18:57















3












$begingroup$


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?










share|improve this question









$endgroup$











  • $begingroup$
    Could try maximizing over individual regions of the piecewise set-up. But the machine precision values will make validation of inequalities kind of iffy.
    $endgroup$
    – Daniel Lichtblau
    Apr 5 at 17:44






  • 1




    $begingroup$
    I'm not seeing what $y$ has to do with this. Wouldn't the maximum value of $x$ be 19762? constraint /. x -> 19762 results in y [Element] Integers && 7229.16 < y < 7344.29 and constraint /. x -> 19763 results in False.
    $endgroup$
    – JimB
    Apr 5 at 17:51











  • $begingroup$
    @JimB, I think for x, y isn't needed. Thanks for pointing this out. But if I am trying to maximize y, I need to maximize over both the variables since y is an expression of x, right?
    $endgroup$
    – gaganso
    Apr 5 at 18:06










  • $begingroup$
    Yes, if that's what you want. The general solution appears to be $x = 19762$ and $7230leq y leq 7344$. So to maximize $y$ you'd choose $7344$.
    $endgroup$
    – JimB
    Apr 5 at 18:49







  • 1




    $begingroup$
    OK. I was assuming that you were conditioning on the maximum value of $x$.
    $endgroup$
    – JimB
    Apr 5 at 18:57













3












3








3


1



$begingroup$


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?










share|improve this question









$endgroup$




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?







functions maximum






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 5 at 17:27









gagansogaganso

1528




1528











  • $begingroup$
    Could try maximizing over individual regions of the piecewise set-up. But the machine precision values will make validation of inequalities kind of iffy.
    $endgroup$
    – Daniel Lichtblau
    Apr 5 at 17:44






  • 1




    $begingroup$
    I'm not seeing what $y$ has to do with this. Wouldn't the maximum value of $x$ be 19762? constraint /. x -> 19762 results in y [Element] Integers && 7229.16 < y < 7344.29 and constraint /. x -> 19763 results in False.
    $endgroup$
    – JimB
    Apr 5 at 17:51











  • $begingroup$
    @JimB, I think for x, y isn't needed. Thanks for pointing this out. But if I am trying to maximize y, I need to maximize over both the variables since y is an expression of x, right?
    $endgroup$
    – gaganso
    Apr 5 at 18:06










  • $begingroup$
    Yes, if that's what you want. The general solution appears to be $x = 19762$ and $7230leq y leq 7344$. So to maximize $y$ you'd choose $7344$.
    $endgroup$
    – JimB
    Apr 5 at 18:49







  • 1




    $begingroup$
    OK. I was assuming that you were conditioning on the maximum value of $x$.
    $endgroup$
    – JimB
    Apr 5 at 18:57
















  • $begingroup$
    Could try maximizing over individual regions of the piecewise set-up. But the machine precision values will make validation of inequalities kind of iffy.
    $endgroup$
    – Daniel Lichtblau
    Apr 5 at 17:44






  • 1




    $begingroup$
    I'm not seeing what $y$ has to do with this. Wouldn't the maximum value of $x$ be 19762? constraint /. x -> 19762 results in y [Element] Integers && 7229.16 < y < 7344.29 and constraint /. x -> 19763 results in False.
    $endgroup$
    – JimB
    Apr 5 at 17:51











  • $begingroup$
    @JimB, I think for x, y isn't needed. Thanks for pointing this out. But if I am trying to maximize y, I need to maximize over both the variables since y is an expression of x, right?
    $endgroup$
    – gaganso
    Apr 5 at 18:06










  • $begingroup$
    Yes, if that's what you want. The general solution appears to be $x = 19762$ and $7230leq y leq 7344$. So to maximize $y$ you'd choose $7344$.
    $endgroup$
    – JimB
    Apr 5 at 18:49







  • 1




    $begingroup$
    OK. I was assuming that you were conditioning on the maximum value of $x$.
    $endgroup$
    – JimB
    Apr 5 at 18:57















$begingroup$
Could try maximizing over individual regions of the piecewise set-up. But the machine precision values will make validation of inequalities kind of iffy.
$endgroup$
– Daniel Lichtblau
Apr 5 at 17:44




$begingroup$
Could try maximizing over individual regions of the piecewise set-up. But the machine precision values will make validation of inequalities kind of iffy.
$endgroup$
– Daniel Lichtblau
Apr 5 at 17:44




1




1




$begingroup$
I'm not seeing what $y$ has to do with this. Wouldn't the maximum value of $x$ be 19762? constraint /. x -> 19762 results in y [Element] Integers && 7229.16 < y < 7344.29 and constraint /. x -> 19763 results in False.
$endgroup$
– JimB
Apr 5 at 17:51





$begingroup$
I'm not seeing what $y$ has to do with this. Wouldn't the maximum value of $x$ be 19762? constraint /. x -> 19762 results in y [Element] Integers && 7229.16 < y < 7344.29 and constraint /. x -> 19763 results in False.
$endgroup$
– JimB
Apr 5 at 17:51













$begingroup$
@JimB, I think for x, y isn't needed. Thanks for pointing this out. But if I am trying to maximize y, I need to maximize over both the variables since y is an expression of x, right?
$endgroup$
– gaganso
Apr 5 at 18:06




$begingroup$
@JimB, I think for x, y isn't needed. Thanks for pointing this out. But if I am trying to maximize y, I need to maximize over both the variables since y is an expression of x, right?
$endgroup$
– gaganso
Apr 5 at 18:06












$begingroup$
Yes, if that's what you want. The general solution appears to be $x = 19762$ and $7230leq y leq 7344$. So to maximize $y$ you'd choose $7344$.
$endgroup$
– JimB
Apr 5 at 18:49





$begingroup$
Yes, if that's what you want. The general solution appears to be $x = 19762$ and $7230leq y leq 7344$. So to maximize $y$ you'd choose $7344$.
$endgroup$
– JimB
Apr 5 at 18:49





1




1




$begingroup$
OK. I was assuming that you were conditioning on the maximum value of $x$.
$endgroup$
– JimB
Apr 5 at 18:57




$begingroup$
OK. I was assuming that you were conditioning on the maximum value of $x$.
$endgroup$
– JimB
Apr 5 at 18:57










2 Answers
2






active

oldest

votes


















5












$begingroup$

Rationalize the constraint:



constraint2 = ((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^-1 Sqrt[
4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <= x <=
19762. &&
2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) //
Rationalize[#, 0] & // Simplify;


With the Rationalized constraint you can use Maximize:



maxX = Maximize[x, constraint2, x, y]

(* 19762, x -> 19762, y -> 7287 *)

constraint2 /. maxX[[2]]

(* True *)


EDIT: To find maximum y



(maxY = Maximize[y, constraint2, x, y]) // N


enter image description here



To plot the region defined by the constraint:



reg = ImplicitRegion[constraint2, x, y];

Region[reg,
Frame -> True,
FrameLabel -> (Style[#, 12, Bold] & /@ x, y),
Epilog -> Red,
AbsolutePointSize[3],
Point[x, y /. maxX[[2]]],
Point[x, y /. maxY[[2]]]]


enter image description here






share|improve this answer











$endgroup$




















    3












    $begingroup$

    You have numbers spread a wide range of magnitudes for no good reason. This range is probably too wide for machine precision arithmetic. Also telling NMinimize explicitly that this an integer optimization problem seems to help. Try this:



    constraint2 = ((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^-1 Sqrt[
    4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <=
    x <= 19762. &&
    2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
    2.8484*10^-1 Sqrt[
    4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
    2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
    2.8484*10^-1 Sqrt[
    4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) // Expand

    maxX = NMaximize[x, constraint2, x, y, Integers,
    MaxIterations -> 10000]



    19762., x -> 19762, y -> 7311




    And with your definition of constraint:



    constraint /. maxX[[2]]



    True







    share|improve this answer











    $endgroup$












    • $begingroup$
      But constraint /. x -> 19762 /. y -> 8647 results in False?
      $endgroup$
      – JimB
      Apr 5 at 17:57










    • $begingroup$
      @JimB D'oh. Yeah, I did the simplification wrong. -.- Thanks for pointing that out.
      $endgroup$
      – Henrik Schumacher
      Apr 5 at 18:02











    • $begingroup$
      @HenrikSchumacher, thank you for this. This works for x but when I try to find the maximum y similarly, I still get the same message - NMaximize[y, res, x, y, Integers, MaxIterations -> 100000]. Output: NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
      $endgroup$
      – gaganso
      Apr 5 at 18:12











    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194684%2fnmaximize-is-not-converging-to-a-solution%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5












    $begingroup$

    Rationalize the constraint:



    constraint2 = ((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^-1 Sqrt[
    4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <= x <=
    19762. &&
    2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
    2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
    2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
    2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) //
    Rationalize[#, 0] & // Simplify;


    With the Rationalized constraint you can use Maximize:



    maxX = Maximize[x, constraint2, x, y]

    (* 19762, x -> 19762, y -> 7287 *)

    constraint2 /. maxX[[2]]

    (* True *)


    EDIT: To find maximum y



    (maxY = Maximize[y, constraint2, x, y]) // N


    enter image description here



    To plot the region defined by the constraint:



    reg = ImplicitRegion[constraint2, x, y];

    Region[reg,
    Frame -> True,
    FrameLabel -> (Style[#, 12, Bold] & /@ x, y),
    Epilog -> Red,
    AbsolutePointSize[3],
    Point[x, y /. maxX[[2]]],
    Point[x, y /. maxY[[2]]]]


    enter image description here






    share|improve this answer











    $endgroup$

















      5












      $begingroup$

      Rationalize the constraint:



      constraint2 = ((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^-1 Sqrt[
      4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <= x <=
      19762. &&
      2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
      2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
      2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
      2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) //
      Rationalize[#, 0] & // Simplify;


      With the Rationalized constraint you can use Maximize:



      maxX = Maximize[x, constraint2, x, y]

      (* 19762, x -> 19762, y -> 7287 *)

      constraint2 /. maxX[[2]]

      (* True *)


      EDIT: To find maximum y



      (maxY = Maximize[y, constraint2, x, y]) // N


      enter image description here



      To plot the region defined by the constraint:



      reg = ImplicitRegion[constraint2, x, y];

      Region[reg,
      Frame -> True,
      FrameLabel -> (Style[#, 12, Bold] & /@ x, y),
      Epilog -> Red,
      AbsolutePointSize[3],
      Point[x, y /. maxX[[2]]],
      Point[x, y /. maxY[[2]]]]


      enter image description here






      share|improve this answer











      $endgroup$















        5












        5








        5





        $begingroup$

        Rationalize the constraint:



        constraint2 = ((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^-1 Sqrt[
        4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <= x <=
        19762. &&
        2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
        2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
        2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
        2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) //
        Rationalize[#, 0] & // Simplify;


        With the Rationalized constraint you can use Maximize:



        maxX = Maximize[x, constraint2, x, y]

        (* 19762, x -> 19762, y -> 7287 *)

        constraint2 /. maxX[[2]]

        (* True *)


        EDIT: To find maximum y



        (maxY = Maximize[y, constraint2, x, y]) // N


        enter image description here



        To plot the region defined by the constraint:



        reg = ImplicitRegion[constraint2, x, y];

        Region[reg,
        Frame -> True,
        FrameLabel -> (Style[#, 12, Bold] & /@ x, y),
        Epilog -> Red,
        AbsolutePointSize[3],
        Point[x, y /. maxX[[2]]],
        Point[x, y /. maxY[[2]]]]


        enter image description here






        share|improve this answer











        $endgroup$



        Rationalize the constraint:



        constraint2 = ((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^-1 Sqrt[
        4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <= x <=
        19762. &&
        2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
        2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
        2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
        2.8484*10^-1 Sqrt[4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) //
        Rationalize[#, 0] & // Simplify;


        With the Rationalized constraint you can use Maximize:



        maxX = Maximize[x, constraint2, x, y]

        (* 19762, x -> 19762, y -> 7287 *)

        constraint2 /. maxX[[2]]

        (* True *)


        EDIT: To find maximum y



        (maxY = Maximize[y, constraint2, x, y]) // N


        enter image description here



        To plot the region defined by the constraint:



        reg = ImplicitRegion[constraint2, x, y];

        Region[reg,
        Frame -> True,
        FrameLabel -> (Style[#, 12, Bold] & /@ x, y),
        Epilog -> Red,
        AbsolutePointSize[3],
        Point[x, y /. maxX[[2]]],
        Point[x, y /. maxY[[2]]]]


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 5 at 19:18

























        answered Apr 5 at 18:54









        Bob HanlonBob Hanlon

        61.4k33598




        61.4k33598





















            3












            $begingroup$

            You have numbers spread a wide range of magnitudes for no good reason. This range is probably too wide for machine precision arithmetic. Also telling NMinimize explicitly that this an integer optimization problem seems to help. Try this:



            constraint2 = ((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^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <=
            x <= 19762. &&
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) // Expand

            maxX = NMaximize[x, constraint2, x, y, Integers,
            MaxIterations -> 10000]



            19762., x -> 19762, y -> 7311




            And with your definition of constraint:



            constraint /. maxX[[2]]



            True







            share|improve this answer











            $endgroup$












            • $begingroup$
              But constraint /. x -> 19762 /. y -> 8647 results in False?
              $endgroup$
              – JimB
              Apr 5 at 17:57










            • $begingroup$
              @JimB D'oh. Yeah, I did the simplification wrong. -.- Thanks for pointing that out.
              $endgroup$
              – Henrik Schumacher
              Apr 5 at 18:02











            • $begingroup$
              @HenrikSchumacher, thank you for this. This works for x but when I try to find the maximum y similarly, I still get the same message - NMaximize[y, res, x, y, Integers, MaxIterations -> 100000]. Output: NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
              $endgroup$
              – gaganso
              Apr 5 at 18:12















            3












            $begingroup$

            You have numbers spread a wide range of magnitudes for no good reason. This range is probably too wide for machine precision arithmetic. Also telling NMinimize explicitly that this an integer optimization problem seems to help. Try this:



            constraint2 = ((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^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <=
            x <= 19762. &&
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) // Expand

            maxX = NMaximize[x, constraint2, x, y, Integers,
            MaxIterations -> 10000]



            19762., x -> 19762, y -> 7311




            And with your definition of constraint:



            constraint /. maxX[[2]]



            True







            share|improve this answer











            $endgroup$












            • $begingroup$
              But constraint /. x -> 19762 /. y -> 8647 results in False?
              $endgroup$
              – JimB
              Apr 5 at 17:57










            • $begingroup$
              @JimB D'oh. Yeah, I did the simplification wrong. -.- Thanks for pointing that out.
              $endgroup$
              – Henrik Schumacher
              Apr 5 at 18:02











            • $begingroup$
              @HenrikSchumacher, thank you for this. This works for x but when I try to find the maximum y similarly, I still get the same message - NMaximize[y, res, x, y, Integers, MaxIterations -> 100000]. Output: NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
              $endgroup$
              – gaganso
              Apr 5 at 18:12













            3












            3








            3





            $begingroup$

            You have numbers spread a wide range of magnitudes for no good reason. This range is probably too wide for machine precision arithmetic. Also telling NMinimize explicitly that this an integer optimization problem seems to help. Try this:



            constraint2 = ((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^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <=
            x <= 19762. &&
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) // Expand

            maxX = NMaximize[x, constraint2, x, y, Integers,
            MaxIterations -> 10000]



            19762., x -> 19762, y -> 7311




            And with your definition of constraint:



            constraint /. maxX[[2]]



            True







            share|improve this answer











            $endgroup$



            You have numbers spread a wide range of magnitudes for no good reason. This range is probably too wide for machine precision arithmetic. Also telling NMinimize explicitly that this an integer optimization problem seems to help. Try this:



            constraint2 = ((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^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2]) || (10713. <=
            x <= 19762. &&
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) -
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2] < y <
            2.08565*10^-36 (3.04959*10^39 + 2.24751*10^34 x) +
            2.8484*10^-1 Sqrt[
            4.98614*10^8 + 4.65469*10^4 x - 3.63201 x^2])) // Expand

            maxX = NMaximize[x, constraint2, x, y, Integers,
            MaxIterations -> 10000]



            19762., x -> 19762, y -> 7311




            And with your definition of constraint:



            constraint /. maxX[[2]]



            True








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 5 at 18:02

























            answered Apr 5 at 17:53









            Henrik SchumacherHenrik Schumacher

            59.6k582166




            59.6k582166











            • $begingroup$
              But constraint /. x -> 19762 /. y -> 8647 results in False?
              $endgroup$
              – JimB
              Apr 5 at 17:57










            • $begingroup$
              @JimB D'oh. Yeah, I did the simplification wrong. -.- Thanks for pointing that out.
              $endgroup$
              – Henrik Schumacher
              Apr 5 at 18:02











            • $begingroup$
              @HenrikSchumacher, thank you for this. This works for x but when I try to find the maximum y similarly, I still get the same message - NMaximize[y, res, x, y, Integers, MaxIterations -> 100000]. Output: NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
              $endgroup$
              – gaganso
              Apr 5 at 18:12
















            • $begingroup$
              But constraint /. x -> 19762 /. y -> 8647 results in False?
              $endgroup$
              – JimB
              Apr 5 at 17:57










            • $begingroup$
              @JimB D'oh. Yeah, I did the simplification wrong. -.- Thanks for pointing that out.
              $endgroup$
              – Henrik Schumacher
              Apr 5 at 18:02











            • $begingroup$
              @HenrikSchumacher, thank you for this. This works for x but when I try to find the maximum y similarly, I still get the same message - NMaximize[y, res, x, y, Integers, MaxIterations -> 100000]. Output: NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
              $endgroup$
              – gaganso
              Apr 5 at 18:12















            $begingroup$
            But constraint /. x -> 19762 /. y -> 8647 results in False?
            $endgroup$
            – JimB
            Apr 5 at 17:57




            $begingroup$
            But constraint /. x -> 19762 /. y -> 8647 results in False?
            $endgroup$
            – JimB
            Apr 5 at 17:57












            $begingroup$
            @JimB D'oh. Yeah, I did the simplification wrong. -.- Thanks for pointing that out.
            $endgroup$
            – Henrik Schumacher
            Apr 5 at 18:02





            $begingroup$
            @JimB D'oh. Yeah, I did the simplification wrong. -.- Thanks for pointing that out.
            $endgroup$
            – Henrik Schumacher
            Apr 5 at 18:02













            $begingroup$
            @HenrikSchumacher, thank you for this. This works for x but when I try to find the maximum y similarly, I still get the same message - NMaximize[y, res, x, y, Integers, MaxIterations -> 100000]. Output: NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
            $endgroup$
            – gaganso
            Apr 5 at 18:12




            $begingroup$
            @HenrikSchumacher, thank you for this. This works for x but when I try to find the maximum y similarly, I still get the same message - NMaximize[y, res, x, y, Integers, MaxIterations -> 100000]. Output: NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.
            $endgroup$
            – gaganso
            Apr 5 at 18:12

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194684%2fnmaximize-is-not-converging-to-a-solution%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

            Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

            Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020