From: Bob Hanlon on 3 May 2010 06:11 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(a)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
|
Pages: 1 Prev: Front-end - a strange behaviour of Plot3D Next: How to manipulate ODE via EventLocator? |