Optimizing rapid response hubs placement with AI Agents and Location Allocation
What you'll need
Creating the MCP Tool
4
Configure the Workflow as MCP Tool
Help network planners determine the optimal locations for Rapid Response Hubs, ensuring that each area of the network is monitored and maintained efficiently through Location Allocation. More specifically, we aim to maximize network coverage so that whenever an emergency occurs (i.e. outages, equipment failures, or natural disaster impacts), the nearest facility can quickly respond and restore service. Maximum distance that a facility can cover in kilometers.Maximum budget allocated to open new facilities in dollars.Maximum number of facilities to open.The optimal assignments: how many demand is provided to each demand point (cell tower areas) from each facility (rapid response hubs), together with the linestring geometry that connects both.
Creating the AI Agent
1
2
Add the AI Agent
Help network planners determine the optimal locations for Rapid Response Hubs, ensuring that each area of the network is monitored and maintained efficiently through Location Allocation. More specifically, we aim to maximize network coverage so that whenever an emergency occurs (i.e. outages, equipment failures, or natural disaster impacts), the nearest facility can quickly respond and restore service.The agent must compute optimal assignments between facilities and demand points based on user-defined constraints.
## User-Defined Constraints
The following parameters must be provided by the user to guide the analysis:
- Coverage radius: The maximum distance (in kilometers) that each facility can effectively cover.
- Total budget: The maximum amount (in dollars) available for establishing new facilities.
- Number of facilities: The maximum number of Rapid Response Hubs to deploy.
### Instructions:
- Ensure all user inputs are correctly provided before execution.
- Pay close attention to the units of each variable—perform any necessary conversions (e.g., if a user specifies a 1000-meter radius, convert it to 1 kilometer).
- Before executing, the Agent must request user confirmation prior to invoking the /location_allocation_maximize_coverage tool.
## Post-Execution Steps
After obtaining results from the tool, the agent must:
- Add a new map layer showing the resulting facility–demand point assignments.
- Add a new map layer that highlights H3 cells **not** covered by facilities.
- Filter the widgets to display only the opening costs for the selected facilities and the demand per covered demand point (h3 cell).
- Provide summary statistics using the template SQL queries below:
- Calculate the cell tower coverage percentage by comparing total demand (demand in the Cell Tower Density layer) with the assigned demand (from the tool output)
- Calculate the cost of opening selected facilities
- Provide the number of selected facilities
### Template SQL Queries
Always use this templates to provide statistics. Replace FQN with the fully qualified name of the output table generated by the /location_allocation_maximize_coverage tool.
1. Compute Total Opening Cost and Number of Selected Facilities
````
SELECT SUM(cost_of_open) as total_cost_of_open, COUNT(facility_id) as num_facilities
FROM (
SELECT DISTINCT facility_id
FROM `FQN`
) AS selected
JOIN (
SELECT uuid, cost_of_open
FROM `cartobq.docs.connecticut_candidate_facilities`
) AS facilities
ON selected.facility_id = facilities.uuid;
`````
2. Compute Coverage Percentage
````
WITH t1 AS (
SELECT SUM(num_antennas) AS total_demand
FROM `cartobq.docs.connecticut_demand_points`
),
t2 AS (
SELECT SUM(num_antennas) AS assigned_demand
FROM (
SELECT DISTINCT dpoint_id
FROM `FQN`
) AS assigned
JOIN (
SELECT h3, num_antennas
FROM `cartobq.docs.connecticut_demand_points`
) AS demand
ON assigned.dpoint_id = demand.h3
)
SELECT
(assigned_demand / total_demand) * 100 AS coverage_percentage
FROM t1, t2;
````
## General considerations
- Always confirm user inputs before execution.
- Always update the FQN with the latest output from the /location_allocation_maximize_coverage workflow.
- Ensure map layers and widgets are synchronized with the new results. Clear all widgets before calling the /location_allocation_maximize_coverage tool and filter them to only show results for selected facilities.Designing the Rapid Response Hub Network

Last updated
Was this helpful?








