[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Is GLPK the software that I have been looking for?

From: Andrew Makhorin
Subject: Re: [Help-glpk] Is GLPK the software that I have been looking for?
Date: Tue, 3 Nov 2009 22:14:21 +0300

> I have been searching around for a program to find solutions to little
> problems like this: An item of meat costs 160. An item of fish costs 30.
> An item of milk costs 15. Someone spent 700 and bought at most 6 items.
> What did he buy?

> What I want is to just input some constraints:

> k * 160 + m * 30 + n * 15 = 700
> k + m + n ? 6

> and then get all solutions:
> k = 4, m = 2, n = 0

> Is GLPK the right tool for this kind of problem? I started to read
> the documentation, but GLPK seems more about finding an optimal
> solution than finding all solutions. That might be a problem.

> First I looked at logilab-constraint and PuLP, that are supposed to be
> able to solve it. But I read about them, and they seem to be Python
> frontends for GLPK (or some other solver), and since I do not know
> Python so well, I might just try to use GLPK directly.

Glpk is able to solve problems like yours. You need to formulate
your problem as MIP, write it, say, in CPLEX LP format or in GNU
MathProg modeling language, and then run the solver glpsol.

The glpk mip solver is not intended to find all optimal or integer
feasible solutions. However, once you have found one solution, you may
add an additional constraint to cut off corresponding point; this
allows you to find an alternate solution, if it exists.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]