Python Linear Programming on Ubuntu

Discussion in 'Python' started by Fett, Sep 17, 2008.

  1. Fett

    Fett Guest

    I am trying to find a wrapper to do linear programming within python.
    I am using an ubuntu machine and I have apt-get'd lp_solve, which
    works just fine. If someone knows of a wrapper that will work with
    that that'd be great.

    I also heard that scipy has a wrapper, however, I can't find any
    documentation on it, nor can I seem to find it with dir(). If anyone
    knows where there is good documentation on this I would love to use
    that (the more native to python the better imo).

    I have tried many things, including http://lpsolve.sourceforge.net/5.5/Python.htm,
    openopt, and cvxopt. I can't seem to find any with enough
    documentation to get me off the ground. Some I can't compile, some I
    can't even find out how to compile.

    If anyone knows of an LP package (preferably with IP as well, like
    lp_solve has), that interfaces well with python and has enough
    documentation to get a dependency newb like myself off the ground that
    would be great.
    Fett, Sep 17, 2008
    #1
    1. Advertising

  2. On Sep 16, 8:50 pm, Fett <> wrote:
    > I am trying to find a wrapper to do linear programming within python.
    > I am using an ubuntu machine and I have apt-get'd lp_solve, which
    > works just fine. If someone knows of a wrapper that will work with
    > that that'd be great.
    >
    > I also heard that scipy has a wrapper, however, I can't find any
    > documentation on it, nor can I seem to find it with dir(). If anyone
    > knows where there is good documentation on this I would love to use
    > that (the more native to python the better imo).
    >
    > I have tried many things, includinghttp://lpsolve.sourceforge.net/5.5/Python.htm,
    > openopt, and cvxopt. I can't seem to find any with enough
    > documentation to get me off the ground. Some I can't compile, some I
    > can't even find out how to compile.
    >
    > If anyone knows of an LP package (preferably with IP as well, like
    > lp_solve has), that interfaces well with python and has enough
    > documentation to get a dependency newb like myself off the ground that
    > would be great.


    Google says:

    about 254,000 for linear programming python.

    Link 3 is:

    http://wiki.python.org/moin/NumericAndScientific/Libraries

    Scroll down.
    Aaron \Castironpi\ Brady, Sep 17, 2008
    #2
    1. Advertising

  3. Fett

    Robert Kern Guest

    Fett wrote:
    > I am trying to find a wrapper to do linear programming within python.
    > I am using an ubuntu machine and I have apt-get'd lp_solve, which
    > works just fine. If someone knows of a wrapper that will work with
    > that that'd be great.
    >
    > I also heard that scipy has a wrapper, however, I can't find any
    > documentation on it, nor can I seem to find it with dir(). If anyone
    > knows where there is good documentation on this I would love to use
    > that (the more native to python the better imo).


    No, scipy doesn't have such a wrapper, sorry.

    > I have tried many things, including http://lpsolve.sourceforge.net/5.5/Python.htm,
    > openopt, and cvxopt. I can't seem to find any with enough
    > documentation to get me off the ground. Some I can't compile, some I
    > can't even find out how to compile.
    >
    > If anyone knows of an LP package (preferably with IP as well, like
    > lp_solve has), that interfaces well with python and has enough
    > documentation to get a dependency newb like myself off the ground that
    > would be great.


    PuLP should be fairly easy to build against GLPK or COIN (provided you have them
    installed; I'm pretty sure Ubuntu has a GLPK package but I'm not sure about
    COIN), but you will have to edit the Makefile for your system:

    http://www.jeannot.org/~js/code/index.en.html#PuLP

    You can ask on scipy-users about OpenOpt, and hopefully Dmitrey will be able to
    help you. If you want to get cvxopt or the Python wrappers in lp_solve itself
    working, I suggest asking their mailing lists.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
    Robert Kern, Sep 17, 2008
    #3
  4. Fett

    Fett Guest

    On Sep 16, 9:00 pm, "Aaron \"Castironpi\" Brady"
    <> wrote:
    > On Sep 16, 8:50 pm, Fett <> wrote:
    >
    >
    >
    > > I am trying to find a wrapper to do linear programming within python.
    > > I am using an ubuntu machine and I have apt-get'd lp_solve, which
    > > works just fine. If someone knows of a wrapper that will work with
    > > that that'd be great.

    >
    > > I also heard that scipy has a wrapper, however, I can't find any
    > > documentation on it, nor can I seem to find it with dir(). If anyone
    > > knows where there is good documentation on this I would love to use
    > > that (the more native to python the better imo).

    >
    > > I have tried many things, includinghttp://lpsolve.sourceforge.net/5.5/Python.htm,
    > > openopt, and cvxopt. I can't seem to find any with enough
    > > documentation to get me off the ground. Some I can't compile, some I
    > > can't even find out how to compile.

    >
    > > If anyone knows of an LP package (preferably with IP as well, like
    > > lp_solve has), that interfaces well with python and has enough
    > > documentation to get a dependency newb like myself off the ground that
    > > would be great.

    >
    > Google says:
    >
    > about 254,000 for linear programming python.
    >
    > Link 3 is:
    >
    > http://wiki.python.org/moin/NumericAndScientific/Libraries
    >
    > Scroll down.


    Yes, many of those seem to be deprecated, without destinations to
    links, most are poorly or not documented at all. The few that are, I
    still can't get running. Of those 254, I think I have tried at least
    10 pages worth. Still no luck.

    # lpsolvpy - Can't get it to compile - dependency problems.
    # Lp_solve5 - NO python binding yet. Volunteers needed for python
    bindings.
    # pycplex - You need to compile the CPX.so module. Change the required
    paths to CPLEX, Python and numpy in the Makefile, and type "make". Not
    sure what to do here.
    # GLPK (GNU Linear Programming Kit) - Hrm... might be something here,
    I missed the second link to the python bindings, looked all over the
    glpk site for anything about python.
    # SciPy -- http://www.scipy.org - supposedly has this, but as I said,
    I can't find any mention of it anywhere but on the site you linked.
    # pySimplex - (broken link)(broken link)
    # Simplex - link is broken, but nothing is mentioned

    I'll take a closer look at glpk's python bindings and if there is any
    documentation on them, maybe I'll have some luck. btw, I have been
    looking for something that works, I have over 5 packages on my desktop
    that I have tried to get up and running, but none of them seem to
    work. glpk makes 6.
    Fett, Sep 17, 2008
    #4
  5. On Sep 16, 9:25 pm, Fett <> wrote:
    > On Sep 16, 9:00 pm, "Aaron \"Castironpi\" Brady"
    >
    >
    >
    > <> wrote:
    > > On Sep 16, 8:50 pm, Fett <> wrote:

    >
    > > > I am trying to find a wrapper to do linear programming within python.
    > > > I am using an ubuntu machine and I have apt-get'd lp_solve, which
    > > > works just fine. If someone knows of a wrapper that will work with
    > > > that that'd be great.

    >
    > > > I also heard that scipy has a wrapper, however, I can't find any
    > > > documentation on it, nor can I seem to find it with dir(). If anyone
    > > > knows where there is good documentation on this I would love to use
    > > > that (the more native to python the better imo).

    >
    > > > I have tried many things, includinghttp://lpsolve.sourceforge.net/5.5/Python.htm,
    > > > openopt, and cvxopt. I can't seem to find any with enough
    > > > documentation to get me off the ground. Some I can't compile, some I
    > > > can't even find out how to compile.

    >
    > > > If anyone knows of an LP package (preferably with IP as well, like
    > > > lp_solve has), that interfaces well with python and has enough
    > > > documentation to get a dependency newb like myself off the ground that
    > > > would be great.

    >
    > > Google says:

    >
    > > about 254,000 for linear programming python.

    >
    > > Link 3 is:

    >
    > >http://wiki.python.org/moin/NumericAndScientific/Libraries

    >
    > > Scroll down.

    >
    > Yes, many of those seem to be deprecated, without destinations to
    > links, most are poorly or not documented at all. The few that are, I
    > still can't get running. Of those 254, I think I have tried at least
    > 10 pages worth. Still no luck.
    >
    > # lpsolvpy - Can't get it to compile - dependency problems.
    > # Lp_solve5 - NO python binding yet. Volunteers needed for python
    > bindings.
    > # pycplex - You need to compile the CPX.so module. Change the required
    > paths to CPLEX, Python and numpy in the Makefile, and type "make". Not
    > sure what to do here.
    > # GLPK (GNU Linear Programming Kit) - Hrm... might be something here,
    > I missed the second link to the python bindings, looked all over the
    > glpk site for anything about python.
    > # SciPy --http://www.scipy.org- supposedly has this, but as I said,
    > I can't find any mention of it anywhere but on the site you linked.
    > # pySimplex - (broken link)(broken link)
    > # Simplex - link is broken, but nothing is mentioned
    >
    > I'll take a closer look at glpk's python bindings and if there is any
    > documentation on them, maybe I'll have some luck. btw, I have been
    > looking for something that works, I have over 5 packages on my desktop
    > that I have tried to get up and running, but none of them seem to
    > work. glpk makes 6.


    If you can find one working in C, use ctypes to link into Python. We
    can help you with that part. It lets you pass primitive types,
    structs, arrays, pointers, to C modules and return values. You need
    to know the C signatures to set up the Pythonized signatures.
    Aaron \Castironpi\ Brady, Sep 17, 2008
    #5
  6. Fett

    Fett Guest

    On Sep 16, 9:44 pm, "Aaron \"Castironpi\" Brady"
    <> wrote:
    > On Sep 16, 9:25 pm, Fett <> wrote:
    >
    >
    >
    > > On Sep 16, 9:00 pm, "Aaron \"Castironpi\" Brady"

    >
    > > <> wrote:
    > > > On Sep 16, 8:50 pm, Fett <> wrote:

    >
    > > > > I am trying to find a wrapper to do linear programming within python.
    > > > > I am using an ubuntu machine and I have apt-get'd lp_solve, which
    > > > > works just fine. If someone knows of a wrapper that will work with
    > > > > that that'd be great.

    >
    > > > > I also heard that scipy has a wrapper, however, I can't find any
    > > > > documentation on it, nor can I seem to find it with dir(). If anyone
    > > > > knows where there is good documentation on this I would love to use
    > > > > that (the more native to python the better imo).

    >
    > > > > I have tried many things, includinghttp://lpsolve.sourceforge.net/5.5/Python.htm,
    > > > > openopt, and cvxopt. I can't seem to find any with enough
    > > > > documentation to get me off the ground. Some I can't compile, some I
    > > > > can't even find out how to compile.

    >
    > > > > If anyone knows of an LP package (preferably with IP as well, like
    > > > > lp_solve has), that interfaces well with python and has enough
    > > > > documentation to get a dependency newb like myself off the ground that
    > > > > would be great.

    >
    > > > Google says:

    >
    > > > about 254,000 for linear programming python.

    >
    > > > Link 3 is:

    >
    > > >http://wiki.python.org/moin/NumericAndScientific/Libraries

    >
    > > > Scroll down.

    >
    > > Yes, many of those seem to be deprecated, without destinations to
    > > links, most are poorly or not documented at all. The few that are, I
    > > still can't get running. Of those 254, I think I have tried at least
    > > 10 pages worth. Still no luck.

    >
    > > # lpsolvpy - Can't get it to compile - dependency problems.
    > > # Lp_solve5 - NO python binding yet. Volunteers needed for python
    > > bindings.
    > > # pycplex - You need to compile the CPX.so module. Change the required
    > > paths to CPLEX, Python and numpy in the Makefile, and type "make". Not
    > > sure what to do here.
    > > # GLPK (GNU Linear Programming Kit) - Hrm... might be something here,
    > > I missed the second link to the python bindings, looked all over the
    > > glpk site for anything about python.
    > > # SciPy --http://www.scipy.org-supposedly has this, but as I said,
    > > I can't find any mention of it anywhere but on the site you linked.
    > > # pySimplex - (broken link)(broken link)
    > > # Simplex - link is broken, but nothing is mentioned

    >
    > > I'll take a closer look at glpk's python bindings and if there is any
    > > documentation on them, maybe I'll have some luck. btw, I have been
    > > looking for something that works, I have over 5 packages on my desktop
    > > that I have tried to get up and running, but none of them seem to
    > > work. glpk makes 6.

    >
    > If you can find one working in C, use ctypes to link into Python. We
    > can help you with that part. It lets you pass primitive types,
    > structs, arrays, pointers, to C modules and return values. You need
    > to know the C signatures to set up the Pythonized signatures.


    Ok, it seems that I have found one (although without an integer
    programming component): upon searching for glpk in the package manager
    in ubuntu I found a package called cvxopt, it is a bit clunky
    (compared to the niceness of lp_solve), but I think I can figure this
    one out. Thanks all who answered.
    Fett, Sep 17, 2008
    #6
  7. Fett

    Joachim Dahl Guest

    CVXOPT supports ILP via GLPK or MOSEK. Documentation is in the doc-
    strings
    for cvxopt.glkp.ilp and cvxopt.mosek.ilp.

    The ILP interfaces are not mentioned otherwise in the documentation,
    as the main
    focus of CVXOPT is convex solvers.

    For additional questions on CVXOPT please use the discussion forum:
    http://groups.google.com/group/cvxopt

    best regards
    Joachim

    On Sep 17, 5:57 am, Fett <> wrote:
    > On Sep 16, 9:44 pm, "Aaron \"Castironpi\" Brady"
    >
    >
    >
    > <> wrote:
    > > On Sep 16, 9:25 pm, Fett <> wrote:

    >
    > > > On Sep 16, 9:00 pm, "Aaron \"Castironpi\" Brady"

    >
    > > > <> wrote:
    > > > > On Sep 16, 8:50 pm, Fett <> wrote:

    >
    > > > > > I am trying to find a wrapper to do linear programming within python.
    > > > > > I am using an ubuntu machine and I have apt-get'd lp_solve, which
    > > > > > works just fine. If someone knows of a wrapper that will work with
    > > > > > that that'd be great.

    >
    > > > > > I also heard that scipy has a wrapper, however, I can't find any
    > > > > > documentation on it, nor can I seem to find it with dir(). If anyone
    > > > > > knows where there is good documentation on this I would love to use
    > > > > > that (the more native to python the better imo).

    >
    > > > > > I have tried many things, includinghttp://lpsolve.sourceforge.net/5.5/Python.htm,
    > > > > > openopt, andcvxopt. I can't seem to find any with enough
    > > > > > documentation to get me off the ground. Some I can't compile, some I
    > > > > > can't even find out how to compile.

    >
    > > > > > If anyone knows of an LP package (preferably with IP as well, like
    > > > > > lp_solve has), that interfaces well with python and has enough
    > > > > > documentation to get a dependency newb like myself off the ground that
    > > > > > would be great.

    >
    > > > > Google says:

    >
    > > > > about 254,000 for linear programming python.

    >
    > > > > Link 3 is:

    >
    > > > >http://wiki.python.org/moin/NumericAndScientific/Libraries

    >
    > > > > Scroll down.

    >
    > > > Yes, many of those seem to be deprecated, without destinations to
    > > > links, most are poorly or not documented at all. The few that are, I
    > > > still can't get running. Of those 254, I think I have tried at least
    > > > 10 pages worth. Still no luck.

    >
    > > > # lpsolvpy - Can't get it to compile - dependency problems.
    > > > # Lp_solve5 - NO python binding yet. Volunteers needed for python
    > > > bindings.
    > > > # pycplex - You need to compile the CPX.so module. Change the required
    > > > paths to CPLEX, Python and numpy in the Makefile, and type "make". Not
    > > > sure what to do here.
    > > > # GLPK (GNU Linear Programming Kit) - Hrm... might be something here,
    > > > I missed the second link to the python bindings, looked all over the
    > > > glpk site for anything about python.
    > > > # SciPy --http://www.scipy.org-supposedlyhas this, but as I said,
    > > > I can't find any mention of it anywhere but on the site you linked.
    > > > # pySimplex - (broken link)(broken link)
    > > > # Simplex - link is broken, but nothing is mentioned

    >
    > > > I'll take a closer look at glpk's python bindings and if there is any
    > > > documentation on them, maybe I'll have some luck. btw, I have been
    > > > looking for something that works, I have over 5 packages on my desktop
    > > > that I have tried to get up and running, but none of them seem to
    > > > work. glpk makes 6.

    >
    > > If you can find one working in C, use ctypes to link into Python.  We
    > > can help you with that part.  It lets you pass primitive types,
    > > structs, arrays, pointers, to C modules and return values.  You need
    > > to know the C signatures to set up the Pythonized signatures.

    >
    > Ok, it seems that I have found one (although without an integer
    > programming component): upon searching for glpk in the package manager
    > in ubuntu I found a package calledcvxopt, it is a bit clunky
    > (compared to the niceness of lp_solve), but I think I can figure this
    > one out. Thanks all who answered.
    Joachim Dahl, Sep 17, 2008
    #7

  8. > > http://wiki.python.org/moin/NumericAndScientific/Libraries
    > >
    > > Scroll down.

    >
    > Yes, many of those seem to be deprecated, without destinations to
    > links, most are poorly or not documented at all. The few that are, I
    > still can't get running. Of those 254, I think I have tried at least
    > 10 pages worth. Still no luck.
    >
    > # lpsolvpy - Can't get it to compile - dependency problems.
    > # Lp_solve5 - NO python binding yet. Volunteers needed for python
    > bindings.
    > # pycplex - You need to compile the CPX.so module. Change the required
    > paths to CPLEX, Python and numpy in the Makefile, and type "make". Not
    > sure what to do here.
    > # GLPK (GNU Linear Programming Kit) - Hrm... might be something here,
    > I missed the second link to the python bindings, looked all over the
    > glpk site for anything about python.
    > # SciPy -- http://www.scipy.org - supposedly has this, but as I said,
    > I can't find any mention of it anywhere but on the site you linked.
    > # pySimplex - (broken link)(broken link)
    > # Simplex - link is broken, but nothing is mentioned
    >
    > I'll take a closer look at glpk's python bindings and if there is any
    > documentation on them, maybe I'll have some luck. btw, I have been
    > looking for something that works, I have over 5 packages on my desktop
    > that I have tried to get up and running, but none of them seem to
    > work. glpk makes 6.


    You are right that this is an unsatisfying experience. Fortunately,
    the referred site is a wiki. Why don't you edit it and delete the
    broken
    links or add the package that did the job for you to the list, so that
    others do not need to go through the same hassle.

    - harold -
    Harold Fellermann, Sep 17, 2008
    #8
  9. Fett

    Martin Manns Guest

    On Tue, 16 Sep 2008 19:25:58 -0700 (PDT)
    Fett <> wrote:

    > # SciPy -- http://www.scipy.org - supposedly has this, but as I said,
    > I can't find any mention of it anywhere but on the site you linked.


    I found OpenOpt on the site:
    http://scipy.org/scipy/scikits/wiki/MILP

    I downloaded the svn version and installed it on my Debian box.
    There were some error messages while installing. However, the example
    seems to work anyways. I am using the solver glpk from the
    package python-glpk.

    I hope that this works on your Ubuntu system as well.
    Martin Manns, Sep 17, 2008
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    1,109
    Roedy Green
    Nov 15, 2005
  2. leo
    Replies:
    2
    Views:
    754
    Julian V. Noble
    Feb 14, 2006
  3. leo
    Replies:
    1
    Views:
    532
    Jim Langston
    Feb 14, 2006
  4. Replies:
    3
    Views:
    761
    Carl Banks
    Oct 17, 2007
  5. SPE - Stani's Python Editor
    Replies:
    1
    Views:
    452
    SPE - Stani's Python Editor
    Apr 29, 2008
Loading...

Share This Page