Loading pyehub/pylp/problem.py +14 −9 Original line number Diff line number Diff line Loading @@ -10,12 +10,17 @@ from contexttimer import Timer from pylp.constraint import Constraint Status = namedtuple('Status', ['status', 'time']) Status = namedtuple("Status", ["status", "time"]) def solve(*, objective=None, constraints: Iterable[Constraint] = None, minimize: bool = False, solver: str = 'glpk', verbose: bool = False) -> Status: def solve( *, objective=None, constraints: Iterable[Constraint] = None, minimize: bool = False, solver: str = "glpk", verbose: bool = False, ) -> Status: """ Solve the linear programming problem. Loading Loading @@ -44,14 +49,14 @@ def solve(*, objective=None, constraints: Iterable[Constraint] = None, for constraint in constraints: problem += constraint.construct() if solver == 'glpk': if solver == "glpk": solver = pulp.solvers.GLPK(msg=verbose) elif solver == 'theo-cluster': solver = pulp.solvers.GLPK(msg=verbose, path='/home/theochri/ENV/bin/glpsol') elif solver == 'cplex': elif solver == "theo-cluster": solver = pulp.solvers.GLPK(msg=verbose, path="/home/theochri/ENV/bin/glpsol") elif solver == "cplex": solver = pulp.solvers.CPLEX(msg=verbose) else: raise ValueError(f'Unsupported solver: {solver}') raise ValueError(f"Unsupported solver: {solver}") with Timer() as time: results = problem.solve(solver) Loading Loading
pyehub/pylp/problem.py +14 −9 Original line number Diff line number Diff line Loading @@ -10,12 +10,17 @@ from contexttimer import Timer from pylp.constraint import Constraint Status = namedtuple('Status', ['status', 'time']) Status = namedtuple("Status", ["status", "time"]) def solve(*, objective=None, constraints: Iterable[Constraint] = None, minimize: bool = False, solver: str = 'glpk', verbose: bool = False) -> Status: def solve( *, objective=None, constraints: Iterable[Constraint] = None, minimize: bool = False, solver: str = "glpk", verbose: bool = False, ) -> Status: """ Solve the linear programming problem. Loading Loading @@ -44,14 +49,14 @@ def solve(*, objective=None, constraints: Iterable[Constraint] = None, for constraint in constraints: problem += constraint.construct() if solver == 'glpk': if solver == "glpk": solver = pulp.solvers.GLPK(msg=verbose) elif solver == 'theo-cluster': solver = pulp.solvers.GLPK(msg=verbose, path='/home/theochri/ENV/bin/glpsol') elif solver == 'cplex': elif solver == "theo-cluster": solver = pulp.solvers.GLPK(msg=verbose, path="/home/theochri/ENV/bin/glpsol") elif solver == "cplex": solver = pulp.solvers.CPLEX(msg=verbose) else: raise ValueError(f'Unsupported solver: {solver}') raise ValueError(f"Unsupported solver: {solver}") with Timer() as time: results = problem.solve(solver) Loading