-
Hi! Is there a way to find a solution where some, or all, individual growth rates have the same value? |
Beta Was this translation helpful? Give feedback.
Answered by
cdiener
Sep 7, 2023
Replies: 1 comment 2 replies
-
Definitely possible but currently a bit clunky. Cooperative Tradeoff will push the solution towards that by default, especially if you choose a low tradeoff. But it is also possible to enforce the same growth rates directly by adding ratio constraints. Here is an example: import micom as mm
com = mm.Community(mm.data.test_taxonomy())
constraints = []
ref_taxon_objective = com.constraints["objective_" + com.taxa[0]].expression
for tax in com.taxa[1:]:
c = com.problem.Constraint(
com.constraints["objective_" + tax].expression - ref_taxon_objective,
name="ratio_" + tax,
lb=0, ub=0
)
constraints.append(c)
with com:
com.add_cons_vars(constraints)
sol = com.optimize() # maximizes community growth with the constraints applied
print(sol.members) Which will give:
So this is planned to be implemented as a helper function already. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
lhtxa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Definitely possible but currently a bit clunky. Cooperative Tradeoff will push the solution towards that by default, especially if you choose a low tradeoff. But it is also possible to enforce the same growth rates directly by adding ratio constraints. Here is an example: