Skip to content

SteadyCom doesn't works with Gurobi #35

@ggmirandac

Description

@ggmirandac

Hello,

I am working with reframed to model microbial communities, but the steadycom function doesn't works with the Gurobi solver.
Specifically, when the Gurobi solver is used, the following error is obtained:

AttributeError                            Traceback (most recent call last)
Cell In[16], [line 5](vscode-notebook-cell:?execution_count=16&line=5)
      1 comunidad = Community('arg_met', [darg, dlys])
      3 M9 = Environment.from_model(model)
----> [5](vscode-notebook-cell:?execution_count=16&line=5) solution = SteadyCom(comunidad, constraints=M9)

File /opt/homebrew/Caskroom/miniconda/base/envs/SaaLab/lib/python3.12/site-packages/reframed/community/SteadyCom.py:26, in SteadyCom(community, constraints, solver)
     22     solver = build_problem(community)
     24 objective = {community.merged_model.biomass_reaction: 1}
---> [26](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniconda/base/envs/SaaLab/lib/python3.12/site-packages/reframed/community/SteadyCom.py:26) sol = binary_search(solver, objective, minimize=False, constraints=constraints)
     28 solution = CommunitySolution(community, sol.values)
     29 solution.solver = solver

File /opt/homebrew/Caskroom/miniconda/base/envs/SaaLab/lib/python3.12/site-packages/reframed/community/SteadyCom.py:156, in binary_search(solver, objective, obj_frac, minimize, max_iters, abs_tol, constraints)
    153         fold = 0.5
    154     value = fold*diff + previous_value
--> [156](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniconda/base/envs/SaaLab/lib/python3.12/site-packages/reframed/community/SteadyCom.py:156) solver.update_growth(value)
    157 sol = solver.solve(objective, get_values=False, minimize=minimize, constraints=constraints)
    159 feasible = sol.status == Status.OPTIMAL

File /opt/homebrew/Caskroom/miniconda/base/envs/SaaLab/lib/python3.12/site-packages/reframed/community/SteadyCom.py:126, in build_problem.<locals>.update_growth(value)
    123 def update_growth(value):
    124     # TODO: find a solution that is not CPLEX specific
    125     coefficients = [(f"g_{x}", f"x_{x}", value) for x in community.organisms]
...
File src/gurobipy/_model.pyx:2105, in gurobipy._model.Model.getAttr()

File src/gurobipy/_attrutil.pyx:40, in gurobipy._attrutil._getattrinfo()

AttributeError: 'gurobipy.Model' object has no attribute 'linear_constraints'

The specific error that I found comes from AttributeError: 'gurobipy.Model' object has no attribute 'linear_constraints' which stems from the solver defined with Gurobi.

Bests,
Gabriel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions