Are you using glpk or cglpk as the argument to Model.optimize? They are both interfaces to GLPK. However, I recommend that you use cglpk... It's faster, better supported, and works with the latest version of GLPK. It shouldn't ever hang on M scale LP's. If it does please send be the model so I can test it.
This time_limit option is forwarded to the solver interface. If the solver can't find a solution in the allotted time then the solution status will be something other than "optimal". I am not 100% sure if the glpk interface supports this option (I have to check) but cglpk definitely does.
--
You received this message because you are subscribed to the Google Groups "cobra pie" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-pie+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
AttributeError Traceback (most recent call last) <ipython-input-20-7ff36dd07f76> in <module>() ----> 1 solver = cobra.solvers.cglpk AttributeError: 'module' object has no attribute 'cglpk'
"
Ah yes, apparently I was using pip 1.5.6, which is somewhat legacy, to say the least! I have upgraded pip and installed cobra again and it is working fine! Thanks for all your help.
Cheers,
Will.
On 18/08/2015 15:55, Ali Ebrahim wrote:
Ok so the issue is that it is compiling against an old version of glpk.
In any case it's still weird because it should be installing from a binary wheel and not compiling anything. What version of pip do you have? Is it up to date?
Also which python are you running? The one that came with your mac, the one from homebrew, or the one from python.org
On Aug 18, 2015 7:40 AM, "Bryant, William A" <w.br...@imperial.ac.uk> wrote:
I just wanted to say it works fine on my Linux box, just not on the Mac. There are two errors below - the first is from your suggestion and the second is the output of 'pip install cobra' after 'pip uninstall cobra', which appears to be pertinent.
The result of running 'import cobra.solvers.cglpk' is:
"
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-21-465ef8852430> in <module>() ----> 1 import cobra.solvers.cglpk ImportError: dlopen(/Users/wbryant/.virtualenvs/cobra/lib/python2.7/site-packages/cobra/solvers/cglpk.so, 2): Symbol not found: _glp_read_prob Referenced from: /Users/wbryant/.virtualenvs/cobra/lib/python2.7/site-packages/cobra/solvers/cglpk.so Expected in: flat namespace in /Users/wbryant/.virtualenvs/cobra/lib/python2.7/site-packages/cobra/solvers/cglpk.so "
Also, when I use "pip install cobra" I get the following message:
"
Installing collected packages: cobra
Running setup.py install for cobra
building 'cobra.solvers.cglpk' extension
clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cobra/solvers/cglpk.c -o build/temp.macosx-10.9-x86_64-2.7/cobra/solvers/cglpk.o -Wno-unused-function
cobra/solvers/cglpk.c:7085:20: warning: implicit declaration of function 'glp_write_prob' is invalid in C99 [-Wimplicit-function-declaration]
__pyx_v_result = glp_write_prob(__pyx_v_self->glp, 0, __pyx_v_name);
^
cobra/solvers/cglpk.c:7690:20: warning: implicit declaration of function 'glp_read_prob' is invalid in C99 [-Wimplicit-function-declaration]
__pyx_v_result = glp_read_prob(__pyx_v_self->glp, 0, __pyx_v_name);
^
2 warnings generated.
clang -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.9-x86_64-2.7/cobra/solvers/cglpk.o -L/usr/local/lib -lglpk -o build/lib.macosx-10.9-x86_64-2.7/cobra/solvers/cglpk.so
Successfully installed cobra
Cleaning up...
"
Cheers,
Will.
On 18/08/2015 15:12, Ali Ebrahim wrote:
That is interesting.
What is the output of import cobra.solvers.cgpk
Hi again,
The 'time_limit' option is working great now for the 'glpk' solver, but seems not to work for 'cglpk'. I have set the 'time_limit=0.0000000000000000001' and tried a few hundred runs with a typical sized model (about 1000 reactions), which times out for every 'glpk' optimisation, but does not time out with 'cglpk'. Has it been tested with 'cglpk'?
I will begin testing my large numbers of optimisations using cglpk and hopefully will no longer encounter the hangs I was getting before.
Cheers,
Will.