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

[Feature] Handle reaction removal in the objective #1396

Open
1 task done
cdiener opened this issue Jul 5, 2024 · 0 comments
Open
1 task done

[Feature] Handle reaction removal in the objective #1396

cdiener opened this issue Jul 5, 2024 · 0 comments

Comments

@cdiener
Copy link
Member

cdiener commented Jul 5, 2024

Checklist

Problem

Right now removing reactions from a model will still reatin in them in the objective even when using remove_orphans=True. They are kind of handled correctly there because they appear as diconnected variables, meaning they are fixed to zero.

In [2]: from cobra.io import load_model

In [3]: mod = load_model("textbook")

In [4]: mod.objective
Out[4]: <optlang.cplex_interface.Objective at 0x7fb641a6d790>

In [5]: mod.objective.expression
Out[5]: 1.0*Biomass_Ecoli_core - 1.0*Biomass_Ecoli_core_reverse_2cdba

In [6]: mod.remove_reactions([mod.reactions.Biomass_Ecoli_core], True)

In [7]: mod.objective.expression
Out[7]: 1.0*Biomass_Ecoli_core - 1.0*Biomass_Ecoli_core_reverse_2cdba

In [8]: mod.optimize()
Out[8]: <Solution 0.000 at 0x7fb641a74590>

But it is still a bit confusing to have removed reactions appear there.

Solution

I don't have a definitive solution. It is challenging because the objective can be arbitrary non-linear functions so it is not trivial to correctly remove terms. Removing individual reactions in theory also breaks the scaling to 1gDW.

Alternatives

Other approaches:

  • leave it as is and document the behavior
  • don't touch the objective but raise a warning
  • remove the objective if any included variables are removed, forcing the user to set a new objective by hand

Anything else?

Happy to hear the thoughts of the community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant