MathGroup Archive 2007

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

Search the Archive

Re: Maximize with Integer constraints


On 26 Jun 2007, at 17:33, sdw wrote:

>
> given entry #1:
>
>
> Maximize[
> {x1 + x2 + x3 + x4,
> Element[x1 | x2 | x3 | x4 , Integers] &&
> 0 <= x1 <= 5.6 &&
> 0 <= x2 <= 8.6 &&
> 0 <= x3 <= 9.7 &&
> 4.0 <= x4 <= 22.4 }, {x1, x2, x3, x4}]
>
> {4., {x1 -> 0, x2 -> 0, x3 -> 0, x4 -> 4}}
>
> note -  zeros for answers
> entry #2:
> Maximize[
> {x1 + x2 + x3 + x4,
> Element[x1 | x2 | x3 | x4 , Integers] &&
> 0 <= x1 <= 5.6 &&
> 0 <= x2 <= 8.6 &&
> 0 <= x3 <= 9.7 &&
> 4.1 <= x4 <= 22.4 }, {x1, x2, x3, x4}]
>
> {44., {x1 -> 5, x2 -> 8, x3 -> 9, x4 -> 22}}
>
> note good answers...
> only difference is 4.1 vs. 4 in constraints
> any ideas what is going on?
>
> thanks,
>
> sdw
>
>

This is probably a bug, but in any case, since Maximize uses exact  
algebraic methods it is not a good idea to have approximate numbers  
in input. Rationalizing your first input will produce the right answer:

Maximize[{x1 + x2 + x3 + x4, Element[x1 | x2 | x3 | x4, Integers] &&
        Rationalize[0 <= x1 <= 5.6 && 0 <= x2 <= 8.6 && 0 <= x3 <=  
9.7 &&
            4. <= x4 <= 22.4]}, {x1, x2, x3, x4}]
  {44, {x1 -> 5, x2 -> 8, x3 -> 9, x4 -> 22}}

Andrzej Kozlowski


  • Prev by Date: Re: Re: Why use Java in Mathematica?
  • Next by Date: Re: Maximize with Integer constraints
  • Previous by thread: Maximize with Integer constraints
  • Next by thread: Re: Maximize with Integer constraints