Module 6 — State, dynamics and decision-making
Lesson 6 of 8
Utility and cost
In the previous lessons, we introduced:
- objectives
- constraints
- optimisation
- feasible and infeasible solutions
Now we need a way to describe how good or bad an outcome is.
That is where utility and cost come in.
These ideas are central to economics, optimisation, decision-making and artificial intelligence.
At a basic level:
Utility represents value or benefit.
and:
Cost represents something undesirable that we want to reduce.
An optimiser can then try to:
[ \max \text{utility} ]
or:
[ \min \text{cost} ]
But the interesting part is not the mathematics.
The interesting part is:
What are we choosing to call valuable, and what are we choosing to call costly?
Utility
Utility is a way of representing how desirable an outcome is.
Suppose a decision-maker has several possible outcomes:
[ A, B, C ]
We might assign:
[ U(A)=10 ]
[ U(B)=7 ]
[ U(C)=2 ]
This means:
Outcome A is preferred to B, and B is preferred to C.
The exact numbers do not necessarily mean that A is literally five times better than C.
They may simply encode preference.
Utility as a decision signal
Suppose an autonomous system has three possible actions.
It estimates:
| Action | Expected utility |
|---|---|
| A | 12 |
| B | 18 |
| C | 9 |
If its objective is:
[ \max U(a) ]
it chooses:
[ a^* = B ]
because:
[ 18 > 12 > 9 ]
This is the basic idea.
Utility converts many possible outcomes into something the decision system can compare.
Cost
Cost works in the opposite direction.
Suppose three actions have costs:
| Action | Cost |
|---|---|
| A | 20 |
| B | 8 |
| C | 15 |
If the objective is:
[ \min C(a) ]
the optimiser chooses:
[ a^* = B ]
because:
[ 8 < 15 < 20 ]
Again, simple in principle.
Utility and cost are often interchangeable
In many cases, maximising utility and minimising cost are mathematically equivalent.
If:
[ U(a) = -C(a) ]
then:
[ \max U(a) ]
is equivalent to:
[ \min C(a) ]
So why use both ideas?
Because they help us describe different kinds of problems.
We often talk about:
maximising health benefit
or:
maximising consumer welfare
or:
maximising reliability
but:
minimising electricity cost
or:
minimising waiting time
or:
minimising emissions
The underlying mathematics can be similar.
The framing reflects what we care about.
Not all costs are money
This is important.
When people hear the word:
cost
they often think:
[ £ ]
or:
[ $ ]
But optimisation uses cost much more broadly.
A cost could represent:
- money
- time
- emissions
- discomfort
- risk
- fuel
- congestion
- waiting
- energy use
- error
- uncertainty
- environmental damage
A cost function might be:
[ C(a)
\text{financial cost} + \text{emissions penalty} + \text{delay penalty} ]
The optimiser does not care whether these are literally paid in currency.
It only sees the numerical representation we give it.
Not all utility is money either
Utility might represent:
- health
- comfort
- happiness
- reliability
- access
- convenience
- safety
- social welfare
- service quality
For example, a household might value:
[ U = \text{comfort}
\text{electricity bill} ]
A hospital might value:
[ U = \text{patient benefit}
\text{treatment burden} ]
A transport system might value:
[ U = -\text{journey time} -\text{emissions} -\text{congestion} ]
These functions are attempts to convert multiple outcomes into something that can guide decisions.
The difficulty: different things use different units
Suppose we want to compare:
- pounds
- minutes
- tonnes of carbon
- probability of injury
These are not naturally commensurate.
We cannot simply write:
[ £10 + 5 \text{ minutes} + 2 \text{ tonnes} ]
and assume the number means anything.
So we introduce weights.
For example:
[ C
\alpha \times \text{financial cost} + \beta \times \text{delay} + \gamma \times \text{emissions} ]
The weights:
[ \alpha,\beta,\gamma ]
convert these outcomes into a common decision scale.
But this creates another question:
Who chooses the weights?
That is where technical optimisation becomes a value question.
Value of time
Transport economics provides a simple example.
Suppose Route A costs:
[ £5 ]
and takes:
[ 60 \text{ minutes} ]
Route B costs:
[ £15 ]
and takes:
[ 30 \text{ minutes} ]
Which is better?
It depends on how much we value time.
If time is valued at:
[ £20/\text{hour} ]
then Route A has total generalised cost:
[ 5 + 20 = £25 ]
because one hour is worth £20.
Route B has:
[ 15 + 10 = £25 ]
because half an hour is worth £10.
Now they are equivalent.
But if time is valued differently, the decision changes.
Different people have different utility
This becomes more complicated because people are not identical.
Suppose two people face the same choice.
One person has a high income and values time very highly.
Another has little disposable income and is much more sensitive to price.
The same journey may create different utility for each person.
We might write:
[ U_i(a) ]
where (i) represents the individual.
Then:
[ U_1(a) \neq U_2(a) ]
even for the same action.
This is fundamental.
People are heterogeneous.
A system that assumes one universal utility function may misrepresent how different people actually experience the same outcome.
Electricity and utility
Consider a household deciding whether to use electricity now or later.
Suppose electricity is expensive at 18:00 and cheaper at 22:00.
For a dishwasher, waiting may have almost no cost.
For cooking dinner, waiting four hours may be unacceptable.
So the household's utility depends not only on energy consumption, but on:
- timing
- convenience
- comfort
- necessity
- preference
We could imagine:
[ U_i
\text{value of energy service}
\text{electricity cost}
\text{inconvenience} ]
The same electricity price can therefore create very different decisions for different households and different devices.
Price is not utility
This distinction matters.
A price tells us:
what something costs in the market.
It does not tell us:
how valuable it is to a particular person.
Suppose electricity costs:
[ £0.50/\text{kWh} ]
For one consumer, running a washing machine now may not be worth it.
For another consumer, electricity is needed to power essential medical equipment.
Same price.
Very different utility.
So:
[ \text{price} \neq \text{value} ]
The two interact, but they are not the same thing.
Willingness to pay
Economics often uses willingness to pay as a proxy for utility.
If someone is willing to pay:
[ £20 ]
for something, we might infer that they value it by at least that much.
This can be useful.
But it has limitations.
Willingness to pay depends on:
- preferences
- income
- wealth
- available alternatives
- urgency
A wealthy person may be able to express strong willingness to pay.
A poorer person may value something enormously but simply be unable to pay much.
So:
[ \text{willingness to pay} ]
is not always equivalent to:
[ \text{importance} ]
or:
[ \text{need} ]
This becomes very important in allocation problems involving essential resources.
Cost to whom?
Just as utility can differ between people, costs can fall on different people.
Suppose a factory produces something cheaply.
Its private cost is:
[ C_{\text{factory}} ]
But production creates pollution affecting nearby residents.
Then society may experience:
[ C_{\text{social}}
C_{\text{factory}} + C_{\text{pollution}} ]
If the factory only optimises its own cost, the pollution may not appear anywhere in its decision.
This is called an externality.
Externalities
An externality occurs when one participant's actions create costs or benefits for others that are not fully reflected in the participant's own objective.
Examples include:
- pollution
- traffic congestion
- noise
- network congestion
- financial contagion
- vaccination
- education
- innovation
Suppose a driver chooses the fastest route.
Their private objective might be:
[ \min \text{my journey time} ]
But their presence adds congestion for everyone else.
The social cost is larger than the private cost.
If thousands of people optimise individually, the system can perform badly.
Private cost versus social cost
We can write:
[ C_{\text{social}}
C_{\text{private}} + C_{\text{external}} ]
A system designer may want decisions to reflect:
[ C_{\text{social}} ]
rather than only:
[ C_{\text{private}} ]
This is one reason taxes, charges and prices are sometimes used.
They attempt to make external effects visible to the decision-maker.
Utility and social welfare
If many people are involved, we may want some system-level measure.
Suppose there are (n) individuals with utilities:
[ U_1,U_2,\ldots,U_n ]
A simple social-welfare function might be:
[ W
\sum_{i=1}^{n} U_i ]
Then the system tries to:
[ \max W ]
This is utilitarian aggregation.
It asks:
Which decision produces the greatest total utility?
This is powerful.
It also creates difficult questions.
Total utility can hide distribution
Consider two outcomes.
Outcome A
| Person | Utility |
|---|---|
| 1 | 100 |
| 2 | 0 |
Total:
[ 100 ]
Outcome B
| Person | Utility |
|---|---|
| 1 | 50 |
| 2 | 50 |
Total:
[ 100 ]
If our objective is only:
[ \max \sum_i U_i ]
the two outcomes are identical.
But many people would care about the distribution.
This tells us:
Total utility does not automatically capture fairness.
The same total, very different society
Consider:
Society A
[ (100,100,100,100) ]
Society B
[ (397,1,1,1) ]
Total utility in both is:
[ 400 ]
But the distributions are radically different.
A pure sum treats them as equal.
A fairness-sensitive objective may not.
This leads to different social-welfare functions.
Weighted utility
We could use weights:
[ W
\sum_i w_i U_i ]
where:
[ w_i ]
represents how strongly the system values person (i)'s utility.
This may allow us to protect:
- vulnerable users
- essential services
- disadvantaged groups
But again:
Who chooses the weights?
Weights can encode policy.
They can also encode bias.
Minimum utility
Another approach is to focus on the worst-off person.
For example:
[ \max \min_i U_i ]
This is a max-min objective.
Rather than maximising total utility, we try to improve the minimum outcome.
This can produce much more equal allocations.
But it may reduce total efficiency.
Again, there is no universal answer.
The objective reflects the values we choose.
Utility under uncertainty
Utility becomes especially important when outcomes are uncertain.
Suppose you can choose between:
Option A
Guaranteed:
[ £50 ]
Option B
50% chance of:
[ £120 ]
and 50% chance of:
[ £0 ]
Expected monetary value of B is:
[ 0.5(120)+0.5(0)=60 ]
So B has higher expected money.
Would everyone choose it?
No.
Some people prefer the guaranteed £50.
This means utility may not increase linearly with money.
Risk aversion
A risk-averse person may have a concave utility function.
For example:
[ U(w)=\sqrt{w} ]
Then the utility of certain wealth and uncertain wealth can differ in ways that monetary expectation alone misses.
This allows decision theory to represent attitudes toward risk.
The important idea is:
£100 does not necessarily create twice the utility of £50.
Value can depend on context and existing resources.
Diminishing marginal utility
Suppose someone has no food.
Giving them £10 may be extremely valuable.
Now suppose someone already has £10 million.
Giving them another £10 may have almost no meaningful effect.
This motivates the idea of diminishing marginal utility.
Mathematically:
[ \frac{dU}{dw}>0 ]
but:
[ \frac{d^2U}{dw^2}<0 ]
Utility increases with wealth, but at a decreasing rate.
This matters when we think about fairness and distribution.
Cost functions can also be nonlinear
Suppose a power line is lightly loaded.
Increasing flow slightly may create little additional concern.
But as it approaches its thermal limit, additional flow becomes increasingly risky.
A cost function might therefore rise sharply near the boundary.
For example:
[ C(F)
\frac{1}{F^{\max}-F} ]
As:
[ F \rightarrow F^{\max} ]
the cost becomes very large.
Nonlinear costs can encode the idea that some states become much less desirable near critical limits.
Penalty functions
Sometimes instead of making something a hard constraint, we include it as a penalty.
Suppose we want voltage to remain close to:
[ 1.0 ]
per unit.
We might define:
[ C_V
(V-1)^2 ]
Small deviations produce small penalties.
Large deviations produce much larger penalties.
This lets the optimiser trade small violations against other objectives.
Utility and AI training
These ideas also appear inside machine learning itself.
A model is trained by minimising a loss function:
[ \theta^*
\arg\min_\theta L(\theta) ]
The loss is effectively a cost function.
For regression, we might use:
[ L
\frac{1}{n} \sum_i (y_i-\hat{y}_i)^2 ]
For classification, we might use cross-entropy.
The learning algorithm tries to reduce that cost.
So even before AI makes external decisions, it is already optimising an internal cost function.
Loss is not the same as real-world utility
This distinction is crucial.
Suppose a medical model minimises prediction error.
Its training objective might be:
[ \min L_{\text{prediction}} ]
But the healthcare system cares about:
[ \max U_{\text{health}} ]
These are not the same objective.
A model with slightly worse prediction loss might produce better clinical outcomes if used differently.
Always distinguish:
[ \text{model loss} ]
from:
[ \text{system utility} ]
Cost can be hidden in the system boundary
Imagine an AI system automates administrative work.
The organisation measures:
[ \text{cost savings} ]
and sees:
[ £10 \text{ million} ]
saved.
But suppose the automation creates:
- longer waits for citizens
- more appeal cases
- additional unpaid work for users
- higher costs elsewhere in government
If those consequences are outside the model boundary, the AI may appear highly efficient.
The apparent cost is:
[ C_{\text{measured}} ]
while the actual system cost may be:
[ C_{\text{total}}
C_{\text{measured}} + C_{\text{hidden}} ]
This is why system boundaries matter.
Who experiences the cost?
A system can also reduce organisational cost by shifting burden onto other people.
For example:
Replace staff support with a complex online self-service portal.
The organisation may save money.
Users now spend much more time navigating the process.
Organisational cost goes down.
Social cost may go up.
So we should ask:
Cost to whom?
This is often as important as:
How much cost?
Cost causation
Another important question is:
Who caused the cost?
Suppose an electricity network needs reinforcement because a particular pattern of demand creates congestion.
The system may need:
[ £10 \text{ million} ]
of additional investment.
How should that cost be recovered?
Possible approaches include:
- spread equally across everyone
- charge users according to energy consumed
- charge users according to peak demand
- charge those whose behaviour contributed to the need
- recover it through general taxation
These choices create very different incentives and fairness outcomes.
A cost function tells us how much cost exists.
It does not automatically tell us how that cost should be allocated.
Cost allocation is a different problem
Suppose total system cost is:
[ C=£100 ]
That tells us the amount to recover.
But among three participants:
[ A,B,C ]
we still need to decide:
[ c_A+c_B+c_C=100 ]
There may be many possible allocations.
For example:
[ (33.3,33.3,33.3) ]
or:
[ (80,10,10) ]
or:
[ (20,30,50) ]
All recover the same total cost.
They are not equally fair.
This moves us toward the problem of allocation.
Utility and allocation
The same is true for benefits.
Suppose a new system creates:
[ £1 \text{ million} ]
of total value.
Who receives it?
Workers?
Customers?
Investors?
Government?
Local communities?
Again, total utility or total surplus does not determine distribution.
We need an allocation rule.
Efficiency versus distribution
A system may maximise:
[ \text{total surplus} ]
while distributing that surplus very unevenly.
This gives us two different questions:
Efficiency
How much total value is created?
Distribution
Who receives that value?
These are not interchangeable.
A system can be highly efficient and politically or socially unacceptable.
Another system can be very equal but destroy substantial value.
Good system design needs to understand both.
Utility is not objective truth
Utility functions are models.
They are representations of preference, welfare or value.
We should not mistake:
[ U(x) ]
for a physical measurement like:
[ 10 \text{ kg} ]
or:
[ 5 \text{ metres} ]
Utility depends on:
- assumptions
- preferences
- context
- measurement choices
In many real systems, utility is only partially observable.
That means caution is needed when we say:
The algorithm maximises welfare.
We should ask:
Whose welfare, measured how?
Revealed preferences
One way economists infer utility is through observed choices.
Suppose someone repeatedly chooses:
[ A ]
over:
[ B ]
We might infer:
[ U(A)>U(B) ]
This is called revealed preference.
It avoids asking people to assign numerical utility directly.
But choices are constrained by:
- income
- information
- availability
- social norms
- market structure
So revealed preference is useful but not perfect.
Stated preferences
We can also ask people directly.
For example:
How much would you pay to avoid a one-hour delay?
or:
How important is reliability to you?
These are stated preferences.
But people may answer differently from how they behave.
Again, utility measurement is difficult.
Utility can change
Preferences are not fixed.
A person's utility can depend on:
- time
- wealth
- health
- context
- social conditions
- previous outcomes
The same action may create different utility tomorrow than today.
This matters for dynamic systems.
System utility is often contested
In public systems, there may be no agreed utility function.
Consider a government deciding how to allocate infrastructure funding.
Possible objectives include:
- maximise GDP
- reduce regional inequality
- reduce emissions
- improve resilience
- create jobs
- improve quality of life
Different political philosophies may assign different utility to these outcomes.
The optimiser cannot resolve that disagreement.
It can help expose the consequences of different choices.
Optimisation can make values explicit
This is one of optimisation's great strengths.
Suppose two policymakers disagree.
One says:
prioritise economic growth.
Another says:
prioritise emissions reduction.
Instead of arguing vaguely, we can model both objectives and ask:
What outcomes follow from each?
Or:
Where are the trade-offs?
This does not make politics disappear.
It can make the disagreement more legible.
Utility and constraints should not be confused
Some values may belong in the objective.
Others may belong in constraints.
Suppose we want:
cheap electricity
and:
no unsafe network operation.
Then we might write:
[ \min C_{\text{electricity}} ]
subject to:
[ |F_l|\leq F_l^{\max} ]
Safety is not traded against cost.
It defines the feasible region.
Similarly, certain rights may be better represented as constraints rather than small penalties in a utility function.
This is a major design choice.
Should everything have a price?
This leads to a deeper question.
If we can assign a cost to everything, should we?
Suppose we put prices on:
- pollution
- human life
- biodiversity
- privacy
- fairness
- democratic rights
Quantification can help decision-making.
But it can also create false precision.
Not everything important needs to become:
[ £x ]
Some things may be better treated as:
- hard constraints
- rights
- minimum standards
- protected entitlements
Good system design knows the difference.
A simple decision framework
When analysing utility and cost, ask:
1. What counts as benefit?
What is the system trying to create?
2. What counts as cost?
What is the system trying to avoid?
3. Who experiences the benefit?
Are some groups gaining more than others?
4. Who experiences the cost?
Are costs being shifted onto outsiders?
5. Are there externalities?
What is missing from the private objective?
6. Are we using a proxy?
Does the metric really represent what we care about?
7. Are different people assumed to have the same utility?
Should heterogeneity be represented?
8. Is distribution visible?
Could total utility improve while some people become much worse off?
9. Should something be an objective or a constraint?
Should safety, fairness or rights be tradeable at all?
10. Who caused the cost?
Does the cost-allocation rule reflect causation?
These questions help turn abstract optimisation into real system analysis.
Extending our framework
We can now expand the structure we have been building.
Prediction
What is likely to happen?
Objective
What are we trying to achieve?
Utility / cost
How do we represent what is good or bad?
Constraints
What is possible?
Optimisation
What is the best feasible action?
Decision
What do we actually do?
Allocation
Who receives scarce resources, costs or benefits?
We are moving steadily away from:
AI as prediction
toward:
AI as one component inside a decision system.
The key takeaway
Utility and cost give decision systems a way to compare outcomes.
[ \boxed{\text{Utility represents value or benefit.}} ]
[ \boxed{\text{Cost represents something we want to reduce.}} ]
But neither is neutral.
They depend on:
- what we measure
- whose preferences count
- which costs are inside the system boundary
- how externalities are treated
- how future outcomes are valued
- whether distribution matters
A system can minimise cost and still produce a terrible outcome.
A system can maximise total utility and still treat some people very badly.
So whenever an optimiser tells us:
This is the best solution
we should ask:
Best for whom?
According to what utility?
And whose costs are we counting?