Skip to content
Open
Show file tree
Hide file tree
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
21 changes: 21 additions & 0 deletions API/Classes/Base/Config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
import os
import shutil
#from dotenv import load_dotenv
import platform

Expand Down Expand Up @@ -27,6 +28,26 @@
EXTRACT_FOLDER = Path("")
SOLVERs_FOLDER = Path('WebAPP', 'SOLVERs')

# --- Solver path resolution ---
# Priority: 1) env var override 2) OS-specific default
_glpk_env = os.environ.get("MUIO_GLPK_PATH")
_cbc_env = os.environ.get("MUIO_CBC_PATH")

if _glpk_env:
GLPK_PATH = Path(_glpk_env)
elif SYSTEM == "Windows":
GLPK_PATH = Path(SOLVERs_FOLDER, 'GLPK')
else:
_glpk_bin = shutil.which("glpsol")
GLPK_PATH = Path(_glpk_bin).parent if _glpk_bin else None

if _cbc_env:
CBC_PATH = Path(_cbc_env)
elif SYSTEM == "Windows":
CBC_PATH = Path(SOLVERs_FOLDER, 'COIN-OR')
else:
_cbc_bin = shutil.which("cbc")
CBC_PATH = Path(_cbc_bin).parent if _cbc_bin else None

#absolute paths
# OSEMOSYS_ROOT = os.path.abspath(os.getcwd())
Expand Down
26 changes: 11 additions & 15 deletions API/Classes/Case/OsemosysClass.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
import platform
from Classes.Base import Config
from Classes.Base.FileClass import File

Expand Down Expand Up @@ -45,20 +44,17 @@ def __init__(self, case):
self.osemosysFile = Path(Config.SOLVERs_FOLDER,'model.v.5.4.txt')
self.osemosysFileOriginal = Path(Config.SOLVERs_FOLDER,'osemosys.txt')

if platform.system() == 'Windows':
#self.glpkFolder = Path(Config.SOLVERs_FOLDER, 'GLPK','glpk-4.65', 'w64')
# self.cbcFolder = Path(Config.SOLVERs_FOLDER,'COIN-OR', 'Cbc-2.7.5-win64-intel11.1', 'bin')
self.glpkFolder = Path(Config.SOLVERs_FOLDER, 'GLPK')
self.cbcFolder = Path(Config.SOLVERs_FOLDER,'COIN-OR')

#self.cbcFolder = Path(Config.SOLVERs_FOLDER,'COIN-OR', 'Cbc-2.10-win64-msvc16-md', 'bin')

#Cbc-master-win64-msvc16-mt
#self.cbcFolder = Path(Config.SOLVERs_FOLDER,'COIN-OR', 'Cbc-master-win64-msvc16-md', 'bin')

else:
self.glpkFolder = Path(Config.SOLVERs_FOLDER, 'GLPK','glpk-4.65', 'w64')
self.cbcFolder = Path(Config.SOLVERs_FOLDER,'COIN-OR', 'Cbc-2.10-osx10.15-x86_64-gcc9', 'bin')
self.glpkFolder = Config.GLPK_PATH
self.cbcFolder = Config.CBC_PATH

if not self.glpkFolder:
raise RuntimeError(
"GLPK solver not found. Install glpk or set MUIO_GLPK_PATH."
)
if not self.cbcFolder:
raise RuntimeError(
"CBC solver not found. Install cbc or set MUIO_CBC_PATH."
)

self.resultsPath = Path(Config.DATA_STORAGE,case,'res')
self.viewFolderPath = Path(Config.DATA_STORAGE,case,'view')
Expand Down
Binary file modified requirements.txt
Binary file not shown.