IN-CORE / pyincore

pyIncore is a component of IN-CORE. It is a python package consisting of two primary components: 1) a set of service classes to interact with the IN-CORE web services, and 2) IN-CORE analyses . The pyIncore allows users to apply various hazards to infrastructure in selected areas, propagating the effect of physical infrastructure damage and loss of functionality to social and economic impacts.
Mozilla Public License 2.0
25 stars 7 forks source link

[Bug] Joplin CGE makes an error by not finding the correct solver path on Windows #444

Open ywkim312 opened 11 months ago

ywkim312 commented 11 months ago

When running the Joplin testbed notebook in the incore-docs, windows makes a following error due to not finding ipopt solver path correctly.

The error cell in notebook is

joplin_cge.run_analysis()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[93], line 2
      1 # Run Joplin CGE model analysis
----> 2 joplin_cge.run_analysis()

File ~\.conda\envs\pyincore\lib\site-packages\pyincore\baseanalysis.py:400, in BaseAnalysis.run_analysis(self)
    397         print("Error reading parameter: " + result[1])
    398         return result
--> 400 return self.run()

File ~\.conda\envs\pyincore\lib\site-packages\pyincore\analyses\joplincge\joplincge.py:1757, in JoplinCGEModel.run(self)
   1755 tmp = "tmp.py"
   1756 print("Calibration: ")
-> 1757 run_solver(filename, tmp)
   1759 '''
   1760 Simulation code below:
   1761 In each simulation:
   (...)
   1766 
   1767 '''
   1769 iNum = self.get_parameter("model_iterations")  # dynamic model iterations

File ~\.conda\envs\pyincore\lib\site-packages\pyincore\analyses\joplincge\joplincge.py:1672, in JoplinCGEModel.run.<locals>.run_solver(cons_filename, temp_file_name)
   1668 keepfiles = False  # True prints intermediate file names (.nl,.sol,...)
   1670 executable_path = self.get_parameter("solver_path") \
   1671     if self.get_parameter("solver_path") is not None else pyglobals.IPOPT_PATH
-> 1672 if not os.path.exists(executable_path):
   1673     print("Invalid executable path, please make sure you have Pyomo installed.")
   1675 opt = SolverFactory(solver, solver_io=solver_io, executable=executable_path)

File ~\.conda\envs\pyincore\lib\genericpath.py:19, in exists(path)
     17 """Test whether a path exists.  Returns False for broken symbolic links"""
     18 try:
---> 19     os.stat(path)
     20 except (OSError, ValueError):
     21     return False

TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
navarroc commented 11 months ago

This is not an IN-CORE issue, but a problem with ipopt not able to build solvers for windows after version 3.11.2. See https://github.com/conda-forge/ipopt-feedstock/issues/55

One resolution is to download ipopt from here for windows:

https://github.com/coin-or/Ipopt/releases