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

Cannot deepcopy models with gurobipy with BiGG id st #1072

Open
sirno opened this issue Apr 4, 2021 · 3 comments
Open

Cannot deepcopy models with gurobipy with BiGG id st #1072

sirno opened this issue Apr 4, 2021 · 3 comments

Comments

@sirno
Copy link

sirno commented Apr 4, 2021

For some models it is not possible to apply deepcopy, because the reaction names may match reserved names of the gurobi LP format—see gurobi docs:

Also, variable names should not be equal (case insensitive) to any of the LP file format keywords, e.g., st, bounds, min, max, binary, or end. Names must be preceded and followed by whitespace.

This happens with sulfur diffusion, see bigg reaction 🤷‍♀️

Although this problem is related to the way optlang sets the state in its gurobi interface, I suppose this is still a cobrapy issue... sort of

/path/python-3.9.1/lib/python3.9/site-packages/optlang/gurobi_interface.py in __setstate__(self, repr_dict) 
    598     def __setstate__(self, repr_dict): 
    599         with TemporaryFilename(suffix=".lp", content=repr_dict["lp"]) as tmp_file_name:
--> 600             problem = gurobipy.read(tmp_file_name)
@cdiener
Copy link
Member

cdiener commented Apr 4, 2021

Yes that is definitely not perfect. I would say it's more a limitation with gurobipy though since they don't provide native serialization like cplex for example: https://groups.google.com/g/gurobi/c/fwLRrWLLJqo. Adjusting the ids in the state setter and getter would work but that would have to be done in optlang.

@Midnighter
Copy link
Member

This would be another place where it'd be great to maintain the SBML IDs and use those since the R_ and M_ prefixes commonly used would avoid this problem and still allow for easy manual inspection of the LP format.

@sirno
Copy link
Author

sirno commented Apr 4, 2021

Yes indeed, I suppose one can manually turn of the replacement of those prefixes with f_replace=None when loading SBML files.

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

3 participants