Skip to content

Monte Carlo Loop: Electricity Generation Costs

Random feasible outputs from five power plants, compared with the exact $28,000 cost of meeting 1,000 MWh demand.

Oct 28, 20267 min readTime O(k·n)Space O(n)
Cost · 1,000 MWhExact optimum: $28,0000 samples

Five power plants, one demand target

This illustrative dispatch problem minimizes the cost of generating exactly 1,000 MWh. The coefficients are example values, not measured data from a utility.

min⁡f(x)=20x1+45x2+60x3+25x4+35x5\min f(x)=20x_1+45x_2+60x_3+25x_4+35x_5
SourceCost ($/MWh)Capacity (MWh)
Nuclear20300
Natural gas45250
Oil60200
Coal25350
Hydroelectric35250
∑i=15xi=1000,0≤xi≤ci\sum_{i=1}^{5}x_i=1000,\qquad 0\le x_i\le c_i

A feasible Monte Carlo loop

Independent continuous random draws almost never sum to exactly 1,000. Instead, shuffle the plant order and sample each output within bounds that leave enough capacity for the remaining plants. Assign the final plant the remaining demand. Every dot represents one feasible draw and its cost; the horizontal axis is the sample index.

These sequential feasible draws are not uniform over the entire feasible polytope. They demonstrate stochastic search, not an unbiased probability model or a guaranteed optimizer. The plot repeats after 200 samples.

The exact reference result

For this linear deterministic model, use the cheapest available capacity first:

x∗=(300,100,0,350,250),f(x∗)=28000x^*=(300,100,0,350,250),\qquad f(x^*)=28000

The supplied 27,750total is also an arithmetic error:27,750 \text{total is also an arithmetic error}: 6,000 + 4,500+4,500 + 8,750 + 8,750=8,750 = 28,000.

The allocation (300,0,0,350,350)(300,0,0,350,350) is infeasible: hydroelectric generation exceeds its 250 MWh capacity. The corrected allocation uses 100 MWh of natural gas.

Monte Carlo can approach this reference cost, but linear programming is the efficient exact method here. This illustration does not model ramp limits, losses, emissions, or uncertain demand.

Reference: Economic Dispatch as a Linear Optimisation Problem.

All algorithms

Comments (1)

Demo discussion
  • Kunigunda Hönig

    Kunigunda@organicwolf477

    Sampling feasible dispatches avoids almost every random five-plant draw failing the exact demand constraint.