Strategies¶
StrategyInput
dataclass
¶
reinforcement_min_cluster: int
property
¶
Returns the minimum length of a reinforcement type
along a traject, usually named as cluster
throughout
the code.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
|
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:
Type | Description |
---|---|
list[type[ReinforcementProfileProtocol]]
|
list[Type[ReinforcementProfileProtocol]]: resulting list. |
cheapest_reinforcement: StrategyReinforcementTypeCosts
property
¶
Gets the StrategyLocationReinforcementCosts
with the lowest total_costs
value.
Returns:
Name | Type | Description |
---|---|---|
StrategyLocationReinforcementCosts |
StrategyReinforcementTypeCosts
|
The cheapest reinforcement for this location. |
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Get the infrastructure costs for the given reinforcement type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
The reinforcement type. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
The reinforcement type is not available. |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
get_reinforcement_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> float
¶
Get the costs for the given reinforcement type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
The reinforcement type. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
The reinforcement type is not available. |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The reinforcement costs. |
PointSurroundings
dataclass
¶
Object representing a meter
with x
, y
coordinates in a polder (or else).
__eq__(__value: object) -> bool
¶
Overriding of the "magic" equality operator required
so that PointSurroundings
can be used as a key in a python dict.
__hash__() -> int
¶
Overriding of the "magic" hash operator required
so that PointSurroundings
can be used as a key in a python dict.
closest_obstacle: float
property
¶
Distance to the closest (obstacle) surrounding. When no surroundings are given the value will be NaN
(Not A Number), so that the value 0 is reserved for buildings at distance 0.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Distance to the closest surrounding. |
get_total_infrastructure_per_zone(*zone_limit_collection: tuple[float, float]) -> list[float]
¶
Gets the total infrastructure width at each of the provided zones
zone_limit_collection
(tuple[float, float]
).
The zone limits are matched by rounding up their upper limit to the
surroundings_matrix
keys (distances to the location
in the real world).
When two zones have overlapping limits (as expected) the lower one will
"claim" the corresponding surrounding distance.
Example
zone_limit_collection
= (0, 4), (4, 11)surroundings_matrix
= {5: 1.5, 10: 3, 15: 6}- "Taken" distances per zone:
(0, 4)
takes key5
.(4, 11)
takes key(s)10
and15
because5
was already taken.
- Total infrastructure width at zones =
(1.5, 9)
Returns:
Type | Description |
---|---|
list[float]
|
list[float]: list with total width corresponding to each provided zone. |
ReinforcementProfileProtocol
¶
Bases: KoswatProfileProtocol
, Protocol
Extension of the KoswatProfileProtocol
to define the properties of a calculated reinforcement.
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:
Type | Description |
---|---|
list[type[ReinforcementProfileProtocol]]
|
list[Type[ReinforcementProfileProtocol]]: resulting list. |
cheapest_reinforcement: StrategyReinforcementTypeCosts
property
¶
Gets the StrategyLocationReinforcementCosts
with the lowest total_costs
value.
Returns:
Name | Type | Description |
---|---|---|
StrategyLocationReinforcementCosts |
StrategyReinforcementTypeCosts
|
The cheapest reinforcement for this location. |
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Get the infrastructure costs for the given reinforcement type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
The reinforcement type. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
The reinforcement type is not available. |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
get_reinforcement_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> float
¶
Get the costs for the given reinforcement type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
The reinforcement type. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
The reinforcement type is not available. |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The reinforcement costs. |
StrategyLocationReinforcement
dataclass
¶
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
Reinforcement type. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
StrategyInput
dataclass
¶
reinforcement_min_cluster: int
property
¶
Returns the minimum length of a reinforcement type
along a traject, usually named as cluster
throughout
the code.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
|
StrategyLocationReinforcement
dataclass
¶
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
Reinforcement type. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
StrategyProtocol
¶
Bases: Protocol
apply_strategy(strategy_input: StrategyInput) -> list[StrategyLocationReinforcement]
¶
Applies a specific strategy by matching each location (PointSurroundings
)
to a valid reinforcement type (ReinforcementProfileProtocol
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strategy_input |
`StrategyInput`
|
Input data structure containing locations and available reinforcements for each of them. |
required |
Returns:
Type | Description |
---|---|
list[StrategyLocationReinforcement]
|
list[StrategyLocationReinforcement]: List of mapped locations to applied reinforcement. |
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:
Type | Description |
---|---|
list[type[ReinforcementProfileProtocol]]
|
list[type[ReinforcementProfileProtocol]]: list of reinforcement types |
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. Cofferdam should always be the last reinforcement type.
Input
strategy_reinforcements (list[StrategyReinforcementInput]): list of reinforcement types with costs and surface
Returns:
Type | Description |
---|---|
list[type[ReinforcementProfileProtocol]]
|
list[type[ReinforcementProfileProtocol]]: list of reinforcement types |
ReinforcementProfileProtocol
¶
Bases: KoswatProfileProtocol
, Protocol
Extension of the KoswatProfileProtocol
to define the properties of a calculated reinforcement.
StrategyInput
dataclass
¶
reinforcement_min_cluster: int
property
¶
Returns the minimum length of a reinforcement type
along a traject, usually named as cluster
throughout
the code.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
|
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:
Type | Description |
---|---|
list[type[ReinforcementProfileProtocol]]
|
list[Type[ReinforcementProfileProtocol]]: resulting list. |
cheapest_reinforcement: StrategyReinforcementTypeCosts
property
¶
Gets the StrategyLocationReinforcementCosts
with the lowest total_costs
value.
Returns:
Name | Type | Description |
---|---|---|
StrategyLocationReinforcementCosts |
StrategyReinforcementTypeCosts
|
The cheapest reinforcement for this location. |
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Get the infrastructure costs for the given reinforcement type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
The reinforcement type. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
The reinforcement type is not available. |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
get_reinforcement_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> float
¶
Get the costs for the given reinforcement type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
The reinforcement type. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
The reinforcement type is not available. |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The reinforcement costs. |
StrategyLocationReinforcement
dataclass
¶
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
Reinforcement type. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
StrategyProtocol
¶
Bases: Protocol
apply_strategy(strategy_input: StrategyInput) -> list[StrategyLocationReinforcement]
¶
Applies a specific strategy by matching each location (PointSurroundings
)
to a valid reinforcement type (ReinforcementProfileProtocol
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strategy_input |
`StrategyInput`
|
Input data structure containing locations and available reinforcements for each of them. |
required |
Returns:
Type | Description |
---|---|
list[StrategyLocationReinforcement]
|
list[StrategyLocationReinforcement]: List of mapped locations to applied reinforcement. |
ReinforcementProfileProtocol
¶
Bases: KoswatProfileProtocol
, Protocol
Extension of the KoswatProfileProtocol
to define the properties of a calculated reinforcement.
StrategyLocationReinforcement
dataclass
¶
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
Reinforcement type. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
ReinforcementProfileProtocol
¶
Bases: KoswatProfileProtocol
, Protocol
Extension of the KoswatProfileProtocol
to define the properties of a calculated reinforcement.
StrategyLocationReinforcement
dataclass
¶
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
Reinforcement type. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
OrderCluster
dataclass
¶
extend_cluster(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
does not remove them from their source cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
OrderCluster
|
Cluster whose contents will be used to extend |
required |
Raises:
Type | Description |
---|---|
ValueError
|
When trying to extend from an unrelated cluster. |
get_stronger_cluster() -> OrderCluster
¶
Gets the neighbor with the lowest reinforcement type value greater
than the current cluster's value (self.reinforcement_idx
).
Returns:
Name | Type | Description |
---|---|---|
OrderCluster |
OrderCluster
|
Neighbor with a stronger |
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:
Name | Type | Description | Default |
---|---|---|---|
min_length |
float
|
Minimal length a reinforcement measure is required for a cluster. |
required |
strongest_reinforcement |
int
|
What is the reinforcement index which cannot be futher 'strengthen'. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
if the cluster is compliant within its neighbors context. |
ReinforcementProfileProtocol
¶
Bases: KoswatProfileProtocol
, Protocol
Extension of the KoswatProfileProtocol
to define the properties of a calculated reinforcement.
StrategyLocationReinforcement
dataclass
¶
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
Reinforcement type. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |
OrderCluster
dataclass
¶
extend_cluster(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
does not remove them from their source cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
OrderCluster
|
Cluster whose contents will be used to extend |
required |
Raises:
Type | Description |
---|---|
ValueError
|
When trying to extend from an unrelated cluster. |
get_stronger_cluster() -> OrderCluster
¶
Gets the neighbor with the lowest reinforcement type value greater
than the current cluster's value (self.reinforcement_idx
).
Returns:
Name | Type | Description |
---|---|---|
OrderCluster |
OrderCluster
|
Neighbor with a stronger |
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:
Name | Type | Description | Default |
---|---|---|---|
min_length |
float
|
Minimal length a reinforcement measure is required for a cluster. |
required |
strongest_reinforcement |
int
|
What is the reinforcement index which cannot be futher 'strengthen'. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
if the cluster is compliant within its neighbors context. |
StrategyLocationReinforcement
dataclass
¶
get_infrastructure_costs(reinforcement_type: type[ReinforcementProfileProtocol]) -> tuple[float, float]
¶
Returns the infrastructure costs for the given reinforcement type (without and with surtax).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reinforcement_type |
type[ReinforcementProfileProtocol]
|
Reinforcement type. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: Tuple containing the infrastructure costs without and with surtax. |