Mathematica 9 is now available
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: [mg51081] Re: [mg51046] Problem with Maximize and conditions.
  • From: "Fred Simons" <f.h.simons at tue.nl>
  • Date: Mon, 4 Oct 2004 06:17:40 -0400 (EDT)
  • References: <200410020719.DAA26384@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Nacho,

It seems to me that the following trick should be unnecessary:

In[105]:=
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}//Reduce},
{x,y,z}]

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

Fred Simons
Eindhoven University of Technology

----- Original Message ----- 
From: "Nacho" <ncc1701zzz at hotmail.com>
To: mathgroup at smc.vnet.net
Subject: [mg51081] [mg51046] Problem with Maximize and conditions.


> Hello.
> 
> I was trying to solve a problem with Mathematica 5 and I am getting
> strange results.
> 
> The problem is:
> 
> Minimize x+y+z, with the condition that 1/20x+y+5z==100 and x,y,z are
> Integers between 1 and 98 (inclusive).
> 
> So I use:
> 
> 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
> 
> I don't know why Mathematica has returned a Real when I specified an
> Integers. I suppose that it is related to the use of NMinimize. I
> suppose that it considers that 18.99 is so near of 19 that it can be
> considered an Integer.
> 
> If you remove the condition of z being an Integer, the result changes,
> so it is affecting. Also, if you ask for "1899/100 e Integers" it
> returns False.
> 
> So, does anybody know how to solve this? Ideally, I would like to know
> why Minimize doesn't work (so I have to use NMinimize), but in any
> case, how to solve the problem.
> 
> Thanks!
> 


  • Prev by Date: Re: Trouble with NDSolve Function
  • Next by Date: Re: 3D data set
  • Previous by thread: Re: Problem with Maximize and conditions.
  • Next by thread: Re: Problem with Maximize and conditions.