-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Labels
Description
Thanks for making this package available. As someone using LP in another research domain (Metabolic Engineering), I was very excited to try it out.
The LP problem I am working on can be formulated using the code below (you would need to pip install cobra for easy access to a 'metabolic model', but it is just a wrapper that connects biology to LP. However, I cannot solve this problem in MPAX for a long time, even though GLPK can solve it within seconds. I wonder if you have any thoughts on this. Appreciate your help!
import jax
import cobra # need to pip install
from cobra.io import load_model
import numpy as np
from mpax import create_lp, create_qp, raPDHG, r2HPDHG
jax.config.update("jax_enable_x64", True)
# Load the LP information from a metabolic model
model = load_model("ijo1366")
S = cobra.util.create_stoichiometric_matrix(model)
c = np.array([r.objective_coefficient for r in model.reactions]) # Objective vector
lb = np.array([r.lower_bound for r in model.reactions])
ub = np.array([r.upper_bound for r in model.reactions])
model.optimize() # this is calling glpk, which is very fast to solve.
# convert to mpax format
c = -c
A = S
b = np.zeros(A.shape[0])
G = np.zeros((0, A.shape[1])) # no inequality constrants
h = np.zeros((0,)) # no inequality constrants
l = lb
u = ub
lp = create_lp(c, A, b, G, h, l, u, use_sparse_matrix=True)
solver = r2HPDHG(eps_abs=1e-4, eps_rel=1e-4, verbose=True)
result = solver.optimize(lp)