Skip to content

Commit

Permalink
added check if solver was installed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophGehbauer committed Oct 16, 2023
1 parent 8ca4733 commit b3da041
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions doper/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ def get_solver(solver, solver_dir=os.path.join(get_root(), 'solvers')):
if system == 'Windows':
return os.path.join(solver_dir, 'Windows'+bit, solver+'.exe')
return os.path.join(solver_dir, 'Linux'+bit, solver)

def check_solver(solver='cbc'):
sol = get_solver(solver)
if not os.path.exists(sol):
logging.warning(f'The default "cbc" solver was not properly installed at "{sol}". ' \
+ 'Need to manually set the "solver_path" and "solver_name" ' \
+ 'when calling DOPER')

def extract_properties(parameter, tech_name, prop_name, set_list=None):
'''
Expand Down
7 changes: 6 additions & 1 deletion doper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
import pandas as pd
import pyutilib.subprocess.GlobalData

from .utility import fix_bug_pyomo, check_solver, pyomo_read_parameter

# Fix bug in pyomo when intializing solver (timeout after 5s)
from .utility import fix_bug_pyomo, pyomo_read_parameter
fix_bug_pyomo()

# Check if solver was properly installed
check_solver()

from pyomo.opt import SolverFactory, TerminationCondition
from .models.basemodel import default_output_list, generate_summary_metrics

Expand Down

0 comments on commit b3da041

Please sign in to comment.