1
$\begingroup$

I wish to find the minimum of a function where the variables are integers. Here is a simple minimum working example (my actual function is much more complicated).

ClearAll[f];
f[{i1_, i2_}] := N[Total[1 + Sin[#] & /@ {i1, i2}]];


FindMinimum[{f[{i1, i2}], 
  0 < i1 < 11 && 10 < i2 < 21 && {i1, i2} \[Element] Integers}, {{i1, 
   5}, {i2, 15}}]

The result is an error message saying integers are only allowed for linear programming.

Is there a technique for solving this sort of problem? Thanks

$\endgroup$
  • 3
    $\begingroup$ Try using NMinimize instead, e.g., NMinimize[{f[{i1, i2}], 0 < i1 < 11 && 10 < i2 < 21}, {i1, i2} ∈ Integers] $\endgroup$ – Carl Woll Sep 19 at 17:11
  • 1
    $\begingroup$ @CarlWoll Yes that works. Thanks, I should have looked further. Please post if you wish to be accepted. $\endgroup$ – Hugh Sep 19 at 17:14

Your Answer

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

Browse other questions tagged or ask your own question.