to giant enterprises, increasingly more organizations are embracing AI brokers and adopting multi-agent architectures to ship dependable, scalable, and manageable options. AI agent and LLM prices can shortly spiral with out cautious administration. On this put up, we’ll uncover a number of agent planning and value optimization enterprise issues and body them as operations analysis options via the lens of information science. If you’re fascinated with studying extra about Agent Planning and Agentic AI, take a look at my article on “How to Build Your Own Agentic AI System Using CrewAI“.
What’s Optimization in Operations Analysis?
Operations analysis leverages mathematical fashions and optimization to search out the perfect choice underneath sensible constraints. It’s the spine of prescriptive analytics, which transforms predictive insights to actions which are crucial to choice making. Framing a real-world scenario into an summary mathematical mannequin is the important thing to fixing any operations analysis downside.
A easy but broadly talked about instance of operations analysis is the linear programming downside, the place we attempt to discover values of x and y that maximize a linear equation (e.g. 2x + 4y), topic to the constraints x ≥ 0 and y ≥ 0. Operations analysis issues sometimes embody the next key elements:
- Choice Variables: The variables to be decided.
- Constraints: The true-world limitations on assets or necessities.
- Targets: The purpose to be maximized or minimized.
How one can Optimize Agent Value and Useful resource Allocation
AI agent planning entails making useful resource allocation choices inside an organization’s funds whereas nonetheless attaining the absolute best outcomes, which makes it a powerful match for operations analysis eventualities. We will map the core elements above to agent value optimization and useful resource planning use circumstances.
- Choice Variables: Brokers assign to duties or initiatives
- Constraints: funds, response time, token
- Targets: decrease prices, maximize return on funding
We are going to use 4 most traditional optimization patterns to deal with widespread agent planning eventualities:
- Set-Protecting Downside: Select the smallest set of brokers to cowl all required duties, expertise, or enterprise features, with the target of minimizing value with out leaving gaps in functionality.
- Project Downside: Determine which agent ought to deal with every challenge, with the purpose of maximizing total output worth.
- Knapsack Downside: Choose the perfect bundle of brokers underneath a set funds, to maximise complete output tokens.
- Community Downside: Design workflows throughout a community of brokers to fulfill division and consumer calls for on the lowest value underneath capability constraints.
To make this extra sensible, we’ll stroll via 4 examples in Python utilizing the Gurobi library. Gurobi is an enterprise-grade mathematical optimization solver that helps many downside varieties, together with linear programming and mixed-integer programming. It’s typically used because the “solver engine” behind operations analysis functions as a result of it might probably deal with large-scale fashions effectively and offers sturdy APIs, together with Python, for outlining choice variables, constraints, and goal features. Gurobi lets knowledge scientists give attention to modeling moderately than implementing customized optimization algorithms. Please observe that this text isn’t affiliated with Gurobi, and all functionalities talked about right here may be achieved utilizing the free license. All datasets proven on this challenge are artificial and are used to exhibit a proof of idea.
1. Set-Protecting Downside – Agent Ability Protection
Set-covering is a traditional optimization downside refers back to the downside of selecting the smallest variety of choices in order that each required merchandise is roofed no less than as soon as. A typical AI agent cost-optimization state of affairs that matches the set-covering downside is ability protection, the place we intention to determine the minimal variety of brokers wanted to cowl the elemental expertise required to assist the corporate’s every day operations.
Downside Assertion: The corporate desires to embed brokers into every day operations and canopy the 9 ability areas listed within the “Ability Space” desk beneath. Every agent prices $20k to construct and focuses on a definite set of expertise as proven within the “Agent Ability” desk. How can the corporate decrease the full value of constructing brokers whereas nonetheless protecting each space?
Ability Space

Agent Ability

