diff --git a/src/config.py b/src/config.py index 74eb97348c30acf608080c7d6e2fe520976c237d..5543333d1a0f2422e3b9d75e313e85d2948a33bb 100644 --- a/src/config.py +++ b/src/config.py @@ -1,4 +1,4 @@ -# (c) Zizhe Wang +# Copyright (c) 2024 - Zizhe Wang # https://zizhe.wang ###################################### @@ -7,50 +7,40 @@ # # ###################################### -# Be sure to only edit your setups in global settings!!! -# Don't modify the code outside of it !!! - import os - -# Basic settings -MODEL_NAME = "SimpleHeatingSystem" -MODEL_FILE = f"{MODEL_NAME}.mo" +import json + +# Load configuration from JSON file +CONFIG_FILE = 'config.json' +with open(CONFIG_FILE, 'r') as f: + config = json.load(f) + +# Assign configuration variables +MODEL_NAME = config['MODEL_NAME'] +MODEL_FILE = config['MODEL_FILE'] +SIMULATION_STOP_TIME = config['SIMULATION_STOP_TIME'] +PARAMETERS = config['PARAMETERS'] +OBJECTIVES = config['OBJECTIVES'] +MAXIMIZE = config['MAXIMIZE'] +PARAM_BOUNDS = config['PARAM_BOUNDS'] +PRECISION = config['PRECISION'] +OPTIMIZATION_CONFIG = config['OPTIMIZATION_CONFIG'] +PLOT_CONFIG = config['PLOT_CONFIG'] +N_JOBS = config['N_JOBS'] + +# Derived configuration MODEL_PATH = os.path.join(os.getcwd(), MODEL_FILE) -SIMULATION_STOP_TIME = 3000 # in seconds - -# Parameters to be varied and objectives to be optimized -PARAMETERS = ["Q_max", "T_set"] -OBJECTIVES = ["energy", "comfort"] -MAXIMIZE = ["comfort"] # List of objectives to maximize - -# Parameter range -PARAM_BOUNDS = { - "Q_max": (1000, 5000), - "T_set": (280, 310), -} - -# Results precision -PRECISION = 2 # decimal places - -# Optimization settings -OPTIMIZATION_CONFIG = { - "ALGORITHM_NAME": 'NSGA2', # Algorithm selection - "POP_SIZE": 100, # Population size for algorithm - "N_GEN": 50 # Number of generations -} - -# Plot configurations -PLOT_CONFIG = { - "PLOT_X": "Energy Consumption", - "PLOT_Y": "Comfort", - "PLOT_TITLE": "Pareto Front of Energy Consumption vs Comfort" -} -# Parallel processing -N_JOBS = -1 # Options: '-1', '1', 'n', 'None' - # ==================================================================== - # -1 = use all available CPU cores - # 1 = disables parallel processing and runs the tasks sequentially - # n = specifies the exact number of CPU cores to use - # None = will run the tasks sequentially, equivalent to '1' - # ==================================================================== \ No newline at end of file +# "PARAMETERS": Parameters to be varied +# "OBJECTIVES": Objectives to be optimized +# "MAXIMIZE": Objectives to be maximized +# "PARAM_BOUNDS": Parameter range +# "PRECISION": Results precision (decimal places) +# "N_JOBS": Parallel processing +# Options: '-1', '1', 'n', 'None' +# ==================================================================== +# -1 = use all available CPU cores +# 1 = disables parallel processing and runs the tasks sequentially +# n = specifies the exact number of CPU cores to use +# None = will run the tasks sequentially, equivalent to '1' +# ==================================================================== \ No newline at end of file