From 1bb25e67f7cc3f6a7008006091d1186f53a59631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carles=20S=2E=20Soriano=20P=C3=A9rez?= Date: Fri, 1 Nov 2024 11:59:37 +0100 Subject: [PATCH] feat: generate strategies intermediate results (#208) * chore: Modified definition of `StrategyLocationReinforcement` so it contains the different assigned reinforcements * chore: Small correction to directly display the previous selection if suitable * chore: Corrected summary builder so the strategy to run can be modified dinamically * chore: Small correction to output history of selection measure during strategies * test: Fixed failing tests after merge from `master` * chore: Small rework to track only three items in the selection history * chore: Renaming of outdated references * chore: Corrected code `get_strategy_reinforcemetns` so that the available measures are already ordered based on the current strategy * chore: Added some missing docstrings * chore: Corrections in the selection and output of history selected measures * chore: Correction to output selected measures * chore: Fixed output of steps * test: fixed failing tests * chore: Cleaning selected measures to avoid in-between steps * chore: Added to-do * test: Sync test data * feat: Added new dataclass and modified `StrategyLocationReinforcement` so we can better keep track -per-step- of the history and output it appropriately * chore: Added missing subproject * docs: Extended docstrings * test: added missing tests * test: Updated failing tests * chore: Extended shp export logic to include a new layer to represent the `step` from initial to new * test: fixed failing tests * chore: Small corrections to validate generated geodataframes * test: Updated reference data * chore: fixed failing test * chore: Extracted class for better maintainability * test: Added missing coverage test * docs: Documentation cleanup * chore: Removed todo notes * chore: Created new property to represent both available and filtered measures' * chore: Processed review remarks; Moved dataclass into typedict for performance reasons * test: Fixed failing test --- docs/reference/koswat_cost_report.md | 32 +++- .../summary_costs_csv_fom_builder.py | 4 +- .../cluster_collection_shp_fom.py | 34 +++- .../cluster_geodataframe_output_fom.py | 39 ++++ .../summary_locations_csv_fom_builder.py | 15 +- .../summary_locations_shp_exporter.py | 26 ++- koswat/cost_report/summary/koswat_summary.py | 4 +- .../summary/koswat_summary_builder.py | 6 +- koswat/strategies/README.md | 3 +- .../infra_priority_strategy/infra_cluster.py | 3 +- .../infra_priority_strategy.py | 4 +- .../order_strategy/order_cluster.py | 7 +- .../order_strategy/order_strategy.py | 44 +++-- .../order_strategy/order_strategy_base.py | 2 +- .../order_strategy_buffering.py | 5 +- .../strategy_location_reinforcement.py | 111 ++++++++++- koswat/strategies/strategy_step/__init__.py | 0 .../strategy_step/strategy_step_assignment.py | 11 ++ .../strategy_step/strategy_step_enum.py | 7 + tests/cost_report/io/summary/conftest.py | 22 +-- .../test_cluster_collection_shp_fom.py | 9 +- .../test_summary_locations_shp_exporter.py | 2 +- .../test_cluster_collection_shp_fom.py | 59 ++++++ .../test_cluster_geodataframe_output_fom.py | 34 ++++ .../test_summary_locations_csv_exporter.py | 10 +- tests/strategies/conftest.py | 4 +- .../test_infra_cluster.py | 15 +- .../test_infra_cluster_option.py | 4 +- .../test_infra_priority_strategy.py | 33 ++-- .../order_strategy/test_order_cluster.py | 15 +- .../order_strategy/test_order_strategy.py | 42 +++-- .../test_order_strategy_buffering.py | 2 +- .../test_order_strategy_clustering.py | 20 +- .../test_strategy_location_reinforcement.py | 173 ++++++++++++++++++ tests/test_acceptance.py | 7 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../summary_locations.csv | 2 +- .../sync_test_results.py | 7 +- tests/test_main.py | 8 +- 79 files changed, 724 insertions(+), 183 deletions(-) create mode 100644 koswat/cost_report/io/summary/summary_locations/cluster_geodataframe_output_fom.py create mode 100644 koswat/strategies/strategy_step/__init__.py create mode 100644 koswat/strategies/strategy_step/strategy_step_assignment.py create mode 100644 koswat/strategies/strategy_step/strategy_step_enum.py create mode 100644 tests/cost_report/io/summary/summary_locations/test_cluster_collection_shp_fom.py create mode 100644 tests/cost_report/io/summary/summary_locations/test_cluster_geodataframe_output_fom.py create mode 100644 tests/strategies/test_strategy_location_reinforcement.py diff --git a/docs/reference/koswat_cost_report.md b/docs/reference/koswat_cost_report.md index 7d47ffd6..6cbab1ce 100644 --- a/docs/reference/koswat_cost_report.md +++ b/docs/reference/koswat_cost_report.md @@ -84,11 +84,16 @@ After running a Koswat analysis, several files and directories will be generated - Dike section: The selected dike section being analyzed. - Generated files: A combination of images and a 'csv' matrix result. - Images: Visual description of each of the possible reinforcements being applied. - - summary_costs.csv: A csv file containing all the costs information of the summary. + - `summary_costs.csv`: A csv file containing all the costs information of the summary. - Represents the Summary, Profile and Layer report. - - summary_locations.csv: A csv file containing per-location a breakdown of available reinforcements and selected reinforcement ( see [strategies](koswat_strategies.md)). + - `summary_locations.csv` (phased out): A csv file containing per-location a breakdown of available reinforcements and selected reinforcement ( see [strategies](koswat_strategies.md)). - Represents the Location report. - - summary_infrastructure_costs.csv: A csv file contaning all the infrastructure costs at each location for each of the supported reinforcement profile types. + - `/summary_locations` directory: contains the following `.shp` files (and their related binaries): + -`summary_locations_measures`: The same data as present in `summary_locations.csv` is used to shape the geometry of a dike's traject. We keep as well the type of chosen reinforcement. + - `summary_locations_new`: an overlay of `summary_locations_measures` with the geometry buffered in relation to the new selected reinforcement. + - `summary_locations_old`: an overlay of `summary_locations_measures` with the geometry buffered in relation to the original selected reinforcement. + - `summary_locations_step`: an overlay of `summary_locations_measures` with the geometry buffered in relation to the [Ordered Strategy](koswat_strategies.md#order-based-default) step. + - `summary_infrastructure_costs.csv`: A csv file contaning all the infrastructure costs at each location for each of the supported reinforcement profile types. - Represents the [Infrastructure Report](#infrastructure-report). Example using a summarized view of the output tree directory when running the acceptance test `test_main.test_given_valid_input_succeeds`: @@ -108,6 +113,27 @@ acceptance | | | | Stabiliteitswand.png | | | | Verticale_piping_oplossing.png | | | | +| | | +-- summary_locations +| | | | summary_locations_measures.cpg +| | | | summary_locations_measures.dbf +| | | | summary_locations_measures.prj +| | | | summary_locations_measures.shp +| | | | summary_locations_measures.shx +| | | | summary_locations_new.cpg +| | | | summary_locations_new.dbf +| | | | summary_locations_new.prj +| | | | summary_locations_new.shp +| | | | summary_locations_new.shx +| | | | summary_locations_old.cpg +| | | | summary_locations_old.dbf +| | | | summary_locations_old.prj +| | | | summary_locations_old.shp +| | | | summary_locations_step.shx +| | | | summary_locations_step.cpg +| | | | summary_locations_step.dbf +| | | | summary_locations_step.prj +| | | | summary_locations_step.shp +| | | | summary_locations_step.shx | | | +-- Grondmaatregel_profiel | | | | added_Grondmaatregel_profiel_CLAY.png | | | | added_Grondmaatregel_profiel_GRASS.png diff --git a/koswat/cost_report/io/summary/summary_costs/summary_costs_csv_fom_builder.py b/koswat/cost_report/io/summary/summary_costs/summary_costs_csv_fom_builder.py index aa11297a..2829fcaa 100644 --- a/koswat/cost_report/io/summary/summary_costs/summary_costs_csv_fom_builder.py +++ b/koswat/cost_report/io/summary/summary_costs/summary_costs_csv_fom_builder.py @@ -99,13 +99,13 @@ def _get_total_meters_per_selected_measure( # ALWAYS to be of 1 meter. _sorted_reinforcements = sorted( self.koswat_summary.reinforcement_per_locations, - key=lambda x: x.selected_measure.output_name, + key=lambda x: x.current_selected_measure.output_name, ) return dict( (k, len(list(g))) for k, g in groupby( _sorted_reinforcements, - lambda x: x.selected_measure, + lambda x: x.current_selected_measure, ) ) diff --git a/koswat/cost_report/io/summary/summary_locations/cluster_collection_shp_fom.py b/koswat/cost_report/io/summary/summary_locations/cluster_collection_shp_fom.py index 8d03396c..a18730d7 100644 --- a/koswat/cost_report/io/summary/summary_locations/cluster_collection_shp_fom.py +++ b/koswat/cost_report/io/summary/summary_locations/cluster_collection_shp_fom.py @@ -2,10 +2,13 @@ from dataclasses import dataclass, field from itertools import groupby -from typing import Type +from typing import Callable, Type from geopandas import GeoDataFrame +from koswat.cost_report.io.summary.summary_locations.cluster_geodataframe_output_fom import ( + ClusterGeoDataFrameOutputFom, +) from koswat.cost_report.io.summary.summary_locations.cluster_shp_fom import ( ClusterShpFom, ) @@ -24,12 +27,22 @@ class ClusterCollectionShpFom: crs_projection: str = "EPSG:28992" @classmethod - def from_summary(cls, koswat_summary: KoswatSummary) -> ClusterCollectionShpFom: + def from_summary( + cls, + koswat_summary: KoswatSummary, + cluster_criteria: Callable[ + [StrategyLocationReinforcement], type[ReinforcementProfileProtocol] + ] = lambda x: x.current_selected_measure, + ) -> ClusterCollectionShpFom: """ Maps the `KoswatSummary` into a file object model that can be exported into `*.shp` files. Args: koswat_summary (KoswatSummary): The summary containing the information to export. + cluster_criteria (Callable[ + [StrategyLocationReinforcement], + type[ReinforcementProfileProtocol] + ]): (Lambda) Function criteria to group the locations by reinforcement type. Returns: ClusterCollectionShpFom: Dataclass instance that can be directly exported into `.shp`. @@ -53,21 +66,20 @@ def to_cluster_shp_fom( to_cluster_shp_fom, groupby( koswat_summary.reinforcement_per_locations, - key=lambda x: x.selected_measure, + key=cluster_criteria, ), ) ) ) - def generate_geodataframes(self) -> tuple[GeoDataFrame, GeoDataFrame, GeoDataFrame]: + def generate_geodataframes(self) -> ClusterGeoDataFrameOutputFom: """ Generates all geodataframes of the given clusters. The generated geodataframes correspond to the, base geometry (without buffering), the old and new geometries with their profile's width being buffered to the base geometry. Returns: - tuple[GeoDataFrame, GeoDataFrame, GeoDataFrame]: - Tuple of geodataframes maping this `ClusterCollectionShpFom`. + ClusterGeoDataFrameOutputFom: Resulting geodataframes wrapper maping this `ClusterCollectionShpFom`. """ def to_gdf_entry( @@ -94,9 +106,11 @@ def buffered_entry(buffered_value: float) -> dict: def dict_list_to_gdf(dict_entries: list[dict]) -> GeoDataFrame: return GeoDataFrame(data=dict_entries, crs=self.crs_projection) - return tuple( - map( - dict_list_to_gdf, - zip(*(to_gdf_entry(_cl) for _cl in self.clusters)), + return ClusterGeoDataFrameOutputFom( + tuple( + map( + dict_list_to_gdf, + zip(*(to_gdf_entry(_cl) for _cl in self.clusters)), + ) ) ) diff --git a/koswat/cost_report/io/summary/summary_locations/cluster_geodataframe_output_fom.py b/koswat/cost_report/io/summary/summary_locations/cluster_geodataframe_output_fom.py new file mode 100644 index 00000000..8954ef64 --- /dev/null +++ b/koswat/cost_report/io/summary/summary_locations/cluster_geodataframe_output_fom.py @@ -0,0 +1,39 @@ +from geopandas import GeoDataFrame + +from koswat.core.io.file_object_model_protocol import FileObjectModelProtocol + + +class ClusterGeoDataFrameOutputFom(FileObjectModelProtocol): + """ + Data structure to wrap the output generated by `ClusterCollectionShpFom.generate_geodataframes`. + """ + + base_layer: GeoDataFrame | None + initial_state: GeoDataFrame | None + new_state: GeoDataFrame | None + + def __init__(self, gdf_tuples: tuple[GeoDataFrame]): + self.base_layer = None + self.initial_state = None + self.new_state = None + + if not gdf_tuples: + return + self.base_layer = gdf_tuples[0] + self.initial_state = gdf_tuples[1] + self.new_state = gdf_tuples[2] + + def is_valid(self) -> bool: + """ + Checks that all `GeoDataFrame` properties are set. + + Returns: + bool: Validation result. + """ + + def validate_gdf(gdf: GeoDataFrame | None) -> bool: + return gdf is not None + + return all( + map(validate_gdf, [self.base_layer, self.initial_state, self.new_state]) + ) diff --git a/koswat/cost_report/io/summary/summary_locations/summary_locations_csv_fom_builder.py b/koswat/cost_report/io/summary/summary_locations/summary_locations_csv_fom_builder.py index 2e4e4d29..32a50493 100644 --- a/koswat/cost_report/io/summary/summary_locations/summary_locations_csv_fom_builder.py +++ b/koswat/cost_report/io/summary/summary_locations/summary_locations_csv_fom_builder.py @@ -44,7 +44,11 @@ def build(self) -> KoswatCsvFom: "Y coord", ] + _ordered_profile_types - + ["Selected reinforcement"] + + [ + "Initial selection", + "Ordered selection", + "Optimized selection", + ] ), entries=self._get_locations_matrix( self.koswat_summary.reinforcement_per_locations @@ -75,9 +79,12 @@ def _location_as_row( int(_type in _reinforcement_per_location.available_measures) for _type in self.get_summary_reinforcement_type_column_order() ] - _matrix[_reinforcement_per_location.location] = _suitable_locations + [ - _reinforcement_per_location.selected_measure.output_name - ] + _matrix[_reinforcement_per_location.location] = _suitable_locations + list( + map( + lambda x: x.output_name, + _reinforcement_per_location.get_selected_measure_steps(), + ) + ) return list( map( diff --git a/koswat/cost_report/io/summary/summary_locations/summary_locations_shp_exporter.py b/koswat/cost_report/io/summary/summary_locations/summary_locations_shp_exporter.py index 38513855..6a1a0953 100644 --- a/koswat/cost_report/io/summary/summary_locations/summary_locations_shp_exporter.py +++ b/koswat/cost_report/io/summary/summary_locations/summary_locations_shp_exporter.py @@ -15,14 +15,28 @@ def export(self, koswat_summary: KoswatSummary, export_path: Path) -> None: _old = export_path.joinpath("summary_locations_old.shp") _new = export_path.joinpath("summary_locations_new.shp") - # Get clusters + # Get clusters comparing old to new. _clusters = ClusterCollectionShpFom.from_summary( - koswat_summary + koswat_summary, lambda x: x.current_selected_measure ).generate_geodataframes() - if not _clusters: + if not _clusters.is_valid(): return - _clusters[0].to_file(_measures) - _clusters[1].to_file(_old) - _clusters[2].to_file(_new) + # Export clusters to file + _clusters.base_layer.to_file(_measures) + _clusters.initial_state.to_file(_old) + _clusters.new_state.to_file(_new) + + # Get clusters for steps + _step_clusters = ClusterCollectionShpFom.from_summary( + koswat_summary, lambda x: x.get_selected_measure_steps()[1] + ).generate_geodataframes() + + if not _step_clusters.is_valid(): + return + + # Export clusters to file + _step_clusters.new_state.to_file( + export_path.joinpath("summary_locations_step.shp") + ) diff --git a/koswat/cost_report/summary/koswat_summary.py b/koswat/cost_report/summary/koswat_summary.py index 019ac8bb..db0240e0 100644 --- a/koswat/cost_report/summary/koswat_summary.py +++ b/koswat/cost_report/summary/koswat_summary.py @@ -60,8 +60,8 @@ def get_infrastructure_costs( # Get the infra cost tuples (without and with surtax) for each location. _infra_costs_dict = defaultdict(list) for _loc in self.reinforcement_per_locations: - _infra_costs_dict[_loc.selected_measure].append( - _loc.get_infrastructure_costs(_loc.selected_measure) + _infra_costs_dict[_loc.current_selected_measure].append( + _loc.get_infrastructure_costs(_loc.current_selected_measure) ) # Sum the infra costs for each reinforcement type. diff --git a/koswat/cost_report/summary/koswat_summary_builder.py b/koswat/cost_report/summary/koswat_summary_builder.py index 9334c95f..63e654c1 100644 --- a/koswat/cost_report/summary/koswat_summary_builder.py +++ b/koswat/cost_report/summary/koswat_summary_builder.py @@ -1,6 +1,6 @@ import logging import math -from dataclasses import dataclass +from dataclasses import dataclass, field from koswat.configuration.settings.koswat_run_scenario_settings import ( KoswatRunScenarioSettings, @@ -28,11 +28,13 @@ ) from koswat.strategies.order_strategy.order_strategy import OrderStrategy from koswat.strategies.strategy_input import StrategyInput +from koswat.strategies.strategy_protocol import StrategyProtocol @dataclass class KoswatSummaryBuilder(BuilderProtocol): run_scenario_settings: KoswatRunScenarioSettings = None + strategy_type: type[StrategyProtocol] = field(default_factory=lambda: OrderStrategy) @staticmethod def _get_corrected_koswat_scenario( @@ -108,7 +110,7 @@ def _get_final_reinforcement_per_location( # In theory this will become a factory (somewhere) where # the adequate strategy will be chosen. - return OrderStrategy().apply_strategy(_strategy_input) + return self.strategy_type().apply_strategy(_strategy_input) def build(self) -> KoswatSummary: _summary = KoswatSummary() diff --git a/koswat/strategies/README.md b/koswat/strategies/README.md index 8309f17f..1e822f87 100644 --- a/koswat/strategies/README.md +++ b/koswat/strategies/README.md @@ -27,10 +27,11 @@ This modules contains the logic to choose which measure will be applied for a gi - `StrategyLocationReinforcement`, represents a mapped location to a selected measure. - location (`PointSurroundings`), a point (meter) in the dike traject. - - selected_measure (`Type[ReinforcementProfileProtocol]`), which is the reinforcement that should be applied to the location. + - current_selected_measure (`Type[ReinforcementProfileProtocol]`), which is the reinforcement that should be applied to the location. - available_measures (`list[Type[ReinforcementProfileProtocol]]`), which are the possible reinforcements that could be applied to the location. - strategy_location_input (`StrategyLocationInput`), the related input with available reinforcements and their costs related to this location-measure mapping. +- `StrategyStepAssignment`, helps keep track of the different `StrategyLocationReinforcement.current_selected_measure` values done at each strategy. ## Available strategies diff --git a/koswat/strategies/infra_priority_strategy/infra_cluster.py b/koswat/strategies/infra_priority_strategy/infra_cluster.py index f482c394..fb70abff 100644 --- a/koswat/strategies/infra_priority_strategy/infra_cluster.py +++ b/koswat/strategies/infra_priority_strategy/infra_cluster.py @@ -8,6 +8,7 @@ from koswat.strategies.strategy_location_reinforcement import ( StrategyLocationReinforcement, ) +from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum @dataclass @@ -75,4 +76,4 @@ def set_cheapest_common_available_measure( if _selection != self.reinforcement_type: self.reinforcement_type = _selection for _cd in self.cluster: - _cd.selected_measure = _selection + _cd.set_selected_measure(_selection, StrategyStepEnum.INFRASTRUCTURE) diff --git a/koswat/strategies/infra_priority_strategy/infra_priority_strategy.py b/koswat/strategies/infra_priority_strategy/infra_priority_strategy.py index 15588244..490b0335 100644 --- a/koswat/strategies/infra_priority_strategy/infra_priority_strategy.py +++ b/koswat/strategies/infra_priority_strategy/infra_priority_strategy.py @@ -114,7 +114,7 @@ def get_cluster_option( location_collection: list[StrategyLocationReinforcement], ) -> list[list[InfraCluster]]: _icc = [] - for _w_element in filter(len, location_collection): + for _w_element in filter(any, location_collection): _ic = InfraCluster( min_required_length=from_cluster.min_required_length, reinforcement_type=from_cluster.reinforcement_type, @@ -155,7 +155,7 @@ def _get_initial_state( ) -> Iterator[InfraCluster]: for _grouped_by, _grouping in groupby( order_strategy.apply_strategy(strategy_input), - key=lambda x: x.selected_measure, + key=lambda x: x.current_selected_measure, ): _grouping_data = list(_grouping) if not _grouping_data: diff --git a/koswat/strategies/order_strategy/order_cluster.py b/koswat/strategies/order_strategy/order_cluster.py index 5382e39b..a6adb9ae 100644 --- a/koswat/strategies/order_strategy/order_cluster.py +++ b/koswat/strategies/order_strategy/order_cluster.py @@ -6,6 +6,7 @@ from koswat.strategies.strategy_location_reinforcement import ( StrategyLocationReinforcement, ) +from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum @dataclass @@ -62,7 +63,7 @@ def extend_cluster(self, other: OrderCluster): """ Extends the current cluster with the reinforcements (`list[StrategyLocationReinforcement]`) from another cluster. - Modifies the `selected_measure` property of those measures being merged but it + Modifies the `current_selected_measure` property of those measures being merged but it does not remove them from their source cluster. Args: @@ -75,9 +76,9 @@ def extend_cluster(self, other: OrderCluster): logging.warning("Trying to extend cluster from an unrelated one.") if any(self.location_reinforcements): - _new_profile_type = self.location_reinforcements[0].selected_measure + _new_profile_type = self.location_reinforcements[0].current_selected_measure for _lr in other.location_reinforcements: - _lr.selected_measure = _new_profile_type + _lr.set_selected_measure(_new_profile_type, StrategyStepEnum.ORDERED) if self.left_neighbor == other: self.location_reinforcements = ( diff --git a/koswat/strategies/order_strategy/order_strategy.py b/koswat/strategies/order_strategy/order_strategy.py index 984460a3..6b79b2d9 100644 --- a/koswat/strategies/order_strategy/order_strategy.py +++ b/koswat/strategies/order_strategy/order_strategy.py @@ -24,6 +24,7 @@ ) from koswat.strategies.strategy_protocol import StrategyProtocol from koswat.strategies.strategy_reinforcement_input import StrategyReinforcementInput +from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum class OrderStrategy(StrategyProtocol): @@ -117,21 +118,40 @@ def get_strategy_reinforcements( strategy_locations: list[StrategyLocationInput], selection_order: list[type[ReinforcementProfileProtocol]], ) -> list[StrategyLocationReinforcement]: + """ + Gets the strategy representation of the locations with their available measures + ordered filtered and order by the provided `selection_order`. It also sets + their initial state. + + Args: + strategy_locations (list[StrategyLocationInput]): Locations to map into reinforcement locations. + selection_order (list[type[ReinforcementProfileProtocol]]): Priority order to assign a reinforcement. + + Returns: + list[StrategyLocationReinforcement]: Mapped location reinforcements. + """ _strategy_reinforcements = [] for _strategy_location in strategy_locations: - _reinforcements = _strategy_location.available_measures - _selected_reinforcement = next( - (_or for _or in selection_order if _or in _reinforcements), - selection_order[-1], - ) - _strategy_reinforcements.append( - StrategyLocationReinforcement( - location=_strategy_location.point_surrounding, - available_measures=_reinforcements, - selected_measure=_selected_reinforcement, - strategy_location_input=_strategy_location, - ) + # Create the strategy representation. + _slr = StrategyLocationReinforcement( + location=_strategy_location.point_surrounding, + available_measures=_strategy_location.available_measures, + filtered_measures=list( + filter( + lambda x: x in _strategy_location.available_measures, + selection_order, + ) + ), + strategy_location_input=_strategy_location, ) + + # Manually set the current selected measure if none available. + if not any(_slr.available_measures): + # TODO: Unclear why tests fail when setting this measure + # as the only available measure. + _slr.set_selected_measure(selection_order[-1], StrategyStepEnum.ORDERED) + + _strategy_reinforcements.append(_slr) return _strategy_reinforcements def apply_strategy( diff --git a/koswat/strategies/order_strategy/order_strategy_base.py b/koswat/strategies/order_strategy/order_strategy_base.py index 6b73850a..8774209b 100644 --- a/koswat/strategies/order_strategy/order_strategy_base.py +++ b/koswat/strategies/order_strategy/order_strategy_base.py @@ -19,7 +19,7 @@ def _get_reinforcement_groupings( (self.reinforcement_order.index(k), list(g)) for k, g in groupby( location_reinforcements, - lambda x: x.selected_measure, + lambda x: x.current_selected_measure, ) ) diff --git a/koswat/strategies/order_strategy/order_strategy_buffering.py b/koswat/strategies/order_strategy/order_strategy_buffering.py index 6474ea5c..4c8b193c 100644 --- a/koswat/strategies/order_strategy/order_strategy_buffering.py +++ b/koswat/strategies/order_strategy/order_strategy_buffering.py @@ -5,6 +5,7 @@ from koswat.strategies.strategy_location_reinforcement import ( StrategyLocationReinforcement, ) +from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum class OrderStrategyBuffering(OrderStrategyBase): @@ -69,4 +70,6 @@ def apply( # Apply buffer values. for _idx, _location in enumerate(location_reinforcements): - _location.selected_measure = self.reinforcement_order[_result_mask[_idx]] + _location.set_selected_measure( + self.reinforcement_order[_result_mask[_idx]], StrategyStepEnum.ORDERED + ) diff --git a/koswat/strategies/strategy_location_reinforcement.py b/koswat/strategies/strategy_location_reinforcement.py index c97c3588..3aa7c227 100644 --- a/koswat/strategies/strategy_location_reinforcement.py +++ b/koswat/strategies/strategy_location_reinforcement.py @@ -1,4 +1,4 @@ -from dataclasses import dataclass +from dataclasses import dataclass, field from koswat.dike.surroundings.point.point_surroundings import PointSurroundings from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( @@ -8,23 +8,63 @@ from koswat.strategies.strategy_reinforcement_type_costs import ( StrategyReinforcementTypeCosts, ) +from koswat.strategies.strategy_step.strategy_step_assignment import ( + StrategyStepAssignment, +) +from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum @dataclass class StrategyLocationReinforcement: + """ + Represents a location and the different reinforcements that can be applied to it + as well their costs. + This class is used to show the final chosen state for a location. + """ + location: PointSurroundings - selected_measure: type[ReinforcementProfileProtocol] - available_measures: list[type[ReinforcementProfileProtocol]] + # PHASED-OUT, this property should be removed once we confirm available measures + # are filtered by the order strategy (cost-space evaluation) + # use `filtered_measures` instead! + available_measures: list[type[ReinforcementProfileProtocol]] = field( + default_factory=lambda: [] + ) + filtered_measures: list[type[ReinforcementProfileProtocol]] = field( + default_factory=lambda: [] + ) strategy_location_input: StrategyLocationInput = None + _selected_measure_steps: list[StrategyStepAssignment] = field( + init=False, default_factory=lambda: [] + ) + + def __post_init__(self): + if any(self.filtered_measures): + # Set the inital selection to the first available measure. + self.set_selected_measure( + self.filtered_measures[0], StrategyStepEnum.INITIAL + ) + + @property + def current_selected_measure(self) -> type[ReinforcementProfileProtocol]: + """ + Exposes the current selected measure for this object. + """ + if not any(self._selected_measure_steps): + return None + return self._selected_measure_steps[-1]["step_value"] + @property def current_cost(self) -> float: - if not self.selected_measure or not self.strategy_location_input: + """ + Estimates the costs at this location for the given `current_selected_measure`. + """ + if not self.current_selected_measure or not self.strategy_location_input: return 0.0 for _srtc in self.strategy_location_input.strategy_reinforcement_type_costs: - if _srtc.reinforcement_type == self.selected_measure: + if _srtc.reinforcement_type == self.current_selected_measure: return _srtc.total_costs - raise ValueError("No current cost could be calculated") + return 0.0 @property def cheapest_reinforcement(self) -> StrategyReinforcementTypeCosts: @@ -32,6 +72,65 @@ def cheapest_reinforcement(self) -> StrategyReinforcementTypeCosts: return None return self.strategy_location_input.cheapest_reinforcement + def set_selected_measure( + self, + reinforcement_type: type[ReinforcementProfileProtocol], + step: StrategyStepEnum, + ): + """ + Changes the value reprsented in `current_selected_measure` and updates the + dictionary of selections (history). + + Args: + reinforcement_type (type[ReinforcementProfileProtocol]): Reinforcement type + step (StrategyStepsEnum): Step whose + """ + # Update the assigned value for this step. + # TODO: Eventually we want to remove from `filtered_measures` all measures with + # a lower index, something like: + # _from_idx = self._filtered_measures.index(reinforcement_type) + # self._filtered_measures = self._filtered_measures[_from_idx:] + self._selected_measure_steps.append( + StrategyStepAssignment( + step_type=step, + step_value=reinforcement_type, + ) + ) + + def get_selected_measure_steps( + self, + ) -> tuple[ + type[ReinforcementProfileProtocol], + type[ReinforcementProfileProtocol], + type[ReinforcementProfileProtocol], + ]: + """ + Outputs the selected measure following the domain (expected) steps: + - Initial step, + - Order step, + - Infrastructure step + + Returns: + tuple[ + type[ReinforcementProfileProtocol], + type[ReinforcementProfileProtocol], + type[ReinforcementProfileProtocol]]: Resulting tuple. + """ + + def filter_ordered_step(assignment_step: StrategyStepAssignment) -> bool: + return assignment_step["step_type"] == StrategyStepEnum.ORDERED + + _initial_step = self._selected_measure_steps[0] + _ordered_step = next( + filter(filter_ordered_step, self._selected_measure_steps[-1::-1]), + _initial_step, + ) + return ( + _initial_step["step_value"], + _ordered_step["step_value"], + self.current_selected_measure, + ) + def get_reinforcement_costs( self, reinforcement_type: type[ReinforcementProfileProtocol] ) -> float: diff --git a/koswat/strategies/strategy_step/__init__.py b/koswat/strategies/strategy_step/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/koswat/strategies/strategy_step/strategy_step_assignment.py b/koswat/strategies/strategy_step/strategy_step_assignment.py new file mode 100644 index 00000000..35d5fb4b --- /dev/null +++ b/koswat/strategies/strategy_step/strategy_step_assignment.py @@ -0,0 +1,11 @@ +from typing import TypedDict + +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( + ReinforcementProfileProtocol, +) +from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum + + +class StrategyStepAssignment(TypedDict): + step_type: StrategyStepEnum + step_value: type[ReinforcementProfileProtocol] diff --git a/koswat/strategies/strategy_step/strategy_step_enum.py b/koswat/strategies/strategy_step/strategy_step_enum.py new file mode 100644 index 00000000..213d0feb --- /dev/null +++ b/koswat/strategies/strategy_step/strategy_step_enum.py @@ -0,0 +1,7 @@ +from enum import Enum + + +class StrategyStepEnum(Enum): + INITIAL = 0 + ORDERED = 1 + INFRASTRUCTURE = 2 diff --git a/tests/cost_report/io/summary/conftest.py b/tests/cost_report/io/summary/conftest.py index d7e6a28b..a9e2815d 100644 --- a/tests/cost_report/io/summary/conftest.py +++ b/tests/cost_report/io/summary/conftest.py @@ -30,7 +30,6 @@ PipingWallReinforcementProfile, SoilReinforcementProfile, StabilityWallReinforcementProfile, - VPSReinforcementProfile, ) from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( ReinforcementProfileProtocol, @@ -143,16 +142,15 @@ def get_locations_reinforcements( for _lp_report in summary.locations_profile_report_list if _location in _lp_report.report_locations ) - _selected_measure = _available_reinforcements[-1] - if any(_a_measures): - _selected_measure = _a_measures[0] - _matrix.append( - StrategyLocationReinforcement( - location=_location, - available_measures=_a_measures, - selected_measure=_selected_measure, - ) + + _slr = StrategyLocationReinforcement( + location=_location, + available_measures=_a_measures, + filtered_measures=_a_measures + if any(_a_measures) + else [_available_reinforcements[-1]], ) + _matrix.append(_slr) return _matrix @@ -213,8 +211,8 @@ def add_cluster_location( ) -> StrategyLocationReinforcement: return StrategyLocationReinforcement( location=PointSurroundings(location=Point(coordinates)), - selected_measure=reinforced_profile, - available_measures=[], + available_measures=[reinforced_profile], + filtered_measures=[reinforced_profile], ) def create_cluster( diff --git a/tests/cost_report/io/summary/summary_costs/test_cluster_collection_shp_fom.py b/tests/cost_report/io/summary/summary_costs/test_cluster_collection_shp_fom.py index d950075f..0d01cb1a 100644 --- a/tests/cost_report/io/summary/summary_costs/test_cluster_collection_shp_fom.py +++ b/tests/cost_report/io/summary/summary_costs/test_cluster_collection_shp_fom.py @@ -5,6 +5,7 @@ from koswat.cost_report.io.summary.summary_locations.cluster_collection_shp_fom import ( ClusterCollectionShpFom, + ClusterGeoDataFrameOutputFom, ) from koswat.cost_report.io.summary.summary_locations.cluster_shp_fom import ( ClusterShpFom, @@ -67,7 +68,7 @@ def test_given_clusters_when_generate_geodataframes_then_gets_expected_gdf( _gdf_collection = _cluster_collection.generate_geodataframes() # 3. Verify xpectations. - assert len(_gdf_collection) == 3 + assert isinstance(_gdf_collection, ClusterGeoDataFrameOutputFom) def check_gdf( gdf_result: GeoDataFrame, @@ -93,14 +94,14 @@ def check_gdf( assert _cluster_value[4] == geometry_lambda(_ref_data) check_gdf( - _gdf_collection[0], + _gdf_collection.base_layer, lambda c_fom: c_fom.base_geometry, ) check_gdf( - _gdf_collection[1], + _gdf_collection.initial_state, lambda c_fom: c_fom.get_buffered_geometry(c_fom.old_profile_width), ) check_gdf( - _gdf_collection[2], + _gdf_collection.new_state, lambda c_fom: c_fom.get_buffered_geometry(c_fom.new_profile_width), ) diff --git a/tests/cost_report/io/summary/summary_costs/test_summary_locations_shp_exporter.py b/tests/cost_report/io/summary/summary_costs/test_summary_locations_shp_exporter.py index ba2c3d03..aa3f12bf 100644 --- a/tests/cost_report/io/summary/summary_costs/test_summary_locations_shp_exporter.py +++ b/tests/cost_report/io/summary/summary_costs/test_summary_locations_shp_exporter.py @@ -32,4 +32,4 @@ def test_summary_locations_shp_exporter_export( # 3. Verify expectations. assert _test_dir.exists() _shp_files = list(_test_dir.glob("*.shp")) - assert len(_shp_files) == 3 + assert len(_shp_files) == 4 diff --git a/tests/cost_report/io/summary/summary_locations/test_cluster_collection_shp_fom.py b/tests/cost_report/io/summary/summary_locations/test_cluster_collection_shp_fom.py new file mode 100644 index 00000000..58eb6d2d --- /dev/null +++ b/tests/cost_report/io/summary/summary_locations/test_cluster_collection_shp_fom.py @@ -0,0 +1,59 @@ +from copy import deepcopy +from typing import Iterator + +import pytest + +from koswat.cost_report.io.summary.summary_locations.cluster_collection_shp_fom import ( + ClusterCollectionShpFom, +) +from koswat.cost_report.io.summary.summary_locations.cluster_geodataframe_output_fom import ( + ClusterGeoDataFrameOutputFom, +) +from koswat.cost_report.io.summary.summary_locations.cluster_shp_fom import ( + ClusterShpFom, +) +from koswat.cost_report.summary.koswat_summary import KoswatSummary + + +class TestClustercollectionShpFom: + def test_initialize(self): + # 1. Define test data + _fom = ClusterCollectionShpFom() + + # 2. Verify expectations + assert isinstance(_fom, ClusterCollectionShpFom) + assert not _fom.clusters + assert _fom.crs_projection == "EPSG:28992" + + def test_from_summary(self, valid_mocked_summary: KoswatSummary): + # 1. Run test. + _fom = ClusterCollectionShpFom.from_summary(valid_mocked_summary) + + # 2. Verify expectations + assert isinstance(_fom, ClusterCollectionShpFom) + assert any(_fom.clusters) + assert all(map(lambda x: isinstance(x, ClusterShpFom), _fom.clusters)) + + @pytest.fixture(name="valid_fom") + def _get_valid_cluster_collection_shp_fom( + self, valid_mocked_summary: KoswatSummary + ) -> Iterator[ClusterCollectionShpFom]: + _fom = ClusterCollectionShpFom.from_summary(valid_mocked_summary) + for _cluster in _fom.clusters: + _locations = [_cl for _cl in _cluster.locations] + for _l in _locations: + _cluster.locations.append(deepcopy(_l)) + yield _fom + + def test_given_valid_fom_generate_geodataframes( + self, valid_fom: ClusterCollectionShpFom + ): + # 1. Define test data. + assert any(valid_fom.clusters) + + # 2. Run test. + _gdf_output = valid_fom.generate_geodataframes() + + # 3. Verify expectations. + assert isinstance(_gdf_output, ClusterGeoDataFrameOutputFom) + assert _gdf_output.is_valid() diff --git a/tests/cost_report/io/summary/summary_locations/test_cluster_geodataframe_output_fom.py b/tests/cost_report/io/summary/summary_locations/test_cluster_geodataframe_output_fom.py new file mode 100644 index 00000000..471e6a74 --- /dev/null +++ b/tests/cost_report/io/summary/summary_locations/test_cluster_geodataframe_output_fom.py @@ -0,0 +1,34 @@ +from geopandas import GeoDataFrame + +from koswat.cost_report.io.summary.summary_locations.cluster_geodataframe_output_fom import ( + ClusterGeoDataFrameOutputFom, +) + + +class TestClusterGeodataframeOutputFom: + def test_initialize_with_none_tuple(self): + # 1. Run test. + _fom = ClusterGeoDataFrameOutputFom(None) + + # 2. Verify expectations. + assert _fom.is_valid() is False + assert _fom.base_layer is None + assert _fom.initial_state is None + assert _fom.new_state is None + + def test_initialize_with_valid_tuple(self): + # 1. Define test data + _base_value = GeoDataFrame() + _initial_value = GeoDataFrame() + _new_value = GeoDataFrame() + + # 2. Run test. + _fom = ClusterGeoDataFrameOutputFom( + tuple((_base_value, _initial_value, _new_value)) + ) + + # 3. Verify expectations. + assert _fom.is_valid() + assert _fom.base_layer.equals(_base_value) + assert _fom.initial_state.equals(_initial_value) + assert _fom.new_state.equals(_new_value) diff --git a/tests/cost_report/io/summary/summary_locations/test_summary_locations_csv_exporter.py b/tests/cost_report/io/summary/summary_locations/test_summary_locations_csv_exporter.py index 6b86e689..715daa97 100644 --- a/tests/cost_report/io/summary/summary_locations/test_summary_locations_csv_exporter.py +++ b/tests/cost_report/io/summary/summary_locations/test_summary_locations_csv_exporter.py @@ -31,9 +31,9 @@ def test_summary_locations_csv_exporter_export( # 3. Validate results assert _export_path.exists() _read_text = _export_path.read_text(encoding="utf-8") - _expected_text = """Section;X coord;Y coord;Kistdam;Kwelscherm;Grondmaatregel profiel;Stabiliteitswand;Selected reinforcement -A;0.24;0.42;0;1;1;1;Kwelscherm -A;2.4;0.42;0;0;1;1;Grondmaatregel profiel -A;0.24;2.4;0;0;0;1;Stabiliteitswand -A;2.4;2.4;0;0;0;0;Stabiliteitswand""" + _expected_text = """Section;X coord;Y coord;Kistdam;Kwelscherm;Grondmaatregel profiel;Stabiliteitswand;Initial selection;Ordered selection;Optimized selection +A;0.24;0.42;0;1;1;1;Kwelscherm;Kwelscherm;Kwelscherm +A;2.4;0.42;0;0;1;1;Grondmaatregel profiel;Grondmaatregel profiel;Grondmaatregel profiel +A;0.24;2.4;0;0;0;1;Stabiliteitswand;Stabiliteitswand;Stabiliteitswand +A;2.4;2.4;0;0;0;0;Stabiliteitswand;Stabiliteitswand;Stabiliteitswand""" assert _expected_text == _read_text diff --git a/tests/strategies/conftest.py b/tests/strategies/conftest.py index 00424144..d8811e88 100644 --- a/tests/strategies/conftest.py +++ b/tests/strategies/conftest.py @@ -124,8 +124,8 @@ def _get_example_location_reinforcements_with_buffering( _location_reinforcements.append( StrategyLocationReinforcement( location=_location, - selected_measure=_measure_order[_measure_idx], - available_measures=[], + available_measures=[_measure_order[_measure_idx]], + filtered_measures=[_measure_order[_measure_idx]], ) ) diff --git a/tests/strategies/infra_priority_stratregy/test_infra_cluster.py b/tests/strategies/infra_priority_stratregy/test_infra_cluster.py index 26f81472..b6171ab3 100644 --- a/tests/strategies/infra_priority_stratregy/test_infra_cluster.py +++ b/tests/strategies/infra_priority_stratregy/test_infra_cluster.py @@ -91,13 +91,12 @@ def test_set_cheapest_common_available_measure(self, cluster_fixture: InfraClust PipingWallReinforcementProfile: 42, } assert cluster_fixture.reinforcement_type == SoilReinforcementProfile - cluster_fixture.cluster = [ - StrategyLocationReinforcement( - location=None, - selected_measure=cluster_fixture.reinforcement_type, - available_measures=[], - ) - ] * cluster_fixture.min_required_length + _slr = StrategyLocationReinforcement( + location=None, + filtered_measures=[cluster_fixture.reinforcement_type], + available_measures=[cluster_fixture.reinforcement_type], + ) + cluster_fixture.cluster = [_slr] * cluster_fixture.min_required_length assert cluster_fixture.is_valid() # 2. Run test. @@ -105,6 +104,6 @@ def test_set_cheapest_common_available_measure(self, cluster_fixture: InfraClust # 3. Verify expectations. assert all( - c.selected_measure == PipingWallReinforcementProfile + c.current_selected_measure == PipingWallReinforcementProfile for c in cluster_fixture.cluster ) diff --git a/tests/strategies/infra_priority_stratregy/test_infra_cluster_option.py b/tests/strategies/infra_priority_stratregy/test_infra_cluster_option.py index 04fb3612..bbc3a9bd 100644 --- a/tests/strategies/infra_priority_stratregy/test_infra_cluster_option.py +++ b/tests/strategies/infra_priority_stratregy/test_infra_cluster_option.py @@ -83,8 +83,8 @@ def _get_valid_option_fixture(self) -> Iterator[InfraClusterOption]: cluster=[ StrategyLocationReinforcement( location=None, - selected_measure=SoilReinforcementProfile, - available_measures=[], + available_measures=[SoilReinforcementProfile], + filtered_measures=[SoilReinforcementProfile], ) ], ), diff --git a/tests/strategies/infra_priority_stratregy/test_infra_priority_strategy.py b/tests/strategies/infra_priority_stratregy/test_infra_priority_strategy.py index ce7e36b2..ee7b69a9 100644 --- a/tests/strategies/infra_priority_stratregy/test_infra_priority_strategy.py +++ b/tests/strategies/infra_priority_stratregy/test_infra_priority_strategy.py @@ -68,11 +68,11 @@ def test_given_example_when_apply_strategy_then_gets_new_ones( # Basically the same checks as in `test__apply_min_distance_given_example`. assert all( - _sr.selected_measure == PipingWallReinforcementProfile + _sr.current_selected_measure == PipingWallReinforcementProfile for _sr in _strategy_result[0:2] ) assert all( - _sr.selected_measure == CofferdamReinforcementProfile + _sr.current_selected_measure == CofferdamReinforcementProfile for _sr in _strategy_result[2:] ) @@ -94,15 +94,15 @@ def test_given_example_for_subclusters_when_apply_strategy_then_splits_them( # Basically the same checks as in `test__apply_min_distance_given_example`. assert all( - _sr.selected_measure == PipingWallReinforcementProfile + _sr.current_selected_measure == PipingWallReinforcementProfile for _sr in _strategy_result[0:2] ) assert all( - _sr.selected_measure == StabilityWallReinforcementProfile + _sr.current_selected_measure == StabilityWallReinforcementProfile for _sr in _strategy_result[2:5] ) assert all( - _sr.selected_measure == CofferdamReinforcementProfile + _sr.current_selected_measure == CofferdamReinforcementProfile for _sr in _strategy_result[5:] ) @@ -185,18 +185,23 @@ def _get_infra_cluster_for_subclusters_fixture(self) -> Iterator[InfraCluster]: ), ], ) + + _cluster_data = [] + for _available_measures in _available_measures_per_location: + _slr = StrategyLocationReinforcement( + location=None, + available_measures=_available_measures, + filtered_measures=_available_measures + if any(_available_measures) + else [SoilReinforcementProfile], + strategy_location_input=_location_input, + ) + _cluster_data.append(_slr) + yield InfraCluster( reinforcement_type=SoilReinforcementProfile, min_required_length=2, - cluster=[ - StrategyLocationReinforcement( - location=None, - selected_measure=SoilReinforcementProfile, - available_measures=_available_measures, - strategy_location_input=_location_input, - ) - for _available_measures in _available_measures_per_location - ], + cluster=_cluster_data, ) def test_given_cluster_when_generate_sbucluster_options_returns( diff --git a/tests/strategies/order_strategy/test_order_cluster.py b/tests/strategies/order_strategy/test_order_cluster.py index 284778fb..08575983 100644 --- a/tests/strategies/order_strategy/test_order_cluster.py +++ b/tests/strategies/order_strategy/test_order_cluster.py @@ -52,8 +52,8 @@ def _get_order_cluster_with_neighbors( for _idx in range(0, 4): _dummy_location = StrategyLocationReinforcement( location=PointSurroundings(section="test", traject_order=_idx), - selected_measure=[], available_measures=[], + filtered_measures=[], ) basic_order_cluster.location_reinforcements.append(_dummy_location) @@ -166,8 +166,8 @@ def test_extend_cluster_updates_values_to_the_left( _merging_to = order_cluster_with_neighbors.left_neighbor _single_location = StrategyLocationReinforcement( location=PointSurroundings(), - selected_measure=_selected_measure_value, - available_measures=[], + available_measures=[_selected_measure_value], + filtered_measures=[_selected_measure_value], ) _merging_to.location_reinforcements = [_single_location] @@ -178,7 +178,7 @@ def test_extend_cluster_updates_values_to_the_left( # 3. Verify expectations assert all( - lr.selected_measure == _selected_measure_value + lr.current_selected_measure == _selected_measure_value for lr in order_cluster_with_neighbors.location_reinforcements ) assert _merging_to.right_neighbor == order_cluster_with_neighbors.right_neighbor @@ -196,9 +196,10 @@ def test_extend_cluster_updates_values_to_the_right( _merging_to = order_cluster_with_neighbors.right_neighbor _single_location = StrategyLocationReinforcement( location=PointSurroundings(), - selected_measure=_selected_measure_value, - available_measures=[], + available_measures=[_selected_measure_value], + filtered_measures=[_selected_measure_value], ) + _merging_to.location_reinforcements = [_single_location] # 2. Run test. @@ -208,7 +209,7 @@ def test_extend_cluster_updates_values_to_the_right( # 3. Verify expectations assert all( - lr.selected_measure == _selected_measure_value + lr.current_selected_measure == _selected_measure_value for lr in order_cluster_with_neighbors.location_reinforcements ) assert _merging_to.left_neighbor == order_cluster_with_neighbors.left_neighbor diff --git a/tests/strategies/order_strategy/test_order_strategy.py b/tests/strategies/order_strategy/test_order_strategy.py index 51d49c05..adb7ffe2 100644 --- a/tests/strategies/order_strategy/test_order_strategy.py +++ b/tests/strategies/order_strategy/test_order_strategy.py @@ -9,6 +9,9 @@ StabilityWallReinforcementProfile, VPSReinforcementProfile, ) +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( + ReinforcementProfileProtocol, +) from koswat.strategies.order_strategy.order_strategy import OrderStrategy from koswat.strategies.order_strategy.order_strategy_base import OrderStrategyBase from koswat.strategies.strategy_input import StrategyInput @@ -115,7 +118,7 @@ def test_get_strategy_order_increased_surface_filters_reinforcement( assert _reinforcements == _expected_result assert _reinforcements[-1] == CofferdamReinforcementProfile - def test__get_strategy_reinforcements_given_example( + def test_get_strategy_reinforcements_given_example( self, example_strategy_input: StrategyInput ): # 1. Define test data. @@ -123,24 +126,37 @@ def test__get_strategy_reinforcements_given_example( assert _default_order[-1] == CofferdamReinforcementProfile # 2. Run test. - _reinforcements = OrderStrategy.get_strategy_reinforcements( + _location_reinforcements = OrderStrategy.get_strategy_reinforcements( example_strategy_input.strategy_locations, _default_order ) # 3. Verify expectations - assert isinstance(_reinforcements, list) - assert len(_reinforcements) == len(example_strategy_input.strategy_locations) + assert isinstance(_location_reinforcements, list) + assert len(_location_reinforcements) == len( + example_strategy_input.strategy_locations + ) + assert all( + isinstance(_lr, StrategyLocationReinforcement) + for _lr in _location_reinforcements + ) - def assert_subset_selected_measure(selected_measure: type, subset: list): - assert all(_r.selected_measure == selected_measure for _r in subset) + def assert_subset_selected_measure( + selected_measure: type[ReinforcementProfileProtocol], + subset: list[StrategyLocationReinforcement], + ): + assert all(_r.current_selected_measure == selected_measure for _r in subset) - assert_subset_selected_measure(SoilReinforcementProfile, _reinforcements[:3]) assert_subset_selected_measure( - StabilityWallReinforcementProfile, _reinforcements[3:5] + SoilReinforcementProfile, _location_reinforcements[:3] + ) + assert_subset_selected_measure( + StabilityWallReinforcementProfile, _location_reinforcements[3:5] + ) + assert_subset_selected_measure( + SoilReinforcementProfile, _location_reinforcements[5:8] ) - assert_subset_selected_measure(SoilReinforcementProfile, _reinforcements[5:8]) assert_subset_selected_measure( - CofferdamReinforcementProfile, _reinforcements[8:] + CofferdamReinforcementProfile, _location_reinforcements[8:] ) def test__get_reinforcement_clusters_given_example( @@ -192,14 +208,14 @@ def test_apply_strategy_given_example(self, example_strategy_input: StrategyInpu # Basically the same checks as in `test__apply_min_distance_given_example`. assert all( - _sr.selected_measure == SoilReinforcementProfile + _sr.current_selected_measure == SoilReinforcementProfile for _sr in _strategy_result[0:2] ) assert all( - _sr.selected_measure == StabilityWallReinforcementProfile + _sr.current_selected_measure == StabilityWallReinforcementProfile for _sr in _strategy_result[2:7] ) assert all( - _sr.selected_measure == CofferdamReinforcementProfile + _sr.current_selected_measure == CofferdamReinforcementProfile for _sr in _strategy_result[7:] ) diff --git a/tests/strategies/order_strategy/test_order_strategy_buffering.py b/tests/strategies/order_strategy/test_order_strategy_buffering.py index 0871d5d4..368eb66c 100644 --- a/tests/strategies/order_strategy/test_order_strategy_buffering.py +++ b/tests/strategies/order_strategy/test_order_strategy_buffering.py @@ -34,7 +34,7 @@ def test_apply_given_docs_example(self, example_strategy_input: StrategyInput): # 3. Verify expectations. assert all( - _r.selected_measure == _expected_result[_r_idx] + _r.current_selected_measure == _expected_result[_r_idx] for _r_idx, _r in enumerate(_reinforcements) ) diff --git a/tests/strategies/order_strategy/test_order_strategy_clustering.py b/tests/strategies/order_strategy/test_order_strategy_clustering.py index d962db51..e045be47 100644 --- a/tests/strategies/order_strategy/test_order_strategy_clustering.py +++ b/tests/strategies/order_strategy/test_order_strategy_clustering.py @@ -46,15 +46,15 @@ def test_apply_given_example_docs( # 3. Verify expectations. assert all( - _sr.selected_measure == SoilReinforcementProfile + _sr.current_selected_measure == SoilReinforcementProfile for _sr in example_location_reinforcements_with_buffering[0:2] ) assert all( - _sr.selected_measure == StabilityWallReinforcementProfile + _sr.current_selected_measure == StabilityWallReinforcementProfile for _sr in example_location_reinforcements_with_buffering[2:7] ) assert all( - _sr.selected_measure == CofferdamReinforcementProfile + _sr.current_selected_measure == CofferdamReinforcementProfile for _sr in example_location_reinforcements_with_buffering[7:] ) @@ -75,24 +75,26 @@ def test_apply_given_cluster_with_lower_type( # Set all locations to the lowest type: for location_reinforcement in _location_reinforcements: - location_reinforcement.selected_measure = _strategy.reinforcement_order[0] + location_reinforcement.set_selected_measure( + _strategy.reinforcement_order[0], None + ) # Create an isolated cluster in the middle. _mid_cluster = len(_location_reinforcements) // 2 - _location_reinforcements[ - _mid_cluster - ].selected_measure = _strategy.reinforcement_order[1] + _location_reinforcements[_mid_cluster].set_selected_measure( + _strategy.reinforcement_order[1], None + ) # 2. Run test. _strategy.apply(example_location_reinforcements_with_buffering) # 3. Verify expectations. assert ( - _location_reinforcements[_mid_cluster].selected_measure + _location_reinforcements[_mid_cluster].current_selected_measure == _strategy.reinforcement_order[1] ) assert all( - _sr.selected_measure == _strategy.reinforcement_order[0] + _sr.current_selected_measure == _strategy.reinforcement_order[0] for _sr in _location_reinforcements[0:_mid_cluster] + _location_reinforcements[_mid_cluster + 1 :] ) diff --git a/tests/strategies/test_strategy_location_reinforcement.py b/tests/strategies/test_strategy_location_reinforcement.py new file mode 100644 index 00000000..dc60060a --- /dev/null +++ b/tests/strategies/test_strategy_location_reinforcement.py @@ -0,0 +1,173 @@ +from typing import Iterator + +import pytest + +from koswat.dike_reinforcements.reinforcement_profile.outside_slope.cofferdam_reinforcement_profile import ( + CofferdamReinforcementProfile, +) +from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile import ( + ReinforcementProfile, +) +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.dike_reinforcements.reinforcement_profile.standard.vps_reinforcement_profile import ( + VPSReinforcementProfile, +) +from koswat.strategies.strategy_location_reinforcement import ( + StrategyLocationReinforcement, +) +from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum + + +class TestStrategyLocationReinforcement: + def test_initialize(self): + # 1. Define test data. + _slr = StrategyLocationReinforcement(location=None) + + # 2. Verify expectations. + assert isinstance(_slr, StrategyLocationReinforcement) + assert not _slr.filtered_measures + assert not _slr.available_measures + assert _slr.location is None + assert _slr.current_selected_measure is None + assert _slr.cheapest_reinforcement is None + assert _slr.current_cost == 0.0 + + @pytest.fixture(name="basic_valid_slr") + def _get_basic_valid_strategy_location_reinforcement_fixture( + self, + example_location_reinforcements_with_buffering: list[ + StrategyLocationReinforcement + ], + ) -> Iterator[StrategyLocationReinforcement]: + assert any(example_location_reinforcements_with_buffering) + yield example_location_reinforcements_with_buffering[0] + + def test_set_selected_measure_updates_current_selected_measure( + self, basic_valid_slr: StrategyLocationReinforcement + ): + # 1. Define test data. + _new_selection = CofferdamReinforcementProfile + assert basic_valid_slr.current_selected_measure != _new_selection + + # 2. Run test. + basic_valid_slr.set_selected_measure(_new_selection, None) + + # 3. Verify expectations. + assert basic_valid_slr.current_selected_measure == _new_selection + + def test_given_only_initial_step_get_selected_measure_steps_return_all( + self, basic_valid_slr: StrategyLocationReinforcement + ): + # 1. Define test data. + assert len(basic_valid_slr._selected_measure_steps) == 1 + + # 2. Run test. + _steps = basic_valid_slr.get_selected_measure_steps() + + # 3. Verify expectations. + assert len(_steps) == 3 + assert all(_s == basic_valid_slr.current_selected_measure for _s in _steps) + + def _add_extra_steps( + self, + slr: StrategyLocationReinforcement, + step_type: StrategyStepEnum, + steps: list[type[ReinforcementProfileProtocol]], + ): + for _step in steps: + slr.set_selected_measure(_step, step_type) + + def test_given_extra_ordered_steps_get_selected_measure_steps_return_last_of_them( + self, + basic_valid_slr: StrategyLocationReinforcement, + ): + # 1. Define test data + assert len(basic_valid_slr._selected_measure_steps) == 1 + + _expected_initial_value = SoilReinforcementProfile + _new_step_value = CofferdamReinforcementProfile + assert basic_valid_slr.current_selected_measure == _expected_initial_value + + # 2. Run test. + self._add_extra_steps( + basic_valid_slr, + StrategyStepEnum.ORDERED, + [ + PipingWallReinforcementProfile, + StabilityWallReinforcementProfile, + _new_step_value, + ], + ) + _steps = basic_valid_slr.get_selected_measure_steps() + + # 3. Verify expectations. + assert len(_steps) == 3 + assert _steps[0] == _expected_initial_value + assert _steps[1] == _new_step_value + assert _steps[2] == _new_step_value + + def test_given_extra_order_steps_get_selected_measure_steps_return_all( + self, + basic_valid_slr: StrategyLocationReinforcement, + ): + # 1. Define test data + assert len(basic_valid_slr._selected_measure_steps) == 1 + + _expected_initial_value = SoilReinforcementProfile + _new_step_value = CofferdamReinforcementProfile + assert basic_valid_slr.current_selected_measure == _expected_initial_value + + # 2. Run test. + self._add_extra_steps( + basic_valid_slr, + StrategyStepEnum.INFRASTRUCTURE, + [StabilityWallReinforcementProfile, _new_step_value], + ) + _steps = basic_valid_slr.get_selected_measure_steps() + + # 3. Verify expectations. + assert len(_steps) == 3 + assert _steps[0] == _expected_initial_value + assert _steps[1] == _expected_initial_value + assert _steps[2] == _new_step_value + + def test_given_extra_order_and_infra_steps_get_selected_measure_steps_return_all( + self, + basic_valid_slr: StrategyLocationReinforcement, + ): + # 1. Define test data + assert len(basic_valid_slr._selected_measure_steps) == 1 + + _expected_initial_value = SoilReinforcementProfile + _new_step_value = CofferdamReinforcementProfile + assert basic_valid_slr.current_selected_measure == _expected_initial_value + + # 2. Run test. + self._add_extra_steps( + basic_valid_slr, + StrategyStepEnum.ORDERED, + [VPSReinforcementProfile, PipingWallReinforcementProfile], + ) + self._add_extra_steps( + basic_valid_slr, + StrategyStepEnum.INFRASTRUCTURE, + [StabilityWallReinforcementProfile, _new_step_value], + ) + _steps = basic_valid_slr.get_selected_measure_steps() + + # 3. Verify expectations. + assert len(_steps) == 3 + assert _steps[0] == _expected_initial_value + assert _steps[1] == PipingWallReinforcementProfile + assert _steps[2] == _new_step_value diff --git a/tests/test_acceptance.py b/tests/test_acceptance.py index 6858847a..c0fc4c59 100644 --- a/tests/test_acceptance.py +++ b/tests/test_acceptance.py @@ -58,6 +58,9 @@ from koswat.dike.profile import KoswatProfileBase, KoswatProfileBuilder from koswat.dike.surroundings.wrapper.surroundings_wrapper import SurroundingsWrapper from koswat.dike_reinforcements import ReinforcementProfileBuilderFactory +from koswat.strategies.infra_priority_strategy.infra_priority_strategy import ( + InfraPriorityStrategy, +) from tests import ( get_fixturerequest_case_name, get_testcase_results_dir, @@ -223,7 +226,9 @@ def test_koswat_run_as_sandbox_with_obstacles_and_infrastructures( ) # 2. Run test. - _summary = KoswatSummaryBuilder(run_scenario_settings=_run_settings).build() + _summary = KoswatSummaryBuilder( + run_scenario_settings=_run_settings, strategy_type=InfraPriorityStrategy + ).build() assert isinstance(_summary, KoswatSummary) # 3. Verify expectations. diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_1a_dh_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_1a_dh_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_1a_dh_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_1a_dh_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_1b_ds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_1b_ds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_1b_ds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_1b_ds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_1c_dp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_1c_dp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_1c_dp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_1c_dp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_1d_dhds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_1d_dhds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_1d_dhds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_1d_dhds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_1e_dhdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_1e_dhdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_1e_dhdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_1e_dhdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_1f_dsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_1f_dsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_1f_dsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_1f_dsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_1g_dhdsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_1g_dhdsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_1g_dhdsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_1g_dhdsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_2a_dh_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_2a_dh_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_2a_dh_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_2a_dh_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_2b_ds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_2b_ds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_2b_ds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_2b_ds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_2c_dp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_2c_dp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_2c_dp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_2c_dp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_2d_dhds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_2d_dhds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_2d_dhds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_2d_dhds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_2e_dhdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_2e_dhdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_2e_dhdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_2e_dhdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_2f_dsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_2f_dsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_2f_dsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_2f_dsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk1_2g_dhdsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk1_2g_dhdsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk1_2g_dhdsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk1_2g_dhdsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_1a_dh_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_1a_dh_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_1a_dh_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_1a_dh_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_1b_ds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_1b_ds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_1b_ds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_1b_ds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_1c_dp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_1c_dp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_1c_dp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_1c_dp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_1d_dhds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_1d_dhds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_1d_dhds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_1d_dhds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_1e_dhdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_1e_dhdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_1e_dhdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_1e_dhdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_1f_dsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_1f_dsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_1f_dsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_1f_dsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_1g_dhdsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_1g_dhdsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_1g_dhdsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_1g_dhdsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_2a_dh_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_2a_dh_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_2a_dh_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_2a_dh_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_2b_ds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_2b_ds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_2b_ds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_2b_ds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_2c_dp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_2c_dp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_2c_dp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_2c_dp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_2d_dhds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_2d_dhds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_2d_dhds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_2d_dhds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_2e_dhdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_2e_dhdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_2e_dhdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_2e_dhdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_2f_dsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_2f_dsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_2f_dsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_2f_dsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk2_2g_dhdsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk2_2g_dhdsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk2_2g_dhdsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk2_2g_dhdsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_1a_dh_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_1a_dh_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_1a_dh_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_1a_dh_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_1b_ds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_1b_ds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_1b_ds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_1b_ds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_1c_dp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_1c_dp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_1c_dp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_1c_dp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_1d_dhds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_1d_dhds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_1d_dhds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_1d_dhds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_1e_dhdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_1e_dhdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_1e_dhdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_1e_dhdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_1f_dsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_1f_dsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_1f_dsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_1f_dsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_1g_dhdsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_1g_dhdsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_1g_dhdsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_1g_dhdsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_2a_dh_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_2a_dh_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_2a_dh_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_2a_dh_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_2b_ds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_2b_ds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_2b_ds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_2b_ds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_2c_dp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_2c_dp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_2c_dp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_2c_dp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_2d_dhds_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_2d_dhds_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_2d_dhds_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_2d_dhds_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_2e_dhdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_2e_dhdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_2e_dhdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_2e_dhdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_2f_dsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_2f_dsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_2f_dsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_2f_dsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/case_dijk3_2g_dhdsdp_with_default_layers/summary_locations.csv b/tests/test_data/acceptance_reference_data/case_dijk3_2g_dhdsdp_with_default_layers/summary_locations.csv index 066a04f3..e8e54718 100644 --- a/tests/test_data/acceptance_reference_data/case_dijk3_2g_dhdsdp_with_default_layers/summary_locations.csv +++ b/tests/test_data/acceptance_reference_data/case_dijk3_2g_dhdsdp_with_default_layers/summary_locations.csv @@ -1 +1 @@ -Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Selected reinforcement +Section;X coord;Y coord;Grondmaatregel profiel;Verticale piping oplossing;Kwelscherm;Stabiliteitswand;Kistdam;Initial selection;Ordered selection;Optimized selection diff --git a/tests/test_data/acceptance_reference_data/sync_test_results.py b/tests/test_data/acceptance_reference_data/sync_test_results.py index 34148757..8abc4400 100644 --- a/tests/test_data/acceptance_reference_data/sync_test_results.py +++ b/tests/test_data/acceptance_reference_data/sync_test_results.py @@ -2,10 +2,9 @@ from pathlib import Path from shutil import copy2, copytree, rmtree -_test_data_path = Path(getcwd()).joinpath(r"tests\test_data\acceptance_reference_data") -_test_results_path = Path(getcwd()).joinpath( - r"tests\test_results\sandbox_acceptance_case" -) +_tests_dir = Path(getcwd()).joinpath("tests") +_test_data_path = _tests_dir.joinpath("test_data", "acceptance_reference_data") +_test_results_path = _tests_dir.joinpath("test_results", "sandbox_acceptance_case") _test_result_folders = [f for f in _test_results_path.iterdir() if f.is_dir()] diff --git a/tests/test_main.py b/tests/test_main.py index c9a2956d..f0dd160f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -20,11 +20,15 @@ def test_given_invalid_path_raises_value_error(self): assert _invalid_path == str(_run_result.exc_info[1]) def test_given_valid_input_succeeds(self): + """ + NOTE: This test is used as output reference in `koswat_cost_report.md`. + Keep it in mind when updating the reference data! + """ # 1. Define test data. - _valid_path = test_data / "acceptance" / "koswat_general.ini" + _valid_path = test_data.joinpath("acceptance", "koswat_general.ini") assert _valid_path.is_file() # Ensure we have a clean results dir. - _results_dir = test_results / "acceptance" + _results_dir = test_results.joinpath("acceptance") if _results_dir.exists(): shutil.rmtree(_results_dir) _results_dir.mkdir(parents=True)