opencobra / cobrapy

COBRApy is a package for constraint-based modeling of metabolic networks.
http://opencobra.github.io/cobrapy/
GNU General Public License v2.0
464 stars 218 forks source link

Problems using QSOpt esolver interface #148

Closed 0xaf1f closed 9 years ago

0xaf1f commented 9 years ago

I'm trying to use your esolver interface and I'm having issues (although this may be due to my not understanding how to use it properly since there's no documentation for it).

With the 0.3.0 release version, I get "Infeasible" right away when doing model.optimize(objective_sense="minimize", solver="esolver"). I found out that there are .sol and .bas files in /tmp, but no .lp file was ever written. With the development version (u'0.3.0.post18+git04c1b39' ), I don't even get that far. When I do model.optimize(objective_sense="minimize",solver="esolver"), I get a KeyError from the solver_dict. Here is the error:

KeyError                                  Traceback (most recent call last)
<ipython-input-3-5370421820c4> in <module>()
----> 1 model.optimize(objective_sense="minimize",solver="esolver")

cobrapy/cobra/core/Model.py in optimize(self, objective_sense, solver, quadratic_component, **kwargs)
    283         the_solution = optimize(self, solver=solver,
    284                                 objective_sense=objective_sense,
--> 285                                 **kwargs)
    286         self.solution = the_solution
    287         return the_solution

cobrapy/cobra/solvers/__init__.py in optimize(cobra_model, solver, **kwargs)
    119         solver = get_solver_name(qp=qp)
    120 
--> 121     return solver_dict[solver].solve(cobra_model, **kwargs)

This is on my Debian 7 system with GLPK 4.45, esolver version 2.5.0.

aebrahim commented 9 years ago

Are you sure cglpk is installed correctly in both versions? Make sure you can do import cobra.solvers.cglpk

Also, try using the options verbose=True and clean_up=False

On Thu, Feb 5, 2015 at 8:06 PM, عفيف الغراوي notifications@github.com wrote:

I'm trying to use your esolver interface and I'm having issues (although this may be due to my not understanding how to use it properly since there's no documentation for it).

With the 0.3.0 release version, I get "Infeasible" right away when doing model.optimize(objective_sense="minimize", solver="esolver"). I found out that there are .sol and .bas files in /tmp, but no .lp file was ever written. With the development version (u'0.3.0.post18+git04c1b39' ), I don't even get that far. When I do model.optimize(objective_sense="minimize",solver="esolver"), I get a KeyError from the solver_dict. Here is the error:

KeyError Traceback (most recent call last)

in () ----> 1 model.optimize(objective_sense="minimize",solver="esolver") cobrapy/cobra/core/Model.py in optimize(self, objective_sense, solver, quadratic_component, *_kwargs) 283 the_solution = optimize(self, solver=solver, 284 objective_sense=objective_sense, --> 285 *_kwargs) 286 self.solution = the_solution 287 return the_solution cobrapy/cobra/solvers/**init**.py in optimize(cobra_model, solver, *_kwargs) 119 solver = get_solver_name(qp=qp) 120 --> 121 return solver_dict[solver].solve(cobra_model, *_kwargs) This is on my Debian 7 system with GLPK 4.45, esolver version 2.5.0. — Reply to this email directly or view it on GitHub https://github.com/opencobra/cobrapy/issues/148.
aebrahim commented 9 years ago

You raise a good point that the solver parameters should all be better documented.

On Thu, Feb 5, 2015 at 8:23 PM, Ali Ebrahim aebrahim@ucsd.edu wrote:

Are you sure cglpk is installed correctly in both versions? Make sure you can do import cobra.solvers.cglpk

Also, try using the options verbose=True and clean_up=False

On Thu, Feb 5, 2015 at 8:06 PM, عفيف الغراوي notifications@github.com wrote:

I'm trying to use your esolver interface and I'm having issues (although this may be due to my not understanding how to use it properly since there's no documentation for it).

With the 0.3.0 release version, I get "Infeasible" right away when doing model.optimize(objective_sense="minimize", solver="esolver"). I found out that there are .sol and .bas files in /tmp, but no .lp file was ever written. With the development version (u'0.3.0.post18+git04c1b39' ), I don't even get that far. When I do model.optimize(objective_sense="minimize",solver="esolver"), I get a KeyError from the solver_dict. Here is the error:

KeyError Traceback (most recent call last)

in () ----> 1 model.optimize(objective_sense="minimize",solver="esolver") cobrapy/cobra/core/Model.py in optimize(self, objective_sense, solver, quadratic_component, *_kwargs) 283 the_solution = optimize(self, solver=solver, 284 objective_sense=objective_sense, --> 285 *_kwargs) 286 self.solution = the_solution 287 return the_solution cobrapy/cobra/solvers/**init**.py in optimize(cobra_model, solver, *_kwargs) 119 solver = get_solver_name(qp=qp) 120 --> 121 return solver_dict[solver].solve(cobra_model, *_kwargs) This is on my Debian 7 system with GLPK 4.45, esolver version 2.5.0. — Reply to this email directly or view it on GitHub https://github.com/opencobra/cobrapy/issues/148.
0xaf1f commented 9 years ago

You're right that my cglpk build probably isn't keeping up in my development version. Anyway, here is output from the release versoin 0.3.0.

In [4]: model.optimize(objective_sense="minimize", solver="esolver",verbose=True, clean_up=False)
esolver -b /tmp/tmpIl9pqA.bas -O /tmp/tmpQKGugM -L /tmp/tmp8xp13X.lp
Usage: esolver [- below -] prob_file
   -b f  write basis to file f
   -B f  read initial basis from file f
   -L    input file is in lp format (default: mps)
   -O    write the final solution to a .sol file
   -p #  run primal simplex with pricing rule #
         (1-Dantzig, 2-Devex, 3-Steep (default), 4-Partial
   -P #  number of bits to use for the float representation (default: 128)
   -d #  run dual simplex with pricing rule #
         (6-Dantzig, 7-Steep, 8-Partial, 9-Devex)
   -S    do NOT scale the initial LP
   -v    print QSopt version number
Out[4]: <Solution 'infeasible' at 0x5ac1f50>

In /tmp, I do see the lp file. However, I believe I know what the problem is, but I thought you would have run into it during your testing. On the command line, I've never been able to use esolver with -O and specify an output file name. In my experience, it uses the problem name defined in the LP file or creates "unnamed.sol" if there is no problem name. That looks like what the error is here. Like I said, my esolver version is 2.5.0.

This isn't urgent. I'll continue using my own external interface in the meantime.

aebrahim commented 9 years ago

Try version 2.5.10 of esolver

On Thu, Feb 5, 2015 at 9:15 PM, عفيف الغراوي notifications@github.com wrote:

You're right that my cglpk build probably isn't keeping up in my development version. Anyway, here is output from the release versoin 0.3.0.

In [4]: model.optimize(objective_sense="minimize", solver="esolver",verbose=True, clean_up=False) esolver -b /tmp/tmpIl9pqA.bas -O /tmp/tmpQKGugM -L /tmp/tmp8xp13X.lp Usage: esolver [- below -] prob_file -b f write basis to file f -B f read initial basis from file f -L input file is in lp format (default: mps) -O write the final solution to a .sol file -p # run primal simplex with pricing rule # (1-Dantzig, 2-Devex, 3-Steep (default), 4-Partial -P # number of bits to use for the float representation (default: 128) -d # run dual simplex with pricing rule # (6-Dantzig, 7-Steep, 8-Partial, 9-Devex) -S do NOT scale the initial LP -v print QSopt version number Out[4]: <Solution 'infeasible' at 0x5ac1f50>

In /tmp, I do see the lp file. However, I believe I know what the problem is, but I thought you would have run into it during your testing. On the command line, I've never been able to use esolver with -O and specify an output file name. In my experience, it uses the problem name defined in the LP file or creates "unnamed.sol" if there is no problem name. That looks like what the error is here. Like I said, my esolver version is 2.5.0.

This isn't urgent. I'll continue using my own external interface in the meantime.

— Reply to this email directly or view it on GitHub https://github.com/opencobra/cobrapy/issues/148#issuecomment-73184165.

0xaf1f commented 9 years ago

I see. I didn't know the version at http://www.math.uwaterloo.ca/~bico/qsopt/ex/ was different from the one at http://www.dii.uchile.cl/~daespino/QSoptExact_doc/main.html Thanks

aebrahim commented 9 years ago

So it works for you now?

On Thu, Feb 5, 2015 at 11:28 PM, عفيف الغراوي notifications@github.com wrote:

I see. I didn't know the version at http://www.math.uwaterloo.ca/~bico/qsopt/ex/ was different from the one at http://www.dii.uchile.cl/~daespino/QSoptExact_doc/main.html Thanks

— Reply to this email directly or view it on GitHub https://github.com/opencobra/cobrapy/issues/148#issuecomment-73196703.

0xaf1f commented 9 years ago

Yes. Thank you

aebrahim commented 9 years ago

OK great :)

On Fri, Feb 6, 2015 at 12:18 AM, عفيف الغراوي notifications@github.com wrote:

Yes. Thank you

— Reply to this email directly or view it on GitHub https://github.com/opencobra/cobrapy/issues/148#issuecomment-73201459.