4
$\begingroup$

Set

f[a_?NumberQ, b_?NumberQ] := 5

and attempt

NMinimize[{f[a, b], a>0.1 && a<0.2 && b>0 && b<10 && Element[b,Integers], {a,b}]

The response is

NMinimize::nsol: There are no points that satisfy the constraints {}.  

Yet if you try

NMinimize[{f[a, b], a>0.0 && a<0.2 && b>0 && b<10 && Element[b,Integers], {a,b}]

you get

{5., {a -> 0, b -> 6}}

Function is smooth with all derivatives.

{5., {a -> 0.15, b -> 6}}

would seem like a reasonable solution to the first request in light of the second.

$\endgroup$

1 Answer 1

1
$\begingroup$

I think this is worth reporting to Wolfram support. You can workaround the issue by using Mod:

NMinimize[
    f[a, b],
    a>0.1 && a<0.2 && b>0 && b<10 && Mod[b,1]==0,
    {a, b}
]

{5., {a -> 0.145338, b -> 9.82944*10^-9}}

$\endgroup$
1
  • $\begingroup$ this doesn't satisfy Element[b,Integers] though. $\endgroup$
    – george2079
    Dec 20, 2017 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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