MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Minimizing an integer value function


On 10/1/05 at 2:55 AM, ingolf.dahl at telia.com (Ingolf Dahl) wrote:

>Suppose we have a function that only takes integer values, but
>anyway is quite smooth

>e.g.

>func1[x_, y_, z_] := Floor[(x - 2.1)^2 + (y - 3.21)^2 + (z - 4.3)^4
>+ 54.9]

>or

>func2[x_, y_, z_] := Floor[(x - 2)^2 + (y - 30000)^2 + (z - 4)^4 +
>54.8]

>What is the best way to minimize such a function, using
>Mathematica?

Hmmm... You say the function "only takes integer values" but the examples you post are written to accept any value and return integer values. Also, I would not decribe something returning integer values as quite smooth. However, NMinimize does what you want. For example,

In[1]:=
NMinimize[{func1[x, y, z], {x, y, z} \[Element] Integers}, 
  {x, y, z}]
Out[1]=
{54., {x -> 2, y -> 3, z -> 4}}
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: mole units
  • Next by Date: Re: Rounding?
  • Previous by thread: Minimizing an integer value function
  • Next by thread: Finding length in recursive definition?