Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9817
| From | Dana DeLouis <dana01@me.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: About linear programming |
| Date | 2012-04-26 09:35 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jnb4tr$5lm$1@smc.vnet.net> (permalink) |
> 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?
Hi. I believe the problems are caused by being Unbounded in the Negative direction.
Just add a lower limit that each variable is >= 0.
obj = 5 Subscript[x,1]+4 Subscript[x,2]+3 Subscript[x,3] ;
const = {
Subscript[x,1]+Subscript[x,3]<=15,
Subscript[x,2]+2 Subscript[x,3]<=25,
Subscript[x,1]>=0,
Subscript[x,2]>=0,
Subscript[x,3]>=0}
var = {
Subscript[x,1],
Subscript[x,2],
Subscript[x,3]}
Maximize[{obj ,const},var]
{175, {Subscript[x, 1]->15, Subscript[x, 2]->25, Subscript[x, 3]->0}}
When one has many variable as in your example #2, try including Thread, as in this small example...
Thread[var >= 0]
{Subscript[x, 1]>=0,Subscript[x, 2]>=0,Subscript[x, 3]>=0}
Don't know if you would find this useful:
Although LinearProgramming is a Minimizing function, one can multiply the objective by -1 to reverse the logic.
This changes your Maximizing problem into one of Minimizing.
obj ={5,4,3};
LinearProgramming[ - obj, {{1,0,3},{0,1,2}}, {{15,-1},{25,-1}} ]
{15,25,0}
obj . %
175
= = = = = = = = = =
Good luck. HTH :>)
Dana DeLouis
Mac & Math 8
= = = = = = = = = =
On Apr 25, 12:35 am, Marcela Villa Marulanda <mavim...@gmail.com> 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]}]
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: About linear programming Dana DeLouis <dana01@me.com> - 2012-04-26 09:35 +0000
csiph-web