Commit fab127ad authored by Theo Christiaanse's avatar Theo Christiaanse
Browse files

did the black

parent 5ed73135
Loading
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -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.

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