micom-dev / micom

Python package to study microbial communities using metabolic modeling.
https://micom-dev.github.io/micom
Apache License 2.0
82 stars 17 forks source link

Why does problems.solve() return None when status is not optimal? #1

Closed mmundy42 closed 3 years ago

mmundy42 commented 6 years ago

Just curious since there is additional information about what did not work in the cobrapy Solution object that could be returned. Or does it just not make sense to return a CommunitySolution object when the optimization did not work? I'm most interested in knowing what the solver status is.

cdiener commented 6 years ago

Mostly because it can not run pFBA because there is no defined optimum and CommunitySolution also will choke if there are no optimal growth rates. Maybe would be better to raise an exception? Access to the solver object is still possible via Community.solver, for example community.solver.status will get you the optimization status. In my experience this usually fails if you define a minimum growth rate for one of the organisms that can not be achieved (in Community.optcom this defaults to 0.1 which I think I should change). For instance calling com.optcom(min_growth=0.0) usually fixes those problems...

mmundy42 commented 6 years ago

That makes sense. I found what I was looking for in community.solver.status.

Maybe you could add a raise_error parameter and raise an OptimizationError when parameter is set to True.

cdiener commented 6 years ago

Yeah that makes sense. Will reopen so I don't forget to make the changes...

cdiener commented 3 years ago

Managed internally now by the workflows.