Remove Optlang object from COBRApy model

21 views
Skip to first unread message

Nicholas Y

unread,
Nov 22, 2025, 2:31:10 PM (12 days ago) Nov 22
to cobra pie
Hi,

My name is Nick, and I have a question regarding the COBRApy Python package. 

I understand that COBRApy models contain an optlang object within them. I was wondering if it is possible to remove this optlang object from COBRApy models, or to create models without the optlang object. 

The reason for this is I would like to be able to represent a very large genome scale model in COBRApy, and I want to be able to pickle this model for fast save/reload. However, because COBRApy models contain optlang objects, I am running into issues loading the model from a pickle file. Is it possible to remove an optlang object from a COBRApy model and if so, how do I do it? Thanks!

Best regards,
Nick Yousefi

Matthias König

unread,
Nov 24, 2025, 2:57:34 AM (10 days ago) Nov 24
to cobra pie
Hi Nick,
if your problem is the serialization you should try the dill library
https://github.com/uqfoundation/dill
It can handle many uses cases pickle struggles with.
Best Matthias

Nicholas Y

unread,
Nov 26, 2025, 9:35:02 AM (8 days ago) Nov 26
to cobra pie
Hi Matthias,

Thank you for your suggestion. I will try it and see if it works.

I still do want to confirm, though, whether there is an official way to remove the optlang solver from COBRApy models. Ideally, I would still like to remove it if possible. If this is not possible with COBRApy's current design, that is fine, but I would appreciate if you could please confirm if that is the case.

If there is no official way to remove the optlang object, I am considering using a fork of COBRApy in which I modify the code to remove the optlang object. I was wondering if this would be feasible and if you could provide any insights as to what parts of the code I would need to change to achieve this.

Thank you very much for your assistance. It is much appreciated.

Best regards,
Nick Yousefi
Reply all
Reply to author
Forward
0 new messages