opencobra / driven

Data-Driven Constraint-based analysis
http://biosustain.github.io/driven/
Apache License 2.0
12 stars 9 forks source link

Solver status turning infeasible when trying to optimize #24

Open BrunoMiguelPereira opened 4 years ago

BrunoMiguelPereira commented 4 years ago

I am trying to integrate both transcriptomic and metabolomic data into an E.coli model (Escherichia coli str. K-12 substr. MG1655, model iML1515). However, when using gim3e function, the solver becomes infeasible after the first slim_optimize, the one to obtain the penalty_bound_constraint.

I have changed the solver to cplex and the error that i get is: cplex.exceptions.errors.CplexSolverError: CPLEX Error 1225: Numeric entry is not a double precision number (NaN).

This error comes from this line (144 if not mistaken):

model.objective = objective

However the origin of the error comes from:

# Penalty bound constraint
    penalty_obj = model.slim_optimize()

When trying to optimize the model after resetting the objective function, the solver status changes to infeasible, making variable penalty_obj equal to nan and so the constraint that is built after gets this value as an upper_bound.

My inputs are the ones requested: 1) a cobra model; 2) an expression profile obtained from the class ExpressionProfile with the model gene names as lines and conditions as columns; 3) a dictionary of medium metabolites. Metabolites names' matches the ones in the model.

I have already tried a less complex model, expression profile and fewer metabolites.

I uploaded a zip with 3 files:

Notes: Cplex solver was used but if the attempt to reproduce is done with glpk the infeasible error still happens. The python version was 3.8.5.

integrating_omics.zip

Midnighter commented 4 years ago

Thank you for the detailed description. I will take a look at the zip that you provided. In general, nobody has worked on driven in a while so I wouldn't necessarily expect it to work out of the box.

BrunoMiguelPereira commented 4 years ago

No problem, thank you for taking my problem into account. I know this probably does not make much sense but if the original metabolites are removed from the model (via _removemetabolites()) and only the "TM_" ones remain, the solver is able to find a solution.

robertobarg commented 1 year ago

I've a similar issue coding a branch-and-price algorithm. On model modification the exception 1225 is thrown, but changing some coefficients of the objective function creating the model avoid the error. Unfortunately I need other values for that coefficients in the objective function. So, it should not be a bug in my code. I do not find any solution in the Cplex documentation.

I've asked a question with more details on stackoverflow: https://stackoverflow.com/questions/76627803/prevent-cplex-setting-to-nan-coefficients-of-problem-variables-exception-1225-i