Topic: MILP with glpk solver not working

My name is Roger Guimera and I've recently started using OpenOpt for solving MILP problems (and will probably use it in the future for other LP and QP applications).

When running the MILP example referenced in http://openopt.org/MILP with the GLPK solver, the solver quits without giving any result. Any statements after the p.solve('glpk') are ignored, but I get no error message. All the output I can see is the following:

--------------------------------------------------
solver: glpk   problem: unnamed    type: MILP   goal: min
iter    objFunVal    log10(maxResidual)   
    0  0.000e+00               2.36

Does anyone have an idea of what's wrong? Any hints will be much appreciated.

Best,

Roger

Re: MILP with glpk solver not working

hi rguimera,
I dunno what happend with glpk, maybe something in its C code or CVXOPT connection.

Try using lpSolve, it works fine for me:

--------------------------------------------------
solver: lpSolve   problem: unnamed    type: MILP   goal: minimum
 iter   objFunVal   log10(maxResidual)   
    0  1.595e+04               3.71 
    1  1.262e+03            -100.00 
istop: 1
Solver:   Time Elapsed = 0.01   CPU Time Elapsed = 0.01
objFunValue: 1262.1 (feasible, MaxResidual = 0)
>>> print(r.xf)
{unnamed_oofun_1: array([-5. , -4.5]), unnamed_oofun_2: -17.0, unnamed_oofun_3: 0.0}

Also, you could try using cplex if you have it.
Regards, D.

Re: MILP with glpk solver not working

glpk works well for me if I run it from my Python IDE (Eric), but I have similar problem while running it from terminal (Linux KUBUNTU 1.04).

I have no idea what's the matter.

Re: MILP with glpk solver not working

Thanks Dmitrey. I'm running this from the command line in a Gentoo Linux box, with GLPK 4.35 and Python 2.7. The problem with the other solvers is that I don't have them installed (and I don't seem to be able to easily get lp_solve installed).

Re: MILP with glpk solver not working

It's very easy to install lpsolve: download lpsolve and its python wrapper (_source.tar.gz and _Python_source.tar.gz  files from sourceforge), run "sh ccc" in directory lpsolve55, copy ./bin/{your_arch}/liblpsolve55.so to /usr/lib or /usr/local/lib (former requires admin rights, latter requires you have LD_LIBRARY_PATH included the directory), then go to extra/Python directory and run [sudo] python setup.py install.

Or you can try
[sudo] yum install eric
and run the example from eric IDE.

Re: MILP with glpk solver not working

Dmitrey wrote:

It's very easy to install lpsolve: download lpsolve and its python wrapper (_source.tar.gz and _Python_source.tar.gz  files from sourceforge), run "sh ccc" in directory lpsolve55...

I did get lp_solve_5.5.2.0_source.tar.gz (before posting the original question to the forum) and unpacked it, but there is no ccc script sad

Re: MILP with glpk solver not working

check subdirectory "lpsolve55"

Re: MILP with glpk solver not working

Got it! It's now working with lp_solve. In any case, please post the solution if you ever find out what's wrong with GPLK.

Thanks for the help.

Re: MILP with glpk solver not working

I'm seeing this too, from the command line on an ubuntu box.  It appears to be an issue with openopt-0.33, or at least the link between openopt and glpk.  If I downgrade from openopt-0.33 to openopt-0.28, then glpk works fine.  However, it must be in the glpk library itself because the process aborts without any exception handling from python.

Re: MILP with glpk solver not working

Well, the bug seems to be in the line
   os.close(1); os.close(2)
of the file openopt/solvers/CVXOPT_LP_SOLVER.py
comment it out to fix the issue.
Unfortunately, despite of Python language portability it is OS-dependent issue, it works on some OSes and fails on some other. Even some Linux OSes differ here.
Those commands serve to reduce undesired text output.
I have committed the bugfix.

11

Re: MILP with glpk solver not working

Dmitrey wrote:

os.close(1); os.close(2)

Thanks!  That solves the problem.