Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Problem with Maximize and conditions.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51068] Re: Problem with Maximize and conditions.
  • From: "Curt Fischer" <crf3 at po.cwru.edu>
  • Date: Sun, 3 Oct 2004 05:47:45 -0400 (EDT)
  • References: <cjlna7$q7f$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Nacho wrote:
[...]
>
> Minimize[{x+y+z, 1/20 x+y+5z\[Equal]100,  x \[Element] Integers,
>     y \[Element] Integers, z\[Element]Integers, 0<x<99,0<y<99,0<z<99},
> {x,y,
>     z}]
>
> I have copied the text using "Plain text" option, I hope it's fine.
>
> This returns the same expression, I suppose that Mathematica cannot
> resolve it. So I use NMinimize:
>
> NMinimize[{x+y+z, 1/20 x+y+5z\[Equal]100,  x \[Element] Integers,
>     y \[Element] Integers, z\[Element]Integers, 0<x<99,0<y<99,0<z<99},
> {x,y,
>     z}]
>
> Now I get a result, but rather weird...
>
> \!\({25.`, {x -> 1, y -> 5, z -> 1899\/100}}\)
>
> The minimum of x+y+z is 25 but z is 1899/100
> 1899/100 is not a Integers, and the nearest Integer, 19, doesn't
> satisfy 1/20x+y+5z==100, and also x+y+z is not 25 but 24.99

[...]

If you multiply the constraint equation by 20, NMinimize [] , but not
Minimize, will get you to the correct answer.  I'll leave it for the more
qualified to ponder about why.

In[1]:=
Minimize[{x+y+z,xâ??Integers,yâ??Integers,zâ??Integers,1â?¤x,98â?¥x,1â?¤y,98â?¥y,1â?¤z,98â?¥z,

    x+20y+100z\[Equal]2000},{x,y,z}]

Out[1]=
Minimize[{x+y+z,xâ??Integers,yâ??Integers,zâ??Integers,1â?¤x,98â?¥x,1â?¤y,98â?¥y,1â?¤z,98â?¥z,

    x+20 y+100 z\[Equal]2000},{x,y,z}]

In[2]:=
NMinimize[{x+y+z,xâ??Integers,yâ??Integers,zâ??Integers,1â?¤x,98â?¥x,1â?¤y,98â?¥y,1â?¤z,98â?¥z
,
    x+20y+100z\[Equal]2000},{x,y,z}]

Out[2]=
{43.,{x\[Rule]20,y\[Rule]4,z\[Rule]19}}

-- 
Curt Fischer


  • Prev by Date: Re: Courier New Button, selecting cells without brackets
  • Next by Date: Re: Trouble with NDSolve Function
  • Previous by thread: Re: Problem with Maximize and conditions.
  • Next by thread: Re: Problem with Maximize and conditions.