Implementation
We will body it as an optimization downside that follows the set-covering sample and resolve it utilizing Gurobi library, outlined by following key elements — knowledge, mannequin, variables, constraints and targets.
- Knowledge: load the information for expertise, brokers and agent prices (which is 20k every agent)
## knowledge
expertise = knowledge["skills"]
brokers = knowledge["agents"]
agent_skills = knowledge["agent_skills"]
agent_costs = {i: 20 for i in brokers}
- Mannequin: Create the Gurobi mannequin with a reputation “Set Protecting”. For those who haven’t put in gurobipy but, run the command
## mannequin
import gurobipy as gp
mannequin = gp.Mannequin("Set Protecting")
- Variables: The choice variables are binary variables related to each agent, with a decrease certain of 0 and an higher certain of 1 to point whether or not an agent is chosen. Gurobi presents a spread of preset variable varieties, together with
GRB.BINARY,GRB.INTEGER, andGRB.CONTINUOUS, and so on.
## variables
X = mannequin.addVars(brokers, lb=0, ub=1, vtype=GRB.BINARY, identify="x")
- Constraints: For every ability space, sum of all chosen brokers with that ability needs to be greater than 1, making certain that now we have no less than one agent to cowl the ability space. We use the summation perform
gp.quicksumso as to add constraints utilizing weighted sum after which use nested loop expressions to iterate via 9 ability areas.
## constraints: for every ability in expertise, sum of brokers with that ability ≥ 1
for j in expertise:
mannequin.addConstr(
gp.quicksum(X[i] for i in brokers if j in agent_skills[i]) >= 1,
identify=f'{j}_area_constr'
)
- Goal: Reduce the full value of chosen brokers, calculated because the weighted sum of every agent’s value multiplied by the choice variable indicating whether or not that agent is chosen.
## targets: decrease sum of brokers chosen
mannequin.setObjective(
gp.quicksum(agent_costs[i] * X[i] for i in brokers),
GRB.MINIMIZE
)
Lastly, we run the mannequin optimization utilizing mannequin.optimize().
Enterprise Influence
On this part, we first interpret the mannequin’s optimum output after which estimate the influence of creating choices primarily based on that optimum output versus making random decisions. In a enterprise setting, this helps leaders allocate funds successfully by figuring out which brokers to construct, deploy, or retire.
Optimum Outcome
mannequin.ObjVal prints out the optimum goal worth. For every binary choice variable, we use X[i].X > 0.5 to print out the chosen brokers.
print(f"Complete brokers chosen: {spherical(mannequin.ObjVal, 4)}")
for i in brokers:
if X[i].X > 0.5:
print(f"Agent {i} chosen.")
Alternatively, Claude Code suggests me the next snippet to show the mannequin output in a structured method.
print("================ Set-Protecting: Ability Protection ================")
if mannequin.Standing == GRB.OPTIMAL:
chosen = [i for i in agents if X[i].X > 0.5]
print(f"Minimal brokers wanted : {len(chosen)}")
print(f"Complete value : ${mannequin.ObjVal:.0f}okay")
print("nSelected brokers:")
for agent in chosen:
lined = ", ".be part of(
f"{s}({skill_labels[s]})" for s in agent_skills[agent]
)
print(f" - {agent} [{covered}]")
else:
print("No optimum resolution discovered.")
Output beneath reveals that the optimum agent planning is to pick 4 brokers (Normal Help Agent, Entry & Permissions Agent, CRM Agent and Value & Efficiency Optimization Agent) to cowl all expertise with $80k funds spend.
================ Set-Protecting: Ability Protection ================
Minimal brokers wanted : 4
Complete value : $80k
Chosen brokers:
- Normal Help Agent [F(Support), C(Knowledge), H(Collaboration)]
- Entry & Permissions Agent [F(Support), E(Automation), G(Governance)]
- CRM / Relationship Administration Agent [A(Planning), B(Tool Use), C(Knowledge)]
- Value & Efficiency Optimization Agent [D(Analytics), I(Monitoring), J(Optimization)]
Simulations
We then simulated random picks and in contrast them with the optimum consequence. As proven beneath, we generated 500 possible agent picks (blue histogram) with prices starting from $80k to $200k and a mean value of $134.6k (blue dotted line). This implies the optimization helps the enterprise to cut back the price by ($134.6k − $80k)/$134.6 = 40.6% on common.

