Skip to content

Commit

Permalink
Add test on cutting_plan_method
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliette-Gerbaux committed Jan 8, 2025
1 parent 0783cc1 commit 8cd4546
Show file tree
Hide file tree
Showing 4 changed files with 844 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,11 @@ def __init__(
self.remove_incoherence()

def __call__(self, x: np.ndarray) -> float:
if len(x.shape) > 1:
x = x[0]
return np.maximum(
self.lower_bound(x), np.sum([layer(x) for layer in self.layers], axis=0)
)[0]
)

def remove_inconsistence(self, tolerance: float = 1) -> None:
inputs, costs = self.lower_bound.inputs, self.lower_bound.costs
Expand Down
12 changes: 10 additions & 2 deletions src/multi_stock_bellman_value_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,18 @@ def Lget_costs(
pkl.dump((proto, m.stored_variables_and_constraints_ids), file)
costs_ws, slopes_ws, _, _ = get_week_scenario_costs(
m=m,
controls_list=controls_list[week, scenario],
controls_list=[
{
a: u[i]
for i, a in enumerate(
multi_stock_management.dict_reservoirs.keys()
)
}
for u in controls_list[week, scenario]
],
)
costs[week, scenario] = costs_ws
slopes[week, scenario] = slopes_ws
slopes[week, scenario] = [[sl for sl in s.values()] for s in slopes_ws]
with open(filename, "wb") as file:
pkl.dump(
(controls_list[: week + 1], costs[: week + 1], slopes[: week + 1]),
Expand Down
Loading

0 comments on commit 8cd4546

Please sign in to comment.