A constraint-based reconstruction and analysis model for biological systems is actually just an application of a class of discrete optimization problems typically solved with linear, mixed integer or quadratic programming techniques. Cobrapy does not implement any algorithm to find solutions to such problems but rather creates a biologically motivated abstraction to these techniques to make it easier to think of how metabolic systems work without paying much attention to how that formulates to an optimization problem.
When you have defined your model, you can switch solver backend by simply assigning to the
import cobra.test model = cobra.test.create_test_model('textbook')
model.solver = 'glpk' # or if you have cplex installed model.solver = 'cplex'
For information on how to configure and tune the solver, please see the documentation for optlang project and note that
model.solver is simply an optlang object of class
12.1. Internal solver interfaces¶
Cobrapy also contains its own solver interfaces but these are now deprecated and will be removed completely in the near future. For documentation of how to use these, please refer to older documentation.