cdanielmachado / reframed

ReFramed: metabolic modeling package
Other
57 stars 15 forks source link

Having class `Status` in top-level API would be useful #8

Open yaccos opened 2 years ago

yaccos commented 2 years ago

When I work with solutions generated by reframed, I often have to look into the optimization status. This becomes a little tricky when the status enumeration is hidden deep into the API. Here is an example:

solution = reframed.FBA(model)
if solution.status == reframed.solvers.solution.Status.OPTIMAL:
    print("Problem solved sucessfully"
else:
    print("Something went wrong solving the model")

Instead of writing reframed.solvers.solution.Status.OPTIMAL I would think it would be sufficient to access it with reframed.Status.OPTIMAL.

ccshao commented 2 years ago

@yaccos May I ask a rather silly question about solver. How could I make the reframed to the gurobi solver which I have installed and tested?

I have tried the set_default_solver, but it didn't work. However, I have the /gurobi951/linux64/bin in the path. I am using v1.2.1.

from reframed import *
set_default_solver("gurobi")

RuntimeError: Solver gurobi not available.

Thanks!

yaccos commented 2 years ago

Have you tried interfacing directly with gurobipy? Try running

from gurobipy import Model
Model()

and see whether you get any error messages. If you get an ImportError, please follow these instructions: https://support.gurobi.com/hc/en-us/articles/360044290292-How-do-I-install-Gurobi-for-Python-

ccshao commented 2 years ago

Thanks for the quick updates! I guess you mean from gurobipy import Model? Yes, grobipy worked.

I just relealized I installed reframed via pip install gurobipy, which gives the latest version of 1.2.1. However, the master branch is ahead of the released version.

After uninsalling old released version and installing the current master, test examples worked smoothly without need of any further configurations. I hope not to run into othe configuration issures in the future.