Relocation problem#
- class libadalina_analytics.relocation.RelocationResource(*, column_name: str, amount: float)[source]#
-
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- libadalina_analytics.relocation.relocation_algorithm(data: DataFrame | GeoDataFrame | DataFrame, epsg: EPSGFormats, id_column: str = 'id', geometry_column: str = 'geometry', demand_column: str = 'demand', geometry_format: GeometryFormats = GeometryFormats.WKT, max_distance_assignment: float | None = None, max_distance_relocation: float | None = None, server_column: str | None = None, resources: list[RelocationResource] | None = None, timelimit: int = 60) DataFrame | None[source]#
Optimally assign demand to servers minimizing relocation costs.
- Parameters:
data (pandas.DataFrame) – The input data containing the geometries and properties.
epsg (EPSGFormats) – The EPSG format of the input geometries.
id_column (str) – The name of the column containing the unique identifiers for each location. Default is ‘id’.
geometry_column (str) – The name of the column containing the geometries. Default is ‘geometry’.
demand_column (str) – The name of the column containing the demand values. Default is ‘demand’.
geometry_format (GeometryFormats) – The format of the geometries in the geometry column. Default is GeometryFormats.WKT.
max_distance_assignment (float | None) – The maximum distance allowed for assigning demand to servers. If None, no limit is applied. Default is None.
max_distance_relocation (float | None) – The maximum distance allowed for relocating demands. If None, no limit is applied. Default is None.
server_column (str | None) – The name of the column indicating whether a location is a server (True) or not (False). If None, all locations are considered as potential servers. Default is None.
resources (list[RelocationResource] | None) –
A list of RelocationResource objects representing the resources available at each server. Each RelocationResource contains:
column_name: The name of the column in the input data representing the resource
amount: The total amount of the resource needed to serve one unit of demand.
timelimit (int) – The maximum time (in seconds) to run the algorithm. Default is 60 seconds.
- Returns:
A DataFrame containing the optimal assignment of demand to servers, or None if no solution is found.
- Return type:
pandas.DataFrame | None