reframed icon indicating copy to clipboard operation
reframed copied to clipboard

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

Open yaccos opened this issue 3 years ago • 3 comments

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.

yaccos avatar Mar 31 '22 10:03 yaccos

@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!

ccshao avatar Mar 31 '22 14:03 ccshao

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-

yaccos avatar Mar 31 '22 15:03 yaccos

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.

ccshao avatar Apr 01 '22 13:04 ccshao