From b91b46bee174dca37fbade380bb400a2d6e4b321 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Tue, 24 Oct 2023 14:57:10 +0200 Subject: [PATCH 01/12] docs: Added documentation for strategies module --- koswat/strategies/README.md | 18 ++++++++++++++++++ koswat/strategies/__init__.py | 0 2 files changed, 18 insertions(+) create mode 100644 koswat/strategies/README.md create mode 100644 koswat/strategies/__init__.py diff --git a/koswat/strategies/README.md b/koswat/strategies/README.md new file mode 100644 index 00000000..256ba16c --- /dev/null +++ b/koswat/strategies/README.md @@ -0,0 +1,18 @@ +# Strategies + +This modules contains the logic to choose which measure will be applied for a given dike traject. This happens through a series of iterations: +1. For each point (meter) in the traject, determine which measures can be applied to it. +2. Choose one of the available measures based on the chosen [strategy](#order-based-default). When no measure is available the most restrictive will be chosen (`CofferDam`). +3. Apply a buffer (`constructie_overgang`) for each one of the measures. +4. Check if the minimal distance between constructions is met (`constructie_afstand`), otherwise change it into one of the measures next to it. +5. Repeat 4 until all measures have enough distance between themselves. + +## Available strategies. + +### Order based (default). +A strategy is chosen based on a fix priority order: +1. `SoilReinforcement` +2. `PipingWallReinforcement` +3. `StabilityWallReinforcement` +4. `CofferDamReinforcement` + diff --git a/koswat/strategies/__init__.py b/koswat/strategies/__init__.py new file mode 100644 index 00000000..e69de29b From 1823845cc44736a4260a1b18d8fa1690f539f23b Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Tue, 24 Oct 2023 20:26:50 +0200 Subject: [PATCH 02/12] feat: Added new class to better handle / generate the location-reinforcement matrix --- .../summary/koswat_summary_builder.py | 6 ++ .../summary/koswat_summary_location_matrix.py | 29 +++++++ .../koswat_summary_location_matrix_builder.py | 76 +++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 koswat/cost_report/summary/koswat_summary_location_matrix.py create mode 100644 koswat/cost_report/summary/koswat_summary_location_matrix_builder.py diff --git a/koswat/cost_report/summary/koswat_summary_builder.py b/koswat/cost_report/summary/koswat_summary_builder.py index bf926ecc..0b34611d 100644 --- a/koswat/cost_report/summary/koswat_summary_builder.py +++ b/koswat/cost_report/summary/koswat_summary_builder.py @@ -10,6 +10,9 @@ MultiLocationProfileCostReportBuilder, ) from koswat.cost_report.summary.koswat_summary import KoswatSummary +from koswat.cost_report.summary.koswat_summary_location_matrix import ( + KoswatSummaryLocationMatrixBuilder, +) from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase from koswat.dike_reinforcements import ReinforcementProfileBuilderFactory from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( @@ -92,4 +95,7 @@ def build(self) -> KoswatSummary: for _calc_profile in self._get_calculated_profile_list(): _mlpc_builder.reinforced_profile = _calc_profile _summary.locations_profile_report_list.append(_mlpc_builder.build()) + _matrix = KoswatSummaryLocationMatrixBuilder( + _summary.locations_profile_report_list, _summary.available_locations + ).build() return _summary diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix.py b/koswat/cost_report/summary/koswat_summary_location_matrix.py new file mode 100644 index 00000000..31eec15e --- /dev/null +++ b/koswat/cost_report/summary/koswat_summary_location_matrix.py @@ -0,0 +1,29 @@ +from dataclasses import dataclass, field +from koswat.dike.surroundings.point.point_surroundings import PointSurroundings +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( + ReinforcementProfile, +) + + +@dataclass +class KoswatLocationReinforcements: + location: PointSurroundings + reinforcement_list: list[ReinforcementProfile] = field(default_factory=lambda: []) + + +class KoswatSummaryLocationMatrix: + locations_matrix: list[KoswatLocationReinforcements] + + def __init__(self) -> None: + self.locations_matrix = [] + + def __add__(self, other): + return other + self + + @classmethod + def from_point_surroundings_list(cls, point_surroundings: list[PointSurroundings]): + _this_cls = cls() + _this_cls.locations_matrix = list( + map(lambda x: KoswatLocationReinforcements(location=x), point_surroundings) + ) + return _this_cls diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py new file mode 100644 index 00000000..bd3b7348 --- /dev/null +++ b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py @@ -0,0 +1,76 @@ +from collections import defaultdict +import logging +from koswat.core.protocols.builder_protocol import BuilderProtocol +from koswat.cost_report.multi_location_profile.multi_location_profile_cost_report import ( + MultiLocationProfileCostReport, +) +from koswat.cost_report.summary.koswat_summary_location_matrix import ( + KoswatSummaryLocationMatrix, +) +from koswat.dike.surroundings.point.point_surroundings import PointSurroundings +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( + ReinforcementProfile, +) + + +class KoswatSummaryLocationMatrixBuilder(BuilderProtocol): + """ + NOTE: Although this 'problem' could be easily solved with `pandas` + or `numpy`, I prefer not to include external (heavy) dependencies unless + strictily necessary. + If / when performance would become a problem, then this builder could (perhaps) + benefit from using the aforementioned libraries. + """ + + locations_profile_report_list: list[MultiLocationProfileCostReport] + available_locations: list[PointSurroundings] + + def __init__( + self, + locations_profile: list[MultiLocationProfileCostReport], + available_locations: list[PointSurroundings], + ) -> None: + self.locations_profile_report_list = locations_profile + self.available_locations = available_locations + + def _multi_location_profile_to_dict( + self, locations_profile: MultiLocationProfileCostReport + ) -> dict[PointSurroundings, ReinforcementProfile]: + return dict( + (_location, locations_profile.profile_cost_report.reinforced_profile) + for _location in locations_profile.locations + ) + + def _get_matrix_for_locations_with_reinforcements( + self, + ) -> KoswatSummaryLocationMatrix: + _resulting_dict = defaultdict(list) + for _dict in map( + self._multi_location_profile_to_dict, + self.locations_profile_report_list, + ): + for key, value in _dict.items(): + _resulting_dict[key].append(value) + return _resulting_dict + + def build(self) -> KoswatSummaryLocationMatrix: + # 1. First we get all the possible reinforcements per point. + + logging.info("Initalizing locations-reinforcements matrix.") + _reinforce_loc_dict = self._get_matrix_for_locations_with_reinforcements() + + # 2. Then we initialize the matrix with all available locations, + # but no reinforcements. + + _summary_matrix = KoswatSummaryLocationMatrix.from_point_surroundings_list( + self.available_locations + ) + + # 3. Last, we merge both dictionaries. + for _location in _summary_matrix.locations_matrix: + _location.reinforcement_list = _reinforce_loc_dict.get( + _location.location, [] + ) + + logging.info("Finalized locations-reinforcements matrix.") + return _summary_matrix From ed5c5a9f0191fa605244b54e2ffb88ae0d0995df Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Tue, 24 Oct 2023 20:28:18 +0200 Subject: [PATCH 03/12] chore: Fixed builder reference --- koswat/cost_report/summary/koswat_summary_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koswat/cost_report/summary/koswat_summary_builder.py b/koswat/cost_report/summary/koswat_summary_builder.py index 0b34611d..eaf37337 100644 --- a/koswat/cost_report/summary/koswat_summary_builder.py +++ b/koswat/cost_report/summary/koswat_summary_builder.py @@ -10,7 +10,7 @@ MultiLocationProfileCostReportBuilder, ) from koswat.cost_report.summary.koswat_summary import KoswatSummary -from koswat.cost_report.summary.koswat_summary_location_matrix import ( +from koswat.cost_report.summary.koswat_summary_location_matrix_builder import ( KoswatSummaryLocationMatrixBuilder, ) from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase From beff199014b8c128486c4d01488e925d67e43289 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Tue, 24 Oct 2023 21:45:39 +0200 Subject: [PATCH 04/12] chore: Fixed summary location matrix builder by overriding hash and eq operators in `PointSurroundings` --- .../summary/koswat_summary_location_matrix.py | 17 ++------- .../koswat_summary_location_matrix_builder.py | 38 ++++++++++--------- .../surroundings/point/point_surroundings.py | 27 +++++++++++++ 3 files changed, 50 insertions(+), 32 deletions(-) diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix.py b/koswat/cost_report/summary/koswat_summary_location_matrix.py index 31eec15e..3a471270 100644 --- a/koswat/cost_report/summary/koswat_summary_location_matrix.py +++ b/koswat/cost_report/summary/koswat_summary_location_matrix.py @@ -1,29 +1,18 @@ -from dataclasses import dataclass, field +from __future__ import annotations from koswat.dike.surroundings.point.point_surroundings import PointSurroundings from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( ReinforcementProfile, ) -@dataclass -class KoswatLocationReinforcements: - location: PointSurroundings - reinforcement_list: list[ReinforcementProfile] = field(default_factory=lambda: []) - - class KoswatSummaryLocationMatrix: - locations_matrix: list[KoswatLocationReinforcements] + locations_matrix: dict[PointSurroundings, list[ReinforcementProfile]] def __init__(self) -> None: self.locations_matrix = [] - def __add__(self, other): - return other + self - @classmethod def from_point_surroundings_list(cls, point_surroundings: list[PointSurroundings]): _this_cls = cls() - _this_cls.locations_matrix = list( - map(lambda x: KoswatLocationReinforcements(location=x), point_surroundings) - ) + _this_cls.locations_matrix = dict((_ps, []) for _ps in point_surroundings) return _this_cls diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py index bd3b7348..51474c2d 100644 --- a/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py +++ b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py @@ -1,4 +1,3 @@ -from collections import defaultdict import logging from koswat.core.protocols.builder_protocol import BuilderProtocol from koswat.cost_report.multi_location_profile.multi_location_profile_cost_report import ( @@ -33,7 +32,7 @@ def __init__( self.locations_profile_report_list = locations_profile self.available_locations = available_locations - def _multi_location_profile_to_dict( + def _get_multi_location_profile_to_dict_matrix( self, locations_profile: MultiLocationProfileCostReport ) -> dict[PointSurroundings, ReinforcementProfile]: return dict( @@ -41,23 +40,23 @@ def _multi_location_profile_to_dict( for _location in locations_profile.locations ) - def _get_matrix_for_locations_with_reinforcements( + def _get_list_summary_matrix_for_locations_with_reinforcements( self, - ) -> KoswatSummaryLocationMatrix: - _resulting_dict = defaultdict(list) - for _dict in map( - self._multi_location_profile_to_dict, - self.locations_profile_report_list, - ): - for key, value in _dict.items(): - _resulting_dict[key].append(value) - return _resulting_dict + ) -> list[dict[PointSurroundings, ReinforcementProfile]]: + return list( + map( + self._get_multi_location_profile_to_dict_matrix, + self.locations_profile_report_list, + ) + ) def build(self) -> KoswatSummaryLocationMatrix: # 1. First we get all the possible reinforcements per point. logging.info("Initalizing locations-reinforcements matrix.") - _reinforce_loc_dict = self._get_matrix_for_locations_with_reinforcements() + _reinforce_matrix_dict_list = ( + self._get_list_summary_matrix_for_locations_with_reinforcements() + ) # 2. Then we initialize the matrix with all available locations, # but no reinforcements. @@ -66,11 +65,14 @@ def build(self) -> KoswatSummaryLocationMatrix: self.available_locations ) - # 3. Last, we merge both dictionaries. - for _location in _summary_matrix.locations_matrix: - _location.reinforcement_list = _reinforce_loc_dict.get( - _location.location, [] - ) + # 3. Last, we merge the reinforcements dictionary into the matrix. + for _location in _summary_matrix.locations_matrix.keys(): + for _reinforce_matrix_dict in _reinforce_matrix_dict_list: + if _location in _reinforce_matrix_dict: + _summary_matrix.locations_matrix[_location].append( + _reinforce_matrix_dict[_location] + ) logging.info("Finalized locations-reinforcements matrix.") + return _summary_matrix diff --git a/koswat/dike/surroundings/point/point_surroundings.py b/koswat/dike/surroundings/point/point_surroundings.py index 9f313b20..34d3d414 100644 --- a/koswat/dike/surroundings/point/point_surroundings.py +++ b/koswat/dike/surroundings/point/point_surroundings.py @@ -19,6 +19,33 @@ def __init__(self) -> None: self.traject_order = -1 self.distance_to_surroundings = [] + def __hash__(self) -> int: + """ + Overriding of the "magic" hash operator required + so that `PointSurroundings` can be used as a key in a python dict. + """ + return hash( + ( + self.section, + self.traject_order, + self.location, + self.distance_to_surroundings, + ) + ) + + def __eq__(self, __value: object) -> bool: + """ + Overriding of the "magic" equality operator required + so that `PointSurroundings` can be used as a key in a python dict. + """ + if not isinstance(__value, type(self)): + return False + return (self.location, self.section, self.traject_order) == ( + __value.location, + __value.section, + __value.traject_order, + ) + @property def closest_surrounding(self) -> float: """ From 5ee492e6fe938953d24bca702f65c05c3bfa3529 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Tue, 24 Oct 2023 21:51:05 +0200 Subject: [PATCH 05/12] feat: Added order_strategy submodule for determining reinforcement features across a dike traject based on default order --- koswat/strategies/order_strategy/__init__.py | 0 koswat/strategies/order_strategy/order_stategy.py | 12 ++++++++++++ 2 files changed, 12 insertions(+) create mode 100644 koswat/strategies/order_strategy/__init__.py create mode 100644 koswat/strategies/order_strategy/order_stategy.py diff --git a/koswat/strategies/order_strategy/__init__.py b/koswat/strategies/order_strategy/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/koswat/strategies/order_strategy/order_stategy.py b/koswat/strategies/order_strategy/order_stategy.py new file mode 100644 index 00000000..933f2f1d --- /dev/null +++ b/koswat/strategies/order_strategy/order_stategy.py @@ -0,0 +1,12 @@ +from koswat.cost_report.summary.koswat_summary_location_matrix import ( + KoswatSummaryLocationMatrix, +) + +from koswat.dike.surroundings.point.point_surroundings import PointSurroundings + + +class OrderStrategy: + _location_matrix: KoswatSummaryLocationMatrix + + def __init__(self, locations_matrix: KoswatSummaryLocationMatrix) -> None: + self._location_matrix = locations_matrix From b03a2372fb0c379dbabb2313d1b05d72253062d0 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Tue, 24 Oct 2023 22:08:46 +0200 Subject: [PATCH 06/12] chore: Added logic to apply `OrderStrategy` --- .../summary/koswat_summary_builder.py | 27 ++++++++++++++++--- .../order_strategy/order_stategy.py | 8 ++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/koswat/cost_report/summary/koswat_summary_builder.py b/koswat/cost_report/summary/koswat_summary_builder.py index eaf37337..2751f2ba 100644 --- a/koswat/cost_report/summary/koswat_summary_builder.py +++ b/koswat/cost_report/summary/koswat_summary_builder.py @@ -9,15 +9,23 @@ from koswat.cost_report.multi_location_profile import ( MultiLocationProfileCostReportBuilder, ) +from koswat.cost_report.multi_location_profile.multi_location_profile_cost_report import ( + MultiLocationProfileCostReport, +) from koswat.cost_report.summary.koswat_summary import KoswatSummary from koswat.cost_report.summary.koswat_summary_location_matrix_builder import ( KoswatSummaryLocationMatrixBuilder, ) from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase +from koswat.dike.surroundings.point.point_surroundings import PointSurroundings from koswat.dike_reinforcements import ReinforcementProfileBuilderFactory +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( + ReinforcementProfile, +) from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( ReinforcementProfileProtocol, ) +from koswat.strategies.order_strategy.order_stategy import OrderStrategy class KoswatSummaryBuilder(BuilderProtocol): @@ -81,6 +89,16 @@ def _get_multi_location_profile_cost_builder( _builder.koswat_costs = self.run_scenario_settings.costs return _builder + def _get_final_reinforcement_per_location( + self, + locations_profile_report_list: list[MultiLocationProfileCostReport], + available_locations: list[PointSurroundings], + ) -> dict[PointSurroundings, ReinforcementProfile]: + _matrix = KoswatSummaryLocationMatrixBuilder( + locations_profile_report_list, available_locations + ).build() + return OrderStrategy(_matrix).get_locations_reinforcements() + def build(self) -> KoswatSummary: _summary = KoswatSummary() _summary.available_locations = self.run_scenario_settings.surroundings.locations @@ -95,7 +113,10 @@ def build(self) -> KoswatSummary: for _calc_profile in self._get_calculated_profile_list(): _mlpc_builder.reinforced_profile = _calc_profile _summary.locations_profile_report_list.append(_mlpc_builder.build()) - _matrix = KoswatSummaryLocationMatrixBuilder( - _summary.locations_profile_report_list, _summary.available_locations - ).build() + + _summary.reinforcement_per_locations = ( + self._get_final_reinforcement_per_location( + _summary.locations_profile_report_list, _summary.available_locations + ) + ) return _summary diff --git a/koswat/strategies/order_strategy/order_stategy.py b/koswat/strategies/order_strategy/order_stategy.py index 933f2f1d..1699dbac 100644 --- a/koswat/strategies/order_strategy/order_stategy.py +++ b/koswat/strategies/order_strategy/order_stategy.py @@ -3,6 +3,9 @@ ) from koswat.dike.surroundings.point.point_surroundings import PointSurroundings +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( + ReinforcementProfile, +) class OrderStrategy: @@ -10,3 +13,8 @@ class OrderStrategy: def __init__(self, locations_matrix: KoswatSummaryLocationMatrix) -> None: self._location_matrix = locations_matrix + + def get_locations_reinforcements( + self, + ) -> dict[PointSurroundings, ReinforcementProfile]: + raise NotImplementedError() From 537c15ac88e3ce0d8a0965d31a8a9e086b65bda2 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Tue, 24 Oct 2023 22:32:02 +0200 Subject: [PATCH 07/12] chore: Added first loop to determine default chosen measure --- .../summary/koswat_summary_location_matrix.py | 6 +++- .../koswat_summary_location_matrix_builder.py | 2 +- .../surroundings/point/point_surroundings.py | 1 - .../order_strategy/order_stategy.py | 36 ++++++++++++++++++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix.py b/koswat/cost_report/summary/koswat_summary_location_matrix.py index 3a471270..2bcb10d8 100644 --- a/koswat/cost_report/summary/koswat_summary_location_matrix.py +++ b/koswat/cost_report/summary/koswat_summary_location_matrix.py @@ -1,4 +1,5 @@ from __future__ import annotations +from typing import Type from koswat.dike.surroundings.point.point_surroundings import PointSurroundings from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( ReinforcementProfile, @@ -6,11 +7,14 @@ class KoswatSummaryLocationMatrix: - locations_matrix: dict[PointSurroundings, list[ReinforcementProfile]] + locations_matrix: dict[PointSurroundings, list[Type[ReinforcementProfile]]] def __init__(self) -> None: self.locations_matrix = [] + def get_order_by_location(self): + pass + @classmethod def from_point_surroundings_list(cls, point_surroundings: list[PointSurroundings]): _this_cls = cls() diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py index 51474c2d..b396c585 100644 --- a/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py +++ b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py @@ -36,7 +36,7 @@ def _get_multi_location_profile_to_dict_matrix( self, locations_profile: MultiLocationProfileCostReport ) -> dict[PointSurroundings, ReinforcementProfile]: return dict( - (_location, locations_profile.profile_cost_report.reinforced_profile) + (_location, type(locations_profile.profile_cost_report.reinforced_profile)) for _location in locations_profile.locations ) diff --git a/koswat/dike/surroundings/point/point_surroundings.py b/koswat/dike/surroundings/point/point_surroundings.py index 34d3d414..8fbd0e92 100644 --- a/koswat/dike/surroundings/point/point_surroundings.py +++ b/koswat/dike/surroundings/point/point_surroundings.py @@ -29,7 +29,6 @@ def __hash__(self) -> int: self.section, self.traject_order, self.location, - self.distance_to_surroundings, ) ) diff --git a/koswat/strategies/order_strategy/order_stategy.py b/koswat/strategies/order_strategy/order_stategy.py index 1699dbac..46ddc26e 100644 --- a/koswat/strategies/order_strategy/order_stategy.py +++ b/koswat/strategies/order_strategy/order_stategy.py @@ -1,20 +1,54 @@ +from collections import defaultdict +from typing import Type from koswat.cost_report.summary.koswat_summary_location_matrix import ( KoswatSummaryLocationMatrix, ) from koswat.dike.surroundings.point.point_surroundings import PointSurroundings +from koswat.dike_reinforcements.reinforcement_profile.outside_slope import ( + cofferdam_reinforcement_profile, +) from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( ReinforcementProfile, ) +from koswat.dike_reinforcements.reinforcement_profile.standard.piping_wall_reinforcement_profile import ( + PipingWallReinforcementProfile, +) +from koswat.dike_reinforcements.reinforcement_profile.standard.soil_reinforcement_profile import ( + SoilReinforcementProfile, +) +from koswat.dike_reinforcements.reinforcement_profile.standard.stability_wall_reinforcement_profile import ( + StabilityWallReinforcementProfile, +) class OrderStrategy: _location_matrix: KoswatSummaryLocationMatrix + _order_reinforcement: list[Type[ReinforcementProfile]] def __init__(self, locations_matrix: KoswatSummaryLocationMatrix) -> None: self._location_matrix = locations_matrix + self._order_reinforcement = [ + SoilReinforcementProfile, + PipingWallReinforcementProfile, + StabilityWallReinforcementProfile, + cofferdam_reinforcement_profile, + ] def get_locations_reinforcements( self, ) -> dict[PointSurroundings, ReinforcementProfile]: - raise NotImplementedError() + # Ensure it's ordered + self._location_matrix.get_order_by_location() + + _first_choice = defaultdict(list) + for ( + _location, + _reinforcements, + ) in self._location_matrix.locations_matrix.items(): + _first_choice[_location] = next( + (_or for _or in self._order_reinforcement if _or in _reinforcements), + self._order_reinforcement[-1], + ) + + return dict(_first_choice) From be0b636beb79a95feb8d7879c046deeabb0163d2 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Wed, 25 Oct 2023 09:06:34 +0200 Subject: [PATCH 08/12] chore: Added dataclass to handle strategy input --- .../cost_report/summary/koswat_summary_builder.py | 15 ++++++++++++++- koswat/strategies/order_strategy/order_stategy.py | 9 +++++++-- koswat/strategies/strategy_input.py | 9 +++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 koswat/strategies/strategy_input.py diff --git a/koswat/cost_report/summary/koswat_summary_builder.py b/koswat/cost_report/summary/koswat_summary_builder.py index 2751f2ba..803bde6a 100644 --- a/koswat/cost_report/summary/koswat_summary_builder.py +++ b/koswat/cost_report/summary/koswat_summary_builder.py @@ -26,6 +26,7 @@ ReinforcementProfileProtocol, ) from koswat.strategies.order_strategy.order_stategy import OrderStrategy +from koswat.strategies.strategy_input import StrategyInput class KoswatSummaryBuilder(BuilderProtocol): @@ -97,7 +98,19 @@ def _get_final_reinforcement_per_location( _matrix = KoswatSummaryLocationMatrixBuilder( locations_profile_report_list, available_locations ).build() - return OrderStrategy(_matrix).get_locations_reinforcements() + + # TODO: `structure_buffer` and `min_space_between_structures` should come + # from the ini files. + + _strategy_input = StrategyInput( + locations_matrix=_matrix, + structure_buffer=10, + min_space_between_structures=50, + ) + + # In theory this will become a factory (somewhere) where + # the adequate strategy will be chosen. + return OrderStrategy(_strategy_input).get_locations_reinforcements() def build(self) -> KoswatSummary: _summary = KoswatSummary() diff --git a/koswat/strategies/order_strategy/order_stategy.py b/koswat/strategies/order_strategy/order_stategy.py index 46ddc26e..ebefa657 100644 --- a/koswat/strategies/order_strategy/order_stategy.py +++ b/koswat/strategies/order_strategy/order_stategy.py @@ -20,20 +20,25 @@ from koswat.dike_reinforcements.reinforcement_profile.standard.stability_wall_reinforcement_profile import ( StabilityWallReinforcementProfile, ) +from koswat.strategies.strategy_input import StrategyInput class OrderStrategy: _location_matrix: KoswatSummaryLocationMatrix _order_reinforcement: list[Type[ReinforcementProfile]] + _structure_buffer: float + _min_space_between_structures: float - def __init__(self, locations_matrix: KoswatSummaryLocationMatrix) -> None: - self._location_matrix = locations_matrix + def __init__(self, strategy_input: StrategyInput) -> None: self._order_reinforcement = [ SoilReinforcementProfile, PipingWallReinforcementProfile, StabilityWallReinforcementProfile, cofferdam_reinforcement_profile, ] + self._location_matrix = strategy_input.locations_matrix + self._structure_buffer = strategy_input.structure_buffer + self._min_space_between_structures = strategy_input.min_space_between_structures def get_locations_reinforcements( self, diff --git a/koswat/strategies/strategy_input.py b/koswat/strategies/strategy_input.py new file mode 100644 index 00000000..e5046db5 --- /dev/null +++ b/koswat/strategies/strategy_input.py @@ -0,0 +1,9 @@ +from dataclasses import dataclass + +from koswat.cost_report.summary import koswat_summary_location_matrix_builder + +@dataclass +class StrategyInput: + locations_matrix: koswat_summary_location_matrix_builder + structure_buffer: float + min_space_between_structures: float \ No newline at end of file From 352f18e51dd083e0837446bd66a2dc631da6dcff Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Wed, 25 Oct 2023 10:25:40 +0200 Subject: [PATCH 09/12] chore: Added output to the summary csv. Added logic on how to sort the location matrix --- .../io/csv/summary_matrix_csv_fom_builder.py | 60 ++++++++++++------- koswat/cost_report/summary/koswat_summary.py | 15 ++--- .../summary/koswat_summary_location_matrix.py | 6 +- .../koswat_summary_location_matrix_builder.py | 2 + .../cofferdam_reinforcement_profile.py | 3 +- .../reinforcement_profile.py | 1 + .../piping_wall_reinforcement_profile.py | 3 +- .../standard/soil_reinforcement_profile.py | 3 +- .../stability_wall_reinforcement_profile.py | 3 +- .../order_strategy/order_stategy.py | 24 +++++--- koswat/strategies/strategy_location_matrix.py | 13 ++++ .../test_volume_cost_parameters_builder.py | 1 + 12 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 koswat/strategies/strategy_location_matrix.py diff --git a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py index c897e41b..04d6d667 100644 --- a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py +++ b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py @@ -1,13 +1,29 @@ import logging import math from collections import defaultdict -from typing import Any +from typing import Any, Type from koswat.core.io.csv.koswat_csv_fom import KoswatCsvFom from koswat.core.protocols.builder_protocol import BuilderProtocol from koswat.cost_report.profile.volume_cost_parameters import VolumeCostParameter from koswat.cost_report.summary.koswat_summary import KoswatSummary from koswat.dike.surroundings.point.point_surroundings import PointSurroundings +from koswat.dike_reinforcements.reinforcement_profile.outside_slope.cofferdam_reinforcement_profile import ( + CofferdamReinforcementProfile, +) +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( + ReinforcementProfileProtocol, +) +from koswat.dike_reinforcements.reinforcement_profile.standard.piping_wall_reinforcement_profile import ( + PipingWallReinforcementProfile, +) +from koswat.dike_reinforcements.reinforcement_profile.standard.soil_reinforcement_profile import ( + SoilReinforcementProfile, +) +from koswat.dike_reinforcements.reinforcement_profile.standard.stability_wall_reinforcement_profile import ( + StabilityWallReinforcementProfile, +) +from koswat.strategies.strategy_location_matrix import StrategyLocationReinforcements class SummaryMatrixCsvFomBuilder(BuilderProtocol): @@ -34,7 +50,7 @@ def build(self) -> KoswatCsvFom: _loc_prof_report.profile_cost_report.volume_cost_parameters.__dict__, _dict_of_entries, ) - _dict_of_entries[_locations_key].append(_loc_prof_report.locations) + # _dict_of_entries[_locations_key].append(_loc_prof_report.locations) if not _dict_of_entries: logging.error("No entries generated for the CSV Matrix.") @@ -48,7 +64,8 @@ def dict_to_csv_row(key, placeholders: int) -> list[str]: return row _location_rows = self._get_locations_matrix( - _dict_of_entries[_locations_key], self.koswat_summary.available_locations + # _dict_of_entries[_locations_key], self.koswat_summary.available_locations + self.koswat_summary.reinforcement_per_locations ) _required_placeholders = ( len(_location_rows[0]) @@ -69,18 +86,8 @@ def dict_to_csv_row(key, placeholders: int) -> list[str]: def _get_locations_matrix( self, - suitable_locations: list[list[PointSurroundings]], - available_locations: list[PointSurroundings], + reinforcement_per_locations: list[StrategyLocationReinforcements], ) -> list[list[Any]]: - def _find_location( - location: PointSurroundings, locations: list[PointSurroundings] - ) -> PointSurroundings: - return next( - _loc - for _loc in locations - if _loc.traject_order == location.traject_order - ) - def _location_as_row( matrix_item: tuple[PointSurroundings, list[int]] ) -> list[Any]: @@ -89,20 +96,27 @@ def _location_as_row( _location_as_row.extend(_m_values) return _location_as_row - if not any(available_locations): + if not any(reinforcement_per_locations): logging.warning("No locations specified for the report.") return [[]] # Initiate locations matrix. _matrix = defaultdict(list) - for _available_loc in available_locations: - _matrix[_available_loc] = [0] * len(suitable_locations) - - # Set the suitable locations. - for idx, _loc_list in enumerate(suitable_locations): - for _loc in _loc_list: - _available_loc = _find_location(_loc, available_locations) - _matrix[_available_loc][idx] = 1 + _summary_columns_order = [ + SoilReinforcementProfile, + PipingWallReinforcementProfile, + StabilityWallReinforcementProfile, + CofferdamReinforcementProfile, + ] + for _reinforcement_per_location in reinforcement_per_locations: + _suitable_locations = [ + int(_type in _reinforcement_per_location.available_measures) + for _type in _summary_columns_order + ] + _matrix[_reinforcement_per_location.location] = _suitable_locations + [ + _reinforcement_per_location.selected_measure.output_name + ] + return list( map( _location_as_row, diff --git a/koswat/cost_report/summary/koswat_summary.py b/koswat/cost_report/summary/koswat_summary.py index 5f19a24d..b428fff6 100644 --- a/koswat/cost_report/summary/koswat_summary.py +++ b/koswat/cost_report/summary/koswat_summary.py @@ -1,15 +1,12 @@ from __future__ import annotations - -from typing import List +from dataclasses import field, dataclass from koswat.cost_report.multi_location_profile import MultiLocationProfileCostReport from koswat.dike.surroundings.point.point_surroundings import PointSurroundings +from koswat.strategies.strategy_location_matrix import StrategyLocationReinforcements - +@dataclass class KoswatSummary: - locations_profile_report_list: List[MultiLocationProfileCostReport] - available_locations: List[PointSurroundings] - - def __init__(self) -> None: - self.locations_profile_report_list = [] - self.available_locations = [] + locations_profile_report_list: list[MultiLocationProfileCostReport] = field(default_factory=lambda: []) + available_locations: list[PointSurroundings] = field(default_factory=lambda: []) + reinforcement_per_locations: list[StrategyLocationReinforcements] = field(default_factory=lambda: []) \ No newline at end of file diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix.py b/koswat/cost_report/summary/koswat_summary_location_matrix.py index 2bcb10d8..2a1b5cb4 100644 --- a/koswat/cost_report/summary/koswat_summary_location_matrix.py +++ b/koswat/cost_report/summary/koswat_summary_location_matrix.py @@ -12,8 +12,10 @@ class KoswatSummaryLocationMatrix: def __init__(self) -> None: self.locations_matrix = [] - def get_order_by_location(self): - pass + def sort_by_traject_order(self): + self.locations_matrix = dict( + sorted(self.locations_matrix.items(), key=lambda x: x[0].traject_order) + ) @classmethod def from_point_surroundings_list(cls, point_surroundings: list[PointSurroundings]): diff --git a/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py index b396c585..db45225e 100644 --- a/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py +++ b/koswat/cost_report/summary/koswat_summary_location_matrix_builder.py @@ -73,6 +73,8 @@ def build(self) -> KoswatSummaryLocationMatrix: _reinforce_matrix_dict[_location] ) + _summary_matrix.sort_by_traject_order() + logging.info("Finalized locations-reinforcements matrix.") return _summary_matrix diff --git a/koswat/dike_reinforcements/reinforcement_profile/outside_slope/cofferdam_reinforcement_profile.py b/koswat/dike_reinforcements/reinforcement_profile/outside_slope/cofferdam_reinforcement_profile.py index 99f59979..67e4585f 100644 --- a/koswat/dike_reinforcements/reinforcement_profile/outside_slope/cofferdam_reinforcement_profile.py +++ b/koswat/dike_reinforcements/reinforcement_profile/outside_slope/cofferdam_reinforcement_profile.py @@ -11,10 +11,11 @@ class CofferdamReinforcementProfile(OutsideSlopeReinforcementProfile): + output_name: str = "Kistdam" input_data: CofferDamInputProfile layers_wrapper: ReinforcementLayersWrapper old_profile: KoswatProfileProtocol new_ground_level_surface: float def __str__(self) -> str: - return "Kistdam" + return self.output_name diff --git a/koswat/dike_reinforcements/reinforcement_profile/reinforcement_profile.py b/koswat/dike_reinforcements/reinforcement_profile/reinforcement_profile.py index 2481dc83..b505b05c 100644 --- a/koswat/dike_reinforcements/reinforcement_profile/reinforcement_profile.py +++ b/koswat/dike_reinforcements/reinforcement_profile/reinforcement_profile.py @@ -12,6 +12,7 @@ class ReinforcementProfile(ReinforcementProfileProtocol, KoswatProfileBase): + output_name: str input_data: ReinforcementInputProfileProtocol layers_wrapper: ReinforcementLayersWrapper old_profile: KoswatProfileProtocol diff --git a/koswat/dike_reinforcements/reinforcement_profile/standard/piping_wall_reinforcement_profile.py b/koswat/dike_reinforcements/reinforcement_profile/standard/piping_wall_reinforcement_profile.py index dd7ad67c..1f752863 100644 --- a/koswat/dike_reinforcements/reinforcement_profile/standard/piping_wall_reinforcement_profile.py +++ b/koswat/dike_reinforcements/reinforcement_profile/standard/piping_wall_reinforcement_profile.py @@ -11,10 +11,11 @@ class PipingWallReinforcementProfile(StandardReinforcementProfile): + output_name: str = "Kwelscherm" input_data: PipingWallInputProfile layers_wrapper: ReinforcementLayersWrapper old_profile: KoswatProfileProtocol new_ground_level_surface: float def __str__(self) -> str: - return "Kwelscherm" + return self.output_name diff --git a/koswat/dike_reinforcements/reinforcement_profile/standard/soil_reinforcement_profile.py b/koswat/dike_reinforcements/reinforcement_profile/standard/soil_reinforcement_profile.py index 91102ab9..c4c8e7ae 100644 --- a/koswat/dike_reinforcements/reinforcement_profile/standard/soil_reinforcement_profile.py +++ b/koswat/dike_reinforcements/reinforcement_profile/standard/soil_reinforcement_profile.py @@ -11,10 +11,11 @@ class SoilReinforcementProfile(StandardReinforcementProfile): + output_name: str = "Grondmaatregel profiel" input_data: SoilInputProfile layers_wrapper: ReinforcementLayersWrapper old_profile: KoswatProfileProtocol new_ground_level_surface: float def __str__(self) -> str: - return "Grondmaatregel profiel" + return self.output_name diff --git a/koswat/dike_reinforcements/reinforcement_profile/standard/stability_wall_reinforcement_profile.py b/koswat/dike_reinforcements/reinforcement_profile/standard/stability_wall_reinforcement_profile.py index ecb0de0b..8b717bbb 100644 --- a/koswat/dike_reinforcements/reinforcement_profile/standard/stability_wall_reinforcement_profile.py +++ b/koswat/dike_reinforcements/reinforcement_profile/standard/stability_wall_reinforcement_profile.py @@ -11,10 +11,11 @@ class StabilityWallReinforcementProfile(StandardReinforcementProfile): + output_name: str = "Stabiliteitswand" input_data: StabilityWallInputProfile layers_wrapper: ReinforcementLayersWrapper old_profile: KoswatProfileProtocol new_ground_level_surface: float def __str__(self) -> str: - return "Stabiliteitswand" + return self.output_name diff --git a/koswat/strategies/order_strategy/order_stategy.py b/koswat/strategies/order_strategy/order_stategy.py index ebefa657..0febc8ec 100644 --- a/koswat/strategies/order_strategy/order_stategy.py +++ b/koswat/strategies/order_strategy/order_stategy.py @@ -5,8 +5,8 @@ ) from koswat.dike.surroundings.point.point_surroundings import PointSurroundings -from koswat.dike_reinforcements.reinforcement_profile.outside_slope import ( - cofferdam_reinforcement_profile, +from koswat.dike_reinforcements.reinforcement_profile.outside_slope.cofferdam_reinforcement_profile import ( + CofferdamReinforcementProfile, ) from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( ReinforcementProfile, @@ -21,6 +21,7 @@ StabilityWallReinforcementProfile, ) from koswat.strategies.strategy_input import StrategyInput +from koswat.strategies.strategy_location_matrix import StrategyLocationReinforcements class OrderStrategy: @@ -34,7 +35,7 @@ def __init__(self, strategy_input: StrategyInput) -> None: SoilReinforcementProfile, PipingWallReinforcementProfile, StabilityWallReinforcementProfile, - cofferdam_reinforcement_profile, + CofferdamReinforcementProfile, ] self._location_matrix = strategy_input.locations_matrix self._structure_buffer = strategy_input.structure_buffer @@ -42,18 +43,23 @@ def __init__(self, strategy_input: StrategyInput) -> None: def get_locations_reinforcements( self, - ) -> dict[PointSurroundings, ReinforcementProfile]: + ) -> list[StrategyLocationReinforcements]: # Ensure it's ordered - self._location_matrix.get_order_by_location() - - _first_choice = defaultdict(list) + _strategy_reinforcements = [] for ( _location, _reinforcements, ) in self._location_matrix.locations_matrix.items(): - _first_choice[_location] = next( + _selected_reinforcement = next( (_or for _or in self._order_reinforcement if _or in _reinforcements), self._order_reinforcement[-1], ) + _strategy_reinforcements.append( + StrategyLocationReinforcements( + location=_location, + available_measures=_reinforcements, + selected_measure=_selected_reinforcement, + ) + ) - return dict(_first_choice) + return _strategy_reinforcements diff --git a/koswat/strategies/strategy_location_matrix.py b/koswat/strategies/strategy_location_matrix.py new file mode 100644 index 00000000..9d172b1a --- /dev/null +++ b/koswat/strategies/strategy_location_matrix.py @@ -0,0 +1,13 @@ +from dataclasses import dataclass +from typing import Type +from koswat.dike.surroundings.point.point_surroundings import PointSurroundings +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( + ReinforcementProfileProtocol, +) + + +@dataclass +class StrategyLocationReinforcements: + location: PointSurroundings + selected_measure: Type[ReinforcementProfileProtocol] + available_measures: list[Type[ReinforcementProfileProtocol]] diff --git a/tests/cost_report/profile/test_volume_cost_parameters_builder.py b/tests/cost_report/profile/test_volume_cost_parameters_builder.py index 81cd3bfd..842a3cd1 100644 --- a/tests/cost_report/profile/test_volume_cost_parameters_builder.py +++ b/tests/cost_report/profile/test_volume_cost_parameters_builder.py @@ -91,6 +91,7 @@ def __init__(self) -> None: def _get_mocked_reinforcement(self) -> ReinforcementProfileProtocol: class MockedReinforcement(StandardReinforcementProfile): + output_name: str = "Mocked reinforcement" @property def new_ground_level_surface(self) -> float: return 42.0 From 13804f2bc4d1666aecc4c29fccfda3a96ac2c5d8 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Wed, 25 Oct 2023 11:49:36 +0200 Subject: [PATCH 10/12] chore: Updated logic so that the columns are correctly placed --- .../io/csv/summary_matrix_csv_fom_builder.py | 28 +++++++++---------- .../multi_location_profile_cost_report.py | 2 +- koswat/koswat_handler.py | 2 +- ...test_multi_location_profile_cost_report.py | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py index 04d6d667..37f6aa7e 100644 --- a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py +++ b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py @@ -35,6 +35,14 @@ class SummaryMatrixCsvFomBuilder(BuilderProtocol): def __init__(self) -> None: self.koswat_summary = None + def get_summary_reinforcement_type_column_order( + self, + ) -> list[Type[ReinforcementProfileProtocol]]: + return [ + type(_report.profile_cost_report.reinforced_profile) + for _report in self.koswat_summary.locations_profile_report_list + ] + def build(self) -> KoswatCsvFom: _csv_fom = KoswatCsvFom() @@ -44,7 +52,9 @@ def build(self) -> KoswatCsvFom: _dict_of_entries = defaultdict(list) for _loc_prof_report in self.koswat_summary.locations_profile_report_list: - _dict_of_entries[_profile_type_key].append(_loc_prof_report.profile_type) + _dict_of_entries[_profile_type_key].append( + _loc_prof_report.profile_type_name + ) _dict_of_entries[_cost_per_km_key].append(_loc_prof_report.cost_per_km) self._get_volume_cost_parameters( _loc_prof_report.profile_cost_report.volume_cost_parameters.__dict__, @@ -64,14 +74,9 @@ def dict_to_csv_row(key, placeholders: int) -> list[str]: return row _location_rows = self._get_locations_matrix( - # _dict_of_entries[_locations_key], self.koswat_summary.available_locations self.koswat_summary.reinforcement_per_locations ) - _required_placeholders = ( - len(_location_rows[0]) - - len(self.koswat_summary.locations_profile_report_list) - - 1 - ) + _required_placeholders = 2 # Fix value. _headers = dict_to_csv_row(_profile_type_key, _required_placeholders) _cost_rows = [ dict_to_csv_row(_parameter_key, _required_placeholders) @@ -102,16 +107,11 @@ def _location_as_row( # Initiate locations matrix. _matrix = defaultdict(list) - _summary_columns_order = [ - SoilReinforcementProfile, - PipingWallReinforcementProfile, - StabilityWallReinforcementProfile, - CofferdamReinforcementProfile, - ] + for _reinforcement_per_location in reinforcement_per_locations: _suitable_locations = [ int(_type in _reinforcement_per_location.available_measures) - for _type in _summary_columns_order + for _type in self.get_summary_reinforcement_type_column_order() ] _matrix[_reinforcement_per_location.location] = _suitable_locations + [ _reinforcement_per_location.selected_measure.output_name diff --git a/koswat/cost_report/multi_location_profile/multi_location_profile_cost_report.py b/koswat/cost_report/multi_location_profile/multi_location_profile_cost_report.py index 3d379820..9a535d1d 100644 --- a/koswat/cost_report/multi_location_profile/multi_location_profile_cost_report.py +++ b/koswat/cost_report/multi_location_profile/multi_location_profile_cost_report.py @@ -34,7 +34,7 @@ def total_volume(self) -> float: return self.profile_cost_report.total_volume * len(self.locations) @property - def profile_type(self) -> str: + def profile_type_name(self) -> str: if ( not self.profile_cost_report or not self.profile_cost_report.reinforced_profile diff --git a/koswat/koswat_handler.py b/koswat/koswat_handler.py index d27a7f85..69e9108b 100644 --- a/koswat/koswat_handler.py +++ b/koswat/koswat_handler.py @@ -77,7 +77,7 @@ def _generate_plots( except Exception as e_info: logging.error( "Failed to export report comparison plots for {}.".format( - _multi_report.profile_type + _multi_report.profile_type_name ) ) logging.error(e_info) diff --git a/tests/cost_report/multi_location_profile/test_multi_location_profile_cost_report.py b/tests/cost_report/multi_location_profile/test_multi_location_profile_cost_report.py index bd98567c..74806995 100644 --- a/tests/cost_report/multi_location_profile/test_multi_location_profile_cost_report.py +++ b/tests/cost_report/multi_location_profile/test_multi_location_profile_cost_report.py @@ -11,7 +11,7 @@ def test_initialize(self): assert isinstance(_report, MultiLocationProfileCostReport) assert not any(_report.locations) assert not _report.profile_cost_report - assert not _report.profile_type + assert not _report.profile_type_name assert math.isnan(_report.total_cost) assert math.isnan(_report.total_volume) assert math.isnan(_report.cost_per_km) From a731ada725016754d36161290920508782bd268b Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Wed, 25 Oct 2023 12:03:26 +0200 Subject: [PATCH 11/12] chore: removed commented out code --- koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py index 37f6aa7e..feb13eaa 100644 --- a/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py +++ b/koswat/cost_report/io/csv/summary_matrix_csv_fom_builder.py @@ -48,7 +48,6 @@ def build(self) -> KoswatCsvFom: _profile_type_key = "Profile type" _cost_per_km_key = "Cost per km (€)" - _locations_key = "locations" _dict_of_entries = defaultdict(list) for _loc_prof_report in self.koswat_summary.locations_profile_report_list: @@ -60,7 +59,6 @@ def build(self) -> KoswatCsvFom: _loc_prof_report.profile_cost_report.volume_cost_parameters.__dict__, _dict_of_entries, ) - # _dict_of_entries[_locations_key].append(_loc_prof_report.locations) if not _dict_of_entries: logging.error("No entries generated for the CSV Matrix.") From 65d1215de147ad202dc2eda210c30ac3ba90e199 Mon Sep 17 00:00:00 2001 From: "Carles S. Soriano Perez" Date: Wed, 25 Oct 2023 12:43:41 +0200 Subject: [PATCH 12/12] chore: Removed irrelevant comment --- koswat/strategies/order_strategy/order_stategy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/koswat/strategies/order_strategy/order_stategy.py b/koswat/strategies/order_strategy/order_stategy.py index 0febc8ec..85978020 100644 --- a/koswat/strategies/order_strategy/order_stategy.py +++ b/koswat/strategies/order_strategy/order_stategy.py @@ -44,7 +44,6 @@ def __init__(self, strategy_input: StrategyInput) -> None: def get_locations_reinforcements( self, ) -> list[StrategyLocationReinforcements]: - # Ensure it's ordered _strategy_reinforcements = [] for ( _location,