       Re: Optimization with conditional restrictions

• To: mathgroup at smc.vnet.net
• Subject: [mg44609] Re: Optimization with conditional restrictions
• From: drbob at bigfoot.com (Bobby R. Treat)
• Date: Tue, 18 Nov 2003 06:41:38 -0500 (EST)
• References: <bovoca\$mj6\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Here's another approach:

bigM = 336;
NMinimize[Flatten[
{55*x12 + 53*x22 + 53*x32 + 3000*x11 + 3000*x21 + 3000*x31,
25*x12 + 25*x22 + 25*x32 == 16000,
Distribute[{x12, x22, x32} <= 336, List],
Distribute[{x12, x22, x32, x11, x21, x31} >= 0, List],
Distribute[{x11, x21, x31} <= 1, List],
bigM*x11 >= x12, bigM*x21 >= x22, bigM*x31 >= x32,
Element[{x11, x21, x31}, Integers]}],
{x11, x12, x21, x22, x31, x32}]

{40528., {x11 -> 1, x12 -> 304.,
x21 -> 1, x22 -> 336., x31 -> 0,
x32 -> 0.}}

If the result had not satisfied the procedural definitions of x11,
x12, x31, you'd try again with a larger 'bigM' -- 10^10, for instance.

Here's another convenient way to write the problem:

bigM = 336;
between[a_, b_][c_] := a <= c <= b
NMinimize[Flatten[
{55*x12 + 53*x22 + 53*x32 + 3000*x11 + 3000*x21 + 3000*x31,
25*x12 + 25*x22 + 25*x32 == 16000,
between[0, 336] /@ {x12, x22, x32},
between[0, 1] /@ {x11, x21, x31},
bigM*x11 >= x12, bigM*x21 >= x22,
bigM*x31 >= x32,
Element[{x11, x21, x31}, Integers]}],
{x11, x12, x21, x22, x31, x32}]

and here's another:

bigM = 336;
between[a_, b_][c_] := a <= c <= b
NMinimize[Flatten[
{55*x12 + 53*x22 + 53*x32 + 3000*x11 + 3000*x21 + 3000*x31,
25*x12 + 25*x22 + 25*x32 == 16000,
between[0, 336] /@ {x12, x22, x32},
between[0, 1] /@ {x11, x21, x31},
Thread[bigM*{x11, x21, x31} >= {x12, x22, x32}],
Element[{x11, x21, x31}, Integers]}],
{x11, x12, x21, x22, x31, x32}]

Bobby

guillerm at usal.es wrote in message news:<bovoca\$mj6\$1 at smc.vnet.net>...
> Dear group,
> I wish minimize a function, ej:
> 55*x12 + 53*x22 + 53*x32 + 3000*x11 + 3000*x21 + 3000*x31
> including conditional restrictions, ej:
> x11 == If[x12 > 0, 1, 0] && x21 == If[x22 > 0, 1, 0] &&
> x31 == If[x32 > 0, 1, 0]},
> And other standars restrictions
>
> Here is an example:
>
> NMinimize[{55*x12 + 53*x22 + 53*x32 + 3000*x11 + 3000*x21 + 3000*x31,
> 25*x12 + 25*x22 + 25*x32 == 16000 && 0 <= x12 <= 336 &&
> 0 <= x22 <= 336 && 0 <= x32 <= 336 &&
> x11 ?¸ Integers && x21 ?¸ Integers && x31 ?¸ Integers &&
> x11 == If[x12 > 0, 1, 0] && x21 == If[x22 > 0, 1, 0] &&
> x31 == If[x32 > 0, 1, 0]}, {x11, x12, x21, x22, x31, x32}]
>
> Out[]:= {42920.000, {x11 -> 1, x12 -> 2.078*^-7, x21 -> 1, x22 -> 323.29, x31 -
> > 1, x32 -> 316.7}}
>
> The out is wrong, if x12-> 0, should be x11-> 0. I have tested changing the
> restricions, writting: x11 == If[x12 > 0.01, 1, 0] && x21 == If[x22 > 0.01, 1,
> 0] && x31 == If[x32 > 0.01, 1, 0]
>
> Any help
>
> Guillermo Sanchez
>
>
>
> ---------------------------------------------
> This message was sent using Endymion MailMan.
> http://www.endymion.com/products/mailman/

```

• Prev by Date: web-based mathematical visualization and interactive geometry
• Next by Date: Re: Readability confuses mathematica?
• Previous by thread: Re: Optimization with conditional restrictions
• Next by thread: Defining function