Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions linopy/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ def __init__(
):
self.solver_options = solver_options

# Check for the solver to be initialized whether the package is installed or not.
if self.solver_name.value not in available_solvers:
msg = f"Solver package for '{self.solver_name.value}' is not installed. Please install first to initialize solver instance."
raise ImportError(msg)

def safe_get_solution(self, status: Status, func: Callable) -> Solution:
"""
Get solution from function call, if status is unknown still try to run it.
Expand Down Expand Up @@ -301,6 +306,10 @@ def solve_problem(
msg = "No problem file or model specified."
raise ValueError(msg)

@property
def solver_name(self) -> SolverName:
return SolverName[self.__class__.__name__]


class CBC(Solver):
"""
Expand Down