Strategies¶
StrategyLocationInput
dataclass
¶
available_measures: list[type[ReinforcementProfileProtocol]]
property
¶
Gets all the available reinforcement types in strategy_location_reinforcements.
It is called available_measures to match the StrategyLocationReinforcement
definition.
| Returns: |
|
|---|
cheapest_reinforcement: StrategyReinforcementTypeCosts
property
¶
Gets the StrategyLocationReinforcementCosts with the lowest total_costs_with_surtax value.
| Returns: |
|
|---|
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Get the infrastructure costs for the given reinforcement type.
| Parameters: |
|
|---|
| Raises: |
|
|---|
| Returns: |
|
|---|
get_reinforcement_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> float
¶
Get the costs for the given reinforcement type.
| Parameters: |
|
|---|
| Raises: |
|
|---|
| Returns: |
|
|---|
StrategyLocationReinforcement
dataclass
¶
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.
current_cost: float
property
¶
Estimates the costs with surtax at this location for the given current_selected_measure.
current_selected_measure: type[ReinforcementProfileProtocol]
property
¶
Exposes the current selected measure for this object.
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
| Parameters: |
|
|---|
| Returns: |
|
|---|
get_selected_measure_steps() -> tuple[type[ReinforcementProfileProtocol], type[ReinforcementProfileProtocol], type[ReinforcementProfileProtocol]]
¶
Outputs the selected measure following the domain (expected) steps: - Initial step, - Order step, - Infrastructure step
| Returns: |
|
|---|
set_selected_measure(reinforcement_type: type[ReinforcementProfileProtocol], step: StrategyStepEnum)
¶
Changes the value reprsented in current_selected_measure and updates the
dictionary of selections (history).
| Parameters: |
|
|---|
StrategyProtocol
¶
Bases: Protocol
apply_strategy(strategy_input: StrategyInput) -> StrategyOutput
¶
Applies a specific strategy by matching each location (PointSurroundings)
to a valid reinforcement type (ReinforcementProfileProtocol).
| Parameters: |
|
|---|
| Returns: |
|
|---|
Order Strategy¶
OrderStrategy
¶
Bases: StrategyProtocol
get_default_order_for_reinforcements() -> list[type[ReinforcementProfileProtocol]]
staticmethod
¶
Give the default order for reinforcements types, assuming they are sorted from cheapest to most expensive and least to most restrictive.
| Returns: |
|
|---|
get_strategy_order_for_reinforcements(strategy_reinforcements: list[StrategyReinforcementInput]) -> list[type[ReinforcementProfileProtocol]]
¶
Give the ordered reinforcement types for this strategy, from cheapest to most expensive, possibly removing reinforcement types that are more expensive and more restrictive than others. Inactive reinforcements are ignored. Cofferdam should always be the last reinforcement type.
Input
strategy_reinforcements (list[StrategyReinforcementInput]): list of reinforcement types with costs and surface
| Returns: |
|
|---|
get_strategy_reinforcements(strategy_locations: list[StrategyLocationInput], selection_order: list[type[ReinforcementProfileProtocol]]) -> list[StrategyLocationReinforcement]
staticmethod
¶
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.
| Parameters: |
|
|---|
| Returns: |
|
|---|
OrderStrategyBuffering
dataclass
¶
Bases: OrderStrategyBase
Applies buffering, through masks, to each location's pre-assigned reinforcement.
The result of the apply method will be the locations with the best
reinforcement fit (lowest index from reinforcement_order) that fulfills the
reinforcement_min_buffer requirement.
OrderStrategyClustering
dataclass
¶
Bases: OrderStrategyBase
Applies clustering, to the whole collection of reinforcements
(location_reinforcements: list[StrategyLocationReinforcement]).
The result of the apply method will be the locations with the best
reinforcement fit (lowest index from reinforcement_order) that fulfills the
reinforcement_min_length requirement.
OrderCluster
dataclass
¶
extend_cluster(other: OrderCluster)
¶
Extends the current cluster with the reinforcements
(list[StrategyLocationReinforcement]) from another cluster.
Modifies the current_selected_measure property of those measures being merged but it
does not remove them from their source cluster.
| Parameters: |
|
|---|
| Raises: |
|
|---|
get_stronger_cluster() -> OrderCluster
¶
Gets the neighbor with the lowest reinforcement type value greater
than the current cluster's value (self.reinforcement_idx).
| Returns: |
|
|---|
is_compliant(min_length: float, strongest_reinforcement: int) -> bool
¶
Checks whether this OrderCluster instance is compliant within a cluster group.
This method does not check for exceptions, such as, the cluster's neighbors are
of lower strength than the current.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Infra Priority Strategy¶
InfraPriorityStrategy
¶
Bases: StrategyProtocol
This strategy works under the assumption that
StrategyLocationReinforcement.available_measures
ARE NOT ordered by "compatibility".
Thus we need to check first which are the compatible reinforcements
per cluster.
generate_subcluster_options(from_cluster: InfraCluster, min_length: int) -> list[list[InfraCluster]]
staticmethod
¶
Generates all possible combinations of (sub) clusters based on the locations of this cluster. These are also referred as "options".
| Parameters: |
|
|---|
| Returns: |
|
|---|
get_common_available_measures_costs(infra_cluster: InfraCluster, order_strategy_reinforcements: list[type[ReinforcementProfileProtocol]]) -> dict[type[ReinforcementProfileProtocol], float]
staticmethod
¶
Gets a dictionary with the reinforcements available at all
locations of the cluster (infra_cluster) as well as their
total cost if said reinforcement is applied at them.
| Parameters: |
|
|---|
| Returns: |
|
|---|
InfraCluster
dataclass
¶
This dataclass represents the subset of locations sharing the same
reinforcement type (type[ReinforcementProfileProtocol]).
current_cost: float
property
¶
Calculates the cost of applying the reinforcement_type to
all locations present in the cluster.
| Returns: |
|
|---|
fits_subclusters() -> bool
¶
Validates whether this cluster can be split into subclusters. For that it requires to have at least twice the required length.
| Returns: |
|
|---|
is_valid() -> bool
¶
Validates the length of this cluster.
| Returns: |
|
|---|
set_cheapest_common_available_measure(measure_costs: dict[type[ReinforcementProfileProtocol], float]) -> None
¶
Updates all the location reinforcements with the cheapest reinforcement type
from the measure_costs.
| Parameters: |
|
|---|
InfraClusterOption
dataclass
¶
Represents one set of subclusters the strategy could select for costs optimization.
add_cluster(infra_cluster: InfraCluster, cluster_costs: dict)
¶
Adds the infra cluster into the collection as well as its reinforcement costs.
| Parameters: |
|
|---|
cluster_collection: list[InfraCluster]
property
¶
Read-only property to expose the stored subclusters.
cluster_costs: list[dict[ReinforcementProfileProtocol, float]]
property
¶
Read-only property to expose the stored costs.
set_cheapest_option()
¶
Sets the subclusters defined in this option to their most optimal (cheapest) reinforcement possible.
valid_option() -> bool
¶
Validates the collection of clusters based on the required minimun length.
| Returns: |
|
|---|