Skip to content

Commit

Permalink
"Changed structure to full_model_flow tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
masseramatteo committed Jan 10, 2025
1 parent 0cbf4be commit d7b2d1e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
5 changes: 3 additions & 2 deletions adopt_net0/modelhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def read_data(
log.info(log_msg)
self.data.set_settings(data_path, start_period, end_period)
self.data.read_data()
self._perform_preprocessing_checks()

log_msg = "--- Reading in data complete ---"
log.info(log_msg)
Expand Down Expand Up @@ -231,6 +230,8 @@ def construct_model(self):
log.info(log_msg)
start = time.time()

self._perform_preprocessing_checks()

# Determine aggregation
config = self.data.model_config

Expand Down Expand Up @@ -473,7 +474,7 @@ def add_technology(self, investment_period: str, node: str, technologies: list):
}
for technology in technologies:
# read in technology data
tec_data = read_tec_data(
tec_data = create_technology_class(
technology,
self.data.data_path
/ investment_period
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def pytest_configure(config):
config.docu_notebook_folder_path = Path("tests")
config.docu_notebook_data_path = Path("tests/notebook_data")
config.root_folder_path = Path(".")
config.solver = "glpk"
config.solver = "gurobi"


@pytest.fixture(autouse=True)
Expand Down
35 changes: 23 additions & 12 deletions tests/test_full_model_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def test_full_model_flow(request):

pyhub = ModelHub()
pyhub.read_data(path, start_period=0, end_period=1)
pyhub.construct_model()
pyhub.construct_balances()
pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver
pyhub.data.model_config["reporting"]["save_summary_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path
pyhub.construct_model()
pyhub.construct_balances()
pyhub.solve()

m = pyhub.model["full"]
Expand Down Expand Up @@ -105,15 +105,16 @@ def test_clustering_algo(request):

pyhub = ModelHub()
pyhub.read_data(path, start_period=0, end_period=2 * 24)
pyhub.construct_model()
pyhub.construct_balances()
pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver
pyhub.data.model_config["reporting"]["save_summary_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path

pyhub.construct_model()
pyhub.construct_balances()
pyhub.solve()

m = pyhub.model["full"]
Expand All @@ -131,6 +132,7 @@ def test_clustering_algo(request):
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver
for method in methods:
for n in N:
pyhub.data.model_config["optimization"]["typicaldays"]["N"]["value"] = n
Expand Down Expand Up @@ -174,15 +176,16 @@ def test_average_algo(request):

pyhub = ModelHub()
pyhub.read_data(path, start_period=0, end_period=2 * 24)
pyhub.construct_model()
pyhub.construct_balances()
pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver
pyhub.data.model_config["reporting"]["save_summary_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path

pyhub.construct_model()
pyhub.construct_balances()
pyhub.solve()

m = pyhub.model["full"]
Expand All @@ -200,6 +203,7 @@ def test_average_algo(request):
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver

pyhub.data._read_time_series()
pyhub.data._read_node_locations()
Expand Down Expand Up @@ -236,20 +240,23 @@ def test_objective_functions(request):

pyhub = ModelHub()
pyhub.read_data(path, start_period=0, end_period=1)
pyhub.construct_model()
pyhub.construct_balances()

pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver
pyhub.data.model_config["reporting"]["save_summary_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path

pyhub.construct_model()
pyhub.construct_balances()
pyhub._define_solver_settings()

pyhub._optimize_emissions_net()
pyhub._optimize_costs_minE()
pyhub._optimize_costs_emissionslimit()

pyhub._solve_pareto()


Expand All @@ -266,15 +273,16 @@ def test_monte_carlo(request):
# Monte Carlo type normal
pyhub.data.model_config["optimization"]["monte_carlo"]["N"]["value"] = 2

pyhub.construct_model()
pyhub.construct_balances()
pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver
pyhub.data.model_config["reporting"]["save_summary_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path

pyhub.construct_model()
pyhub.construct_balances()
pyhub.solve()

termination = pyhub.solution.solver.termination_condition
Expand All @@ -300,13 +308,16 @@ def test_scaling(request):

pyhub = ModelHub()
pyhub.read_data(path, start_period=0, end_period=1)
pyhub.construct_model()
pyhub.construct_balances()

pyhub.data.model_config["scaling"]["scaling_on"]["value"] = 1
pyhub.data.model_config["reporting"]["save_summary_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["reporting"]["save_path"][
"value"
] = request.config.result_folder_path
pyhub.data.model_config["solveroptions"]["solver"]["value"] = request.config.solver

pyhub.construct_model()
pyhub.construct_balances()
pyhub.solve()

0 comments on commit d7b2d1e

Please sign in to comment.