Re: Minimizing an integer value function
- To: mathgroup at smc.vnet.net
- Subject: [mg60896] Re: Minimizing an integer value function
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 2 Oct 2005 01:54:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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