Re: how to solve for all integer solutions, linear
- To: mathgroup at smc.vnet.net
- Subject: [mg109518] Re: how to solve for all integer solutions, linear
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Mon, 3 May 2010 06:11:20 -0400 (EDT)
vars = {a, b, c, d, e, f}; eqns = Flatten[{ 5 a + 3 b + 2 c + 6 d + 5 e + f == 25, a + b + c <= 4, d + e + f <= 5, Thread[vars >= 0]}]; soln = {Reduce[eqns, vars, Integers] // ToRules}; Length[soln] 80 There are 80 solutions. Looking at only solutions for which all variables are non-zero: Select[soln, FreeQ[#, 0] &] {{a->1,b->1,c->2,d->1,e->1,f->2},{a->1,b->2,c->1,d->1,e->1,f->1}} Bob Hanlon ---- me13013 <me13013 at gmail.com> wrote: ============= Howdy, I have a small linear programming problem that I would like to solve for all integer solutions: 5a + 3b + 2c + 6d + 5e + f = 25 a + b + c <= 4 d + e + f <= 5 a,b,c,d,e,f >= 0 How can I pose this problem to Mathematica? I have looked at (and fiddled around with) the LinearProgramming function, but I don't see how to make ti give me the solution(s) I am looking for. Thanks for any help, Bob H