MathGroup Archive 2007

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

Search the Archive

Re: Maximize with Integer constraints

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78421] Re: [mg78227] Maximize with Integer constraints
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sun, 1 Jul 2007 07:42:13 -0400 (EDT)
  • References: <32174685.1182850375399.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

The first answer is wrong, that's all.

Here's the same problem without reals:

Maximize[{x1 + x2 + x3 + x4,
   Element[x1 | x2 | x3 | x4, Integers] && 0 <= x1 <= 56/10 &&
    0 <= x2 <= 86/10 && 0 <= x3 <= 97/10 && 4 <= x4 <= 224/1=
0}, {x1,
   x2, x3, x4}]

{44, {x1 -> 5, x2 -> 8, x3 -> 9, x4 -> 22}}

or... to avoid typing in all those fractions:

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.0 <= x4 <= 22.4]}, {x1, x2, x3, x4}]

{44, {x1 -> 5, x2 -> 8, x3 -> 9, x4 -> 22}}

which works because:

Rationalize[
  0 <= x1 <= 5.6 && 0 <= x2 <= 8.6 && 0 <= x3 <= 9.7 &&
   4.0 <= x4 <= 22.4]

0 <= x1 <= 28/5 && 0 <= x2 <= 43/5 && 0 <= x3 <= 97/10 &&
  4 <= x4 <= 112/5

Mixing integers and reals is a risky business, I guess.

Bobby

On Tue, 26 Jun 2007 03:33:18 -0500, sdw <warwick at jps.net> 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
>
>
>



-- =

DrMajorBob at bigfoot.com


  • Prev by Date: novice needs help using Manipulate with Plot
  • Next by Date: LogLinearPlot and Manipulate
  • Previous by thread: Re: novice needs help using Manipulate with Plot
  • Next by thread: LogLinearPlot and Manipulate