Skip to content

Commit

Permalink
Add timelimit
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-tomasini committed Dec 10, 2024
1 parent 5fe13cd commit a434660
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 4 additions & 3 deletions scripts/baseline_optimizazion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
TURBINE_FACTORS = {0.75, 0.90, 1.0}
SIMULATION_SETTING = {
"1": {"quantile": 0, "buffer": 0.2, "powered_volume_enabled": True, "with_penalty": True},
"2": {"quantile": 15, "buffer": 0.3, "powered_volume_enabled": True, "with_penalty": True},
"3": {"quantile": 15, "buffer": 0.3, "powered_volume_enabled": False, "with_penalty": True},
"2": {"quantile": 0.15, "buffer": 0.3, "powered_volume_enabled": True, "with_penalty": True},
"3": {"quantile": 0.15, "buffer": 0.3, "powered_volume_enabled": False, "with_penalty": True},
"4": {"quantile": 0, "buffer": 0.2, "powered_volume_enabled": True, "with_penalty": False},
}
output_file_names: dict[str, str] = json.load(open(settings.OUTPUT_FILE_NAMES))
Expand Down Expand Up @@ -69,7 +69,8 @@
baseline_second_stage = BaselineSecondStage(
input_instance=baseline_input,
first_stage=baseline_first_stage,
timestep=timedelta(days=2),
timestep=timedelta(days=5),
time_limit=20,
**sim_setting
)
baseline_second_stage.solve_model()
Expand Down
11 changes: 8 additions & 3 deletions src/pyomo_models/baseline/second_stage/second_stage_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,16 @@ def solve_model(self):
self.generate_state_index()
self.generate_model_instance()
solution = self.solver.solve(self.model_instance, tee=self.log_solver_info)
if solution["Solver"][0]["Status"] != "ok":
if solution["Solver"][0]["Status"] == "ok":
self.extract_result()
elif solution["Solver"][0]["Status"] == "aborted":
print(f"Lower bound {solution["Problem"][0]["Lower bound"]} Lower bound {solution["Problem"][0]["Upper bound"]}")
self.extract_result()
else:
print(solution["Solver"][0]["Status"])
self.infeasible_constraints = check_infeasible_constraints(model=self.model_instance)
break
else:
self.extract_result()

self.finalizes_results_processing()


Expand Down

0 comments on commit a434660

Please sign in to comment.