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

improved solver path

parent 06bded39
Loading
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class EHubModel:
        if not self._compiled:
            self.compile()

        try:
        # try:
            # Use of the solver path is optional, however,
            # needed when doing cluster submission.
        solver_path = solver_settings["solver_path"]
@@ -112,15 +112,15 @@ class EHubModel:
                            minimize=True,
                            solver=solver,
                            verbose=is_verbose,
                                solver_path=solver_path,
                                options=options)
        except:
            print("did not set path or options")
            status = pylp.solve(objective=self.objective,
                                constraints=self.constraints,
                                minimize=True,
                                solver=solver,
                                verbose=is_verbose)
                            options=options,
                            solver_path=solver_path,)
        # except:
        #     print("did not set path or options")
        #     status = pylp.solve(objective=self.objective,
        #                         constraints=self.constraints,
        #                         minimize=True,
        #                         solver=solver,
        #                         verbose=is_verbose)


        attributes = self._public_attributes()
+7 −6
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ def solve(
    solver: str = "glpk",
    verbose: bool = False,
    options: list = None,
    solver_path: str = None,
    **kwargs,
) -> Status:
    """
@@ -65,16 +66,16 @@ def solve(
            problem += constraint.construct()

    if solver == "glpk":
        try:
            solver = pulp.solvers.GLPK(msg=verbose, path=kwargs['solver_path'], options=options)
        except:
        if solver_path==None:
            solver = pulp.solvers.GLPK(msg=verbose, path=solver_path, options=options)
        else:
            print("solver_path is not set, going to default, without options")
            # This catches the error if glpk_path is not set
            solver = pulp.solvers.GLPK(msg=verbose)
    elif solver == "glpk-cluster":
        try:
            solver = pulp.solvers.GLPK(msg=verbose, path=kwargs['solver_path'], options=options)
        except:
        if solver_path==None:
            solver = pulp.solvers.GLPK(msg=verbose, path=solver_path, options=options)
        else:
            print("solver_path is not set, going to default.")
            # This catches the error if glpk_path is not set
            solver = pulp.solvers.GLPK(msg=verbose, path="/home/theochri/ENV/bin/glpsol")