Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the version requirement for swiglpk? #39

Open
jonrkarr opened this issue Aug 17, 2021 · 2 comments
Open

What is the version requirement for swiglpk? #39

jonrkarr opened this issue Aug 17, 2021 · 2 comments
Assignees
Milestone

Comments

@jonrkarr
Copy link
Contributor

I see errors with cbmpy.CBGLPK.glpk_FluxVariabilityAnalysis in 0.8.1 and swiglpk 4.65.1, 5.0.0, and 5.0.3 from PyPI. Is a newer version of swiglpk needed?

>       solution = cbmpy.CBGLPK.glpk_FluxVariabilityAnalysis(model)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../.local/lib/python3.9/site-packages/cbmpy/CBGLPK.py:677: in glpk_FluxVariabilityAnalysis
    glpk_func_SetObjectiveFunctionAsConstraint(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cpx = <Swig Object of type 'glp_prob *' at 0x7f3a5dc5d060>, rhs_sense = 'lower', oval = 0.8739215069684909, tol = None, optPercentage = 100.0

    def glpk_func_SetObjectiveFunctionAsConstraint(
        cpx, rhs_sense, oval, tol, optPercentage
    ):
        """
        Take the objective function and "optimum" value and add it as a constraint
         - *cpx* a cplex object
         - *oval* the objective value
         - *tol*  [default=None] do not floor/ceiling the objective function constraint, otherwise round of to *tol*
         - *rhs_sense* [default='lower'] means objC >= objVal the inequality to use for the objective constraint can also be *upper* or *equal*
         - *optPercentage* [default=100.0] means the percentage optimal value to use for the RHS of the objective constraint: optimal_value*(optPercentage/100.0)
    
        """
    
        # generate new constraint from old objective value (use non-zero coefficients)
        LCS = []
        LCN = []
        new_constraint = []
>       for v_ in range(len(cpx.cols)):
E       AttributeError: 'SwigPyObject' object has no attribute 'cols'

../../.local/lib/python3.9/site-packages/cbmpy/CBGLPK.py:943: AttributeError
@jonrkarr
Copy link
Contributor Author

Below are steps to repeat the error:

Run a Docker image

docker run -it --rm --entrypoint bash python:3.9-slim-buster

In the Docker image

# get example model
apt-get update -y
apt-get install -y wget
wget https://raw.githubusercontent.com/biosimulators/Biosimulators_CBMPy/dev/tests/fixtures/textbook.xml

# install cbmpy
pip install cbmpy swiglpk sympy python_libsbml lxml

# launch python
python

In the python shell:

import cbmpy
import cbmpy.CBGLPK
model_filename = 'textbook.xml'
model = cbmpy.CBRead.readSBML3FBC(model_filename)
solution = cbmpy.CBGLPK.glpk_FluxVariabilityAnalysis(model)

This terminates with this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/cbmpy/CBGLPK.py", line 677, in glpk_FluxVariabilityAnalysis
    glpk_func_SetObjectiveFunctionAsConstraint(
  File "/usr/local/lib/python3.9/site-packages/cbmpy/CBGLPK.py", line 943, in glpk_func_SetObjectiveFunctionAsConstraint
    for v_ in range(len(cpx.cols)):
AttributeError: 'SwigPyObject' object has no attribute 'cols'

@bgoli
Copy link
Member

bgoli commented Sep 19, 2021

The pyGLPK version that is currently used is not available for Python 3 so CPLEX is is required ... I am working on a new wrapper that will use the swiglpk used by cobrapy which should resolve all compatibility issues.

@bgoli bgoli self-assigned this Sep 19, 2021
@bgoli bgoli modified the milestones: Release 0.8.1, Release 0.8.2 Sep 19, 2021
@bgoli bgoli modified the milestones: Release 0.8.3, Release 0.8.5 Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants