Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix solver test bug #398

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 2 additions & 1 deletion 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
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()
Loading