Re: About linear programming

• To: mathgroup at smc.vnet.net
• Subject: [mg126229] Re: About linear programming
• From: danl at wolfram.com
• Date: Thu, 26 Apr 2012 05:27:53 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <jn7uvb\$6dg\$1@smc.vnet.net>

```On Tuesday, April 24, 2012 11:35:55 PM UTC-5, Marcela Villa Marulanda wrote:
> Hi,
>
> I attempt to solve these linear programming problems in Mathematica,
> but its result is "Maximize::natt: The maximum is not attained at any
> point satisfying the given constraints", why? I've solved this problem
> in other applications and the solution is achieved.
>
> I don't know the reasons about it. I'll thank to whom give me some
> clues!
>
> Problem 1
>
> Maximize[{5 Subscript[x, 1] + 4 Subscript[x, 2] + 3 Subscript[x, 3],
>    Subscript[x, 1] + Subscript[x, 3] <= 15 &&
>     Subscript[x, 2] + 2 Subscript[x, 3] <= 25}, {Subscript[x, 1],
>    Subscript[x, 2], Subscript[x, 3]}];
>
> Problem 2
>
> Maximize[{30 Subscript[x, 1] + 40 Subscript[x, 2] +
>    20 Subscript[x, 3] + 10 Subscript[x, 4] - 15 Subscript[x, 5] -
>    20 Subscript[x, 6] - 10 Subscript[x, 7] - 8 Subscript[x, 8],
>   0.3 Subscript[x, 1] + 0.3 Subscript[x, 2] + 0.25 Subscript[x, 3] +
>      0.15 Subscript[x, 4] <= 1000 &&
>    0.25 Subscript[x, 1] + 0.35 Subscript[x, 2] +
>      0.3 Subscript[x, 3] + 0.1 Subscript[x, 4] <= 1000 &&
>    0.45 Subscript[x, 1] + 0.5 Subscript[x, 2] + 0.4 Subscript[x, 3] +
>      0.22 Subscript[x, 4] <= 1000 &&
>    0.15 Subscript[x, 1] + 0.15 Subscript[x, 2] +
>      0.1 Subscript[x, 3] + 0.05 Subscript[x, 4] <= 1000 &&
>    Subscript[x, 1] + Subscript[x, 5] == 800 &&
>    Subscript[x, 2] + Subscript[x, 6] == 750 &&
>    Subscript[x, 3] + Subscript[x, 7] == 600 &&
>    Subscript[x, 4] + Subscript[x, 8] == 500}, {Subscript[x, 1],
>   Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5],
>   Subscript[x, 6], Subscript[x, 7], Subscript[x, 8]}]

Not enough constraints. The example below may give an indication of what can happen. Possibly you also mean to constraing the variables to be nonnegative?

In[164]:= FindInstance[{30 Subscript[x, 1] + 40 Subscript[x, 2] +
20 Subscript[x, 3] + 10 Subscript[x, 4] - 15 Subscript[x, 5] -
20 Subscript[x, 6] - 10 Subscript[x, 7] - 8 Subscript[x, 8] >=
10^6, 0.3 Subscript[x, 1] + 0.3 Subscript[x, 2] +
0.25 Subscript[x, 3] + 0.15 Subscript[x, 4] <= 1000 &&
0.25 Subscript[x, 1] + 0.35 Subscript[x, 2] +
0.3 Subscript[x, 3] + 0.1 Subscript[x, 4] <= 1000 &&
0.45 Subscript[x, 1] + 0.5 Subscript[x, 2] + 0.4 Subscript[x, 3] +
0.22 Subscript[x, 4] <= 1000 &&
0.15 Subscript[x, 1] + 0.15 Subscript[x, 2] +
0.1 Subscript[x, 3] + 0.05 Subscript[x, 4] <= 1000 &&
Subscript[x, 1] + Subscript[x, 5] == 800 &&
Subscript[x, 2] + Subscript[x, 6] == 750 &&
Subscript[x, 3] + Subscript[x, 7] == 600 &&
Subscript[x, 4] + Subscript[x, 8] == 500}, {Subscript[x, 1],
Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5],
Subscript[x, 6], Subscript[x, 7], Subscript[x, 8]}]

Out[164]= {{Subscript[x, 1] -> 800., Subscript[x, 2] -> 49133.3,
Subscript[x, 3] -> -64900., Subscript[x, 4] -> 0.,
Subscript[x, 5] -> 0., Subscript[x, 6] -> -48383.3,
Subscript[x, 7] -> 65500., Subscript[x, 8] -> 500.}}

With such constraints added it will give a max.

In[167]:= Maximize[{30 Subscript[x, 1] + 40 Subscript[x, 2] +
20 Subscript[x, 3] + 10 Subscript[x, 4] - 15 Subscript[x, 5] -
20 Subscript[x, 6] - 10 Subscript[x, 7] - 8 Subscript[x, 8],
0.3 Subscript[x, 1] + 0.3 Subscript[x, 2] + 0.25 Subscript[x, 3] +
0.15 Subscript[x, 4] <= 1000 &&
0.25 Subscript[x, 1] + 0.35 Subscript[x, 2] +
0.3 Subscript[x, 3] + 0.1 Subscript[x, 4] <= 1000 &&
0.45 Subscript[x, 1] + 0.5 Subscript[x, 2] + 0.4 Subscript[x, 3] +
0.22 Subscript[x, 4] <= 1000 &&
0.15 Subscript[x, 1] + 0.15 Subscript[x, 2] +
0.1 Subscript[x, 3] + 0.05 Subscript[x, 4] <= 1000 &&
Subscript[x, 1] + Subscript[x, 5] == 800 &&
Subscript[x, 2] + Subscript[x, 6] == 750 &&
Subscript[x, 3] + Subscript[x, 7] == 600 &&
Subscript[x, 4] + Subscript[x, 8] == 500 &&
And @@ Thread[Table[Subscript[x, j], {j, 8}] >= 0]}, {Subscript[x,
1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4],
Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8]}]

Out[167]= {64625., {Subscript[x, 1] -> 800., Subscript[x, 2] -> 750.,
Subscript[x, 3] -> 387.5, Subscript[x, 4] -> 500.,
Subscript[x, 5] -> 0., Subscript[x, 6] -> 0.,
Subscript[x, 7] -> 212.5, Subscript[x, 8] -> 0.}}
Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Serious Bug in Mathematica 7 and 8.0.4.0 (latest version)
• Next by Date: Re: from a 2d-figure to an interactive 3d model? is it possible with mathematica?
• Previous by thread: Re: About linear programming
• Next by thread: Re: About linear programming