Skip to content

Commit

Permalink
updated glpk
Browse files Browse the repository at this point in the history
  • Loading branch information
VonAlphaBisZulu committed Sep 21, 2022
1 parent 4ab12c1 commit 487f973
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion straindesign/glpk_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@ def __init__(self, c, A_ineq, b_ineq, A_eq, b_eq, lb, ub, vtype, indic_constr, M
glp_load_matrix(self.glpk, A.nnz, ia, ja, ar)

# not sure if the parameter setup is okay
# LP simplex parameters
self.lp_params = glp_smcp()
glp_init_smcp(self.lp_params)
self.max_tlim = self.lp_params.tm_lim
self.lp_params.tol_bnd = 1e-9
self.lp_params.msg_lev = 0
# MILP parameters
if self.ismilp:
self.milp_params = glp_iocp()
glp_init_iocp(self.milp_params)
Expand Down Expand Up @@ -489,8 +491,10 @@ def solve_MILP_LP(self) -> Tuple[float, int, bool]:
# with prior resolve.
if prelim_status == GLP_EFAIL:
self.lp_params.presolve = 1
glp_simplex(self.glpk, self.lp_params)
self.lp_params.meth = 3
prelim_status = glp_simplex(self.glpk, self.lp_params)
self.lp_params.presolve = 0
self.lp_params.meth = 1
status = glp_get_status(self.glpk)
if self.ismilp and status not in [GLP_INFEAS, GLP_NOFEAS]:
glp_intopt(self.glpk, self.milp_params)
Expand Down
9 changes: 6 additions & 3 deletions straindesign/lptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,12 @@ def plot_flux_space(model, axes, **kwargs) -> Tuple[list, list, list]:
for i in range(len(x_space) - 1):
temp_points = [datapoints_bottom[i], datapoints_top[i], datapoints_bottom[i + 1], datapoints_top[i + 1]]
pts = [array(datapoints[idx_p]) for idx_p in temp_points]
if matrix_rank(pts - pts[0]) > 1:
triang_temp = Delaunay(pts).simplices
triang += [[temp_points[idx] for idx in p] for p in triang_temp]
try:
if matrix_rank(pts - pts[0]) > 1:
triang_temp = Delaunay(pts).simplices
triang += [[temp_points[idx] for idx in p] for p in triang_temp]
except:
logging.warning('Computing matrix rank or Delaunay simplices failed.')
# Plot
x = [v for v in x_space] + [v for v in reversed(x_space)]
y = [v for v in lb] + [v for v in reversed(ub)]
Expand Down

0 comments on commit 487f973

Please sign in to comment.