Optimizing rapid response hubs placement with AI Agents and Location Allocation

Operating a modern telecommunications network involves carefully balancing expenses, service reach, and overall efficiency. Each network node—comprising groups of cell towers—creates specific service demands that must be supported by well-placed operational facilities.

In this tutorial, we’ll create a AI Agent that will help us identify the optimal placement of rapid response hubs in Connecticut using Location Allocation, part of the Territory Planning Extension Package. Considering different constraints, this approach helps telecom operators design agile networks that can respond quickly to outages, service disruptions, and infrastructure failures.

What you'll need

To build this AI Agent, you'll need to:

Creating the MCP Server

As a first step, we will create a workflow that serves as an MCP tool for our Agent, enabling it to automatically run Location Allocation based on predefined constraints.

1

Generate a Workflow

For this tutorial, we will use a pre-built template that examines potential rapid response facilities in Connecticut and pinpoints the optimal sites for maximising network coverage based on specific constrains. In this case, demand is modelled using H3 cells, where the density of cell towers within each hexagon reflects network needs.

To explore this analysis in depth, check out this full step-by-step tutorial!

To load the template, navigate to the Workflows tab and click Create new workflow > From template. In the search bar, enter 'Location Allocation - Maximize Coverage' and select the template from the results.

Next, choose the CARTO Data Warehouse connection (or one of your own connections) and click Create Workflow to get started.

2

Include additional components

Once you have explored the workflow, go to the Components section, drag and drop and connect the following:

  • Save as Table: to write the results of the analysis to a non-temporary location.

  • MCP Tool Output: to define the output of the workflow when used as an MCP Tool by agents. In this case, the output of the tool will reflect the selected optimal locations for rapid response hubs and their assigned demand points (H3 cells of specific cell tower density). Since this process may take some time, select the Async mode.

3

Add custom variables

When a user interacts with the agent and asks for specific budget constraints, the agent automatically passes the corresponding variable values to the workflow, which then runs the analysis and produces results tailored to that request. We then need to define which are the variables the agent can configure. To do this, go to the upper-right corner next to Run and find Variables. We will allow tailoring the following:

  • radius : maximum distance that a facility can cover (in kilometers)

  • budget : maximum budget allowed for opening facilities (in dollars)

  • max_facilities : maximum number of facilities to be opened

Remember to set up default values and enable the MCP scope for all three of them as in the screenshot below.

Then, specify the variables in the Location Allocation component using {{@variable_name}} as seen below:

4

Configure the Workflow as MCP Tool

The last step is to enable the Workflow as an MCP Tool. Click the three dots in the top-right section and select MCP Tool. Then, fill in the context the Agents will have when this tool is available to them: this includes a description of what the tool does, and what are its inputs and outputs.

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. 

Enable the workflow as an MCP Tool by clicking the option in the bottom-left corner. You should then see an MCP Tool enabled flag next to the Share bottom in the upper-right side of the canvas.

Creating the AI Agent

Now that our MCP Tool is configured and enabled, we will create a map that uses an AI Agent to design the optimal rapid response hub network. The agent will use the MCP Tool to generate detailed results, allowing end users to explore and test different configurations dynamically.

1

Build an interactive map

In the AI Agent tab, click on New AI Agent, then on New Map. A Builder map will be created. Before configuring the agent, we will first add layers to this map that will help understanding the results.

Rename the map to Location Allocation - Maximize Coverage and add the following layers by selecting Add source from > Custom SQL query in the left-bottom corner. Select the CARTO Data Warehouse connection:

  • Area of Interest: Connecticut counties

SELECT * FROM cartobq.docs.connecticut_counties
  • Candidate facilities: Rapid Response Hubs

SELECT * FROM cartobq.docs.connecticut_candidate_facilities
  • Demand points: Cell tower density (H3 cells)

SELECT * FROM cartobq.docs.connecticut_demand_points

Style the map as you wish and add the following widgets:

  • Cost of open each facility: a category widget that shows the cost of opening values of each of the facilities. Aggregate the cost_of_open data by uuid using the SUM operation. This is the most important widget, as we are instructing the agent to filter the widget and show only selected facilities.

You can add more widgets on your own, such as:

  • Total cost of open: a formula widget that sums the cost_of_open values of the facilities.

  • Capacity: a histogram widget that shows the capacity distribution of the facilities.

  • Demand per county: a pie widget that sums the num_antennas (demand) in all H3 cells for each county_name.

You should end up with something like this:

2

Add the AI Agent

Now, go to the AI Agent menu on the left side, click on Create Agent, and provide the following instructions:

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.

Also, make sure to enable the Query sources for insights option so that the agent can run SQL queries via the map's connection, for analysis and creating new sources and layers.

3

Add the MCP Tool to your Agent

Before finishing, we need to let the agent use the MCP Tool. To do this, click on Show tools and select the location_allocation_maximize_coverage tool we just created.

Click on Create Agent and that's it! Now, we are ready to test it.

4

Enable AI Agents for viewers

To share the agent with end users, find the Map settings for viewers icon next to the Preview top-right bottom and enable the AI Agent option. Then click on Preview to see how it looks like.

Designing the Rapid Response Hub Network

In this last section, we will see the AI Agent in action! It will help us dynamically select which facilities we should open for emergency response depending on different parameters. Take a look at the following demo:

Last updated

Was this helpful?