──────────────────────────────────────────────────
Set Protecting — Ability Protection
──────────────────────────────────────────────────
Minimal (Optimum) : 80.00 okay$
Sim imply : 132.88 okay$
Sim min : 80.00 okay$
Sim max : 220.00 okay$
Possible options : 500/500
──────────────────────────────────────────────────
Discover the whole implementation in our GitHub repo.
2. Project Downside – Agent Useful resource Allocation

Project Downside follows a typical sample to match duties to individuals or objects, often one-to-one or one-to-many relationship, to maximize output produced or decrease value. Agent useful resource allocation matches this downside sample, because it requires allocating a set of brokers throughout initiatives, sometimes with the constraint that every challenge is matched with one main agent and the target of attaining the very best complete output worth.
Downside Assertion: The corporate has constructed a set of brokers to work on 9 initiatives and every challenge requires assigning one main agent. The desk beneath reveals how a lot worth every agent can contribute to every challenge. How can the corporate maximize the general worth by assigning probably the most acceptable main agent to initiatives?

Implementation
We comply with the identical six-step course of to interrupt down this task downside.
- Knowledge: load the information for brokers, initiatives and values. Create a
value_mapdictionary to characterize the connection between agent and challenge.
## knowledge
brokers = knowledge["agents"]
initiatives = knowledge["projects"]
values = knowledge["values"]
# Construct worth lookup: (agent, challenge) -> rating
value_map = {
(brokers[i], initiatives[j]): values[i][j]
for i in vary(len(brokers))
for j in vary(len(initiatives))
}
- Mannequin: Create a Gurobi mannequin with the identify “Project”.
## mannequin
import gurobipy as gp
mannequin = gp.Mannequin("Project")
- Variables: The choice variables on this downside ought to point out whether or not an agent is assigned to a challenge, which is a binary variable related to every distinctive mixture of agent and challenge.
## variables
from gurobipy import GRB
X = mannequin.addVars(brokers, initiatives, lb=0, ub=1, vtype=GRB.BINARY, identify="x")
- Constraints: For every challenge, sum of all assigned brokers needs to be precisely one. For every agent, sum of initiatives it’s assigned to needs to be no less than one.
## constraints: every challenge is assigned precisely one agent
for j in initiatives:
mannequin.addConstr(
gp.quicksum(X[(i, j)] for i in brokers) == 1,
identify=f"{j}_project_constr",
)
## constraints: every agent is assigned no less than one challenge
for i in brokers:
mannequin.addConstr(
gp.quicksum(X[(i, j)] for j in initiatives) >= 1,
identify=f"{i}_agent_constr",
)
- Goal: Maximize the general worth rating utilizing the sum of every agent’s rating on every challenge multiplied by the choice variable indicating whether or not the agent is assigned to the challenge.
## goal: maximize the general worth rating
mannequin.setObjective(
gp.quicksum(value_map[(i, j)] * X[(i, j)] for i in brokers for j in initiatives),
GRB.MAXIMIZE,
)
Enterprise Influence
By framing agent allocation as an task downside, companies can allocate brokers to initiatives in a manner that finest matches their expertise and maximizes total worth. This improves return on funding by rising output high quality whereas attaining enterprise targets with the identical set of pre-built brokers.
To know the enterprise influence of this optimization state of affairs, we’ll first interpret the really helpful allocation after operating mannequin.optimize(), then estimate the influence on the general worth rating by evaluating the optimum outcome with random allocations.
Optimum Outcome
mannequin.ObjVal prints out the optimum goal worth. For every binary variable that signifies agent allocation, we use X[i, j].X > 0.5 to look at if agent i is allotted to challenge j.
print(f"Complete worth: {spherical(mannequin.ObjVal, 4)}")
for i in brokers:
for j in initiatives:
if X[(i, j)].X > 0.5:
print(f"Agent {i} needs to be allotted to Undertaking {j}.")
OR use the next snippet to show the mannequin output extra verbosely.
print("================ Project Downside: Useful resource Allocation ================")
if mannequin.Standing == GRB.OPTIMAL:
print(f"Most complete suitability rating: {mannequin.ObjVal:.0f}n")
print(f"{'Agent':<45} {'Undertaking':<6} {'Description':<30} {'Rating'}")
print("-" * 95)
for i in brokers:
for j in initiatives:
if X[(i, j)].X > 0.5:
print(
f"{i:<45} {j:<6} {project_labels[j]:<30} {obj_coeffs[(i, j)]}"
The output beneath reveals the optimum useful resource allocation, which assigns one main agent to every challenge and achieves a complete suitability rating of 77.
================ Project Downside: Useful resource Allocation ================
Most complete suitability rating: 77
Agent Undertaking Description Rating
-----------------------------------------------------------------------------------------------
Analytics & Insights Agent P1 Exec Metrics Dashboard 9
Analytics & Insights Agent P7 Churn Threat Monitor 8
Data Administration Agent P8 Onboarding Information Bot 9
Advertising and marketing Marketing campaign Orchestration Agent P3 Lead-Scoring Mannequin 9
Advertising and marketing Marketing campaign Orchestration Agent P6 Function Launch Transient 8
Buyer Help Automation Agent P2 CX Data Bot 9
Knowledge High quality & Monitoring Agent P9 SLA Incident Triage 8
Workflow Orchestration Agent P5 Experiment Evaluation 8
Governance & Compliance Agent P4 Coverage QA Assistant 9
Simulations
We simulated 500 random, possible agent allocations and in contrast them with the optimum consequence, the place the worth rating is 77. As proven beneath, the five hundred possible allocations produced total worth scores starting from 55 to 72, with a imply worth rating of 63.16. This means that optimization improves worth scores by (77 − 63.16) / 63.16 = 21.9% on common.

──────────────────────────────────────────────────
Project — Agent-to-Undertaking Allocation
──────────────────────────────────────────────────
Most (Optimum) : 77.00 rating
Sim imply : 63.16 rating
Sim min : 55.00 rating
Sim max : 72.00 rating
Possible options : 500/500
──────────────────────────────────────────────────
3. Knapsack Downside – Agent Budgeting

The knapsack Downside is an optimization state of affairs the place we decide the finest mixture of things whereas staying inside a restrict, like a funds or capability constraint. Portfolio administration and logistics association are common real-world implications. It’s appropriate for agent funds allocation eventualities the place we have to maximize the agent output underneath a restricted firm funds.
Downside Assertion: Given a $4,000 month-to-month funds, choose brokers from the listing beneath, every with a set month-to-month value, to maximise complete tokens generated.

Implementation
Once more, use the 6-step course of to interrupt down this knapsack downside.
- Knowledge: load the agent listing, every agent’s month-to-month value, and every agent’s token output, together with a set $4,000 month-to-month funds.
## knowledge
brokers = knowledge["agents"]
N = vary(len(brokers)) # variety of brokers
C = knowledge["costs"] # value per agent
P = knowledge["tokens"] # tokens per agent
Okay = 4000 # $4000 month-to-month funds
- Mannequin: Create a Gurobi mannequin with the identify “Knapsack”.
## mannequin
import gurobipy as gp
mannequin = gp.Mannequin("Knapsack")
- Variables: A binary choice variable is related to every agent to point whether or not they’re chosen.
## variables
X = mannequin.addVars(N, lb=0, ub=1, vtype=GRB.BINARY, identify="x")
- Constraints: Complete prices of all chosen brokers shouldn’t exceed the funds Okay.
## constraint: complete value should not exceed funds
mannequin.addConstr(
gp.quicksum(C[i] * X[i] for i in N) <= Okay,
identify="budget_constr",
)
- Goal: Maximize the full variety of tokens generated by all chosen brokers.
## goal: maximize complete tokens generated
mannequin.setObjective(
gp.quicksum(C[i] * X[i] for i in N),
GRD.MAXIMIZE,
)
Enterprise Influence
This sort of optimization downside is broadly utilized in enterprise as a result of it helps maximize output underneath a set funds. We are going to evaluate the optimized outcomes with 500 random agent picks underneath the identical funds constraints.
Optimum Outcome
After operating mannequin.optimize(), we use mannequin.ObjVal to get the optimum goal worth of complete tokens generated. For every binary choice variable, we use X[i].X > 0.5 to examine whether or not agent i is chosen.
print(f"Complete tokens generated: {spherical(mannequin.ObjVal, 4)}")
for agent in N:
if X[agent].X > 0.5:
print(f"Agent {agent} chosen.")
The mannequin output suggests choosing 4 brokers (Intent Classifier, Stock Checker, Assessment Analyzer and Analytics Reporter) that enable us to generate the utmost variety of tokens (e.g. 215 million tokens) inside the $4000 month-to-month funds.
================ Knapsack Downside: Budgeting ================
Price range : $4,000
Complete value used : $4,000
Complete tokens (M) : 215
Agent Value ($) Tokens (M)
-------------------------------------------------------
Intent Classifier 800 50
Stock Checker 1,200 70
Assessment Analyzer 900 45
Analytics Reporter 1,100 50
-------------------------------------------------------
TOTAL 4,000 215
Simulations
We simulated 500 random, possible agent allocations underneath the identical $4,000 funds and in contrast them with the optimum results of 215 million tokens. In these simulations, complete tokens ranged from 50M to 215M, with a mean of 151.61M, exhibiting the optimized plan performs about (215 − 151.61) / 151.61 = 41.8% higher than the typical random allocation.

──────────────────────────────────────────────────
Knapsack — Agent Price range Choice
──────────────────────────────────────────────────
Most (Optimum) : 215.00 tokens (M)
Sim imply : 151.61 tokens (M)
Sim min : 50.00 tokens (M)
Sim max : 215.00 tokens (M)
Possible options : 500/500
──────────────────────────────────────────────────
4. Community Downside – Agent Routing

Lastly, we’ll focus on the community downside, which addresses eventualities that require balancing provide and demand, or inputs and outputs throughout a set of entities. For instance, it entails shifting inventories via a warehouse community on the lowest value whereas respecting transport capability. A directed acyclic graph (DAG) is a typical graphical mannequin for community issues, the place nodes characterize distinct entities and arcs characterize flows from an enter entity to an output entity. A crucial constraint in a community downside is that every node meets the requirement of “provide + influx = demand + outflow”, so internet circulate equals demand minus provide.
Agent routing and multi-agent orchestration match this sample as a result of they coordinate a number of brokers throughout a sequence of inputs and outputs and require designing a workflow that balances consumer demand with every agent’s out there capability. As demand for multi-agent workflows grows, this area presents extra alternatives to optimize collaboration effectivity and useful resource consumption.
Downside Assertion: An organization has a multi-agent structure that features a Coding Agent and a Writing Agent, together with two agent hubs that function coordinators. The IT, Advertising and marketing, and Operations departments every require a sure variety of requests to be fulfilled every month, as proven within the desk beneath. Whereas departments can talk straight with the 2 brokers, this sometimes incurs a better value per request. Routing requests via the agent hubs reduces prices by standardizing the communication protocol. Every hyperlink additionally has a most month-to-month request capability, as detailed within the desk beneath. What’s the most cost-effective option to route 12,000 job requests from the Coding Agent and Writing Agent to the Advertising and marketing, IT, and Operations departments?
Provide & Demand

Routing Value / Capability

Implementation
- Knowledge: Load the information for agent provide capacities and division request calls for, together with the price and capability for every arc flowing from an agent to a hub or on to a division.
## knowledge
nodes = knowledge["nodes"]
provides = knowledge["supplies"]
calls for = knowledge["demands"]
arcs = [(a, b) for a, b, _, __ in data["arcs"]]
prices = {(a, b): c for a, b, c, __ in knowledge["arcs"]}
capacities = {(a, b): cap for a, b, _, cap in knowledge["arcs"]}
- Mannequin: Create a Gurobi mannequin with the identify “Community”.
## mannequin
import gurobipy as gp
mannequin = gp.Mannequin("Community")
- Variables: Outline a steady variable for every arc to characterize the variety of requests flowing from one node to a different, with an higher certain equal to the arc’s capability.
## variables
X = mannequin.addVars(arcs, lb=0, ub=capacities, vtype=GRB.CONTINUOUS, identify="x")
- Constraints: For every node (together with brokers, agent hubs and departments), the sum of provide and influx requests ought to equal the sum of demand and outflow requests.
## constraints: circulate stability at every node
for i in nodes:
mannequin.addConstr(
provides[i] + gp.quicksum(X[(j, i)] for j in nodes if (j, i) in arcs)
== calls for[i] + gp.quicksum(X[(i, j)] for j in nodes if (i, j) in arcs),
identify=f"{i}_balance_constr",
)
- Goal: Reduce the full value of all requests from an agent to an agent hub or to a division straight.
## goal: decrease complete routing value
mannequin.setObjective(
gp.quicksum(prices[(i, j)] * X[(i, j)] for i, j in arcs),
GRB.MINIMIZE,
)
Enterprise Influence
Agent routing optimization helps resolve what number of requests to ship alongside every hyperlink so all division demand is met on the lowest value, whereas contemplating the workflow capability and system limitations.
Optimum Outcome
We use mannequin.ObjVal to get the optimum goal worth for complete value. Then we use X[(i,j)].X to print the variety of requests flowing from every enter node to every output node.
print(f"Complete Value: {spherical(mannequin.ObjVal, 2)}")
for (i,j) in arcs:
if X[(i,j)].X > 0:
print(f"Ship {X[(i,j)].X} models of circulate on the arc from {i} to {j}")
As proven within the output beneath, we see that the optimum resolution prices $5,630 per 30 days to meet 12k requests demanded by Advertising and marketing, IT and Operations groups.
================ Community Routing Downside: Agent Routing ================
Minimal complete routing value: $5,630.00
Arc Move Cap Value/req Complete Value
-------------------------------------------------------------------------------------
Coding Agent -> Advertising and marketing Dept 1500 2000 0.80 1,200.00
Coding Agent -> IT Dept 2000 2000 0.60 1,200.00
Coding Agent -> Operations Dept 1200 1200 0.30 360.00
Coding Agent -> Relay Hub A 1200 1500 0.30 360.00
Coding Agent -> Relay Hub B 600 1200 0.20 120.00
Writing Agent -> Advertising and marketing Dept 2000 2000 0.50 1,000.00
Writing Agent -> IT Dept 1000 1000 0.20 200.00
Writing Agent -> Operations Dept 1000 1000 0.20 200.00
Writing Agent -> Relay Hub A 300 2000 0.40 120.00
Writing Agent -> Relay Hub B 1200 1200 0.20 240.00
Relay Hub A -> Advertising and marketing Dept 1500 1500 0.30 450.00
Relay Hub B -> IT Dept 1000 1000 0.10 100.00
Relay Hub B -> Operations Dept 800 1000 0.10 80.00
Demand achievement:
Advertising and marketing Dept: acquired 5000 / wanted 5000
IT Dept: acquired 4000 / wanted 4000
Operations Dept: acquired 3000 / wanted 3000
Simulations
After operating 500 possible options with random request routing from brokers to departments, we are able to estimate that the optimum outcome reduces prices by 33% ($8,425.98 − $5,630.00 = $2,795.98) on common.

──────────────────────────────────────────────────
Community — Agent Routing
──────────────────────────────────────────────────
Minimal (Optimum) : $5,630.00
Sim imply : $8,425.98
Sim min : $5,750.00
Sim max : $11,150.00
Possible options : 500/500
──────────────────────────────────────────────────
Take House Message
On this article, we cowl 4 widespread optimization patterns in operations analysis and their sensible enterprise influence, utilizing AI agent planning eventualities:
- Set Protecting: Select the smallest set of brokers that also covers all required duties, expertise, or enterprise features, with the target of minimizing value with out leaving gaps in functionality.
- Project: Determine which agent ought to deal with every challenge, with the purpose of maximizing total output worth.
- Knapsack: Choose the perfect bundle of brokers or options underneath a set funds, to maximise complete output tokens.
- Community: Design workflows throughout a community of brokers to fulfill division and consumer demand on the lowest value underneath capability constraints.
Advanced agent planning turns into tractable when it’s framed as a commonplace optimization mannequin with variables, constraints, and an goal. Fashionable solvers like Gurobi can shortly discover optimum options that considerably cut back spend or enhance return on funding.
Extra Sources Like This

