Optimal Dispatch of Power Generators: Problem-Based

This example shows how to schedule two gas-fired electric generators optimally, meaning to get the most revenue minus cost. While the example is not entirely realistic, it does show how to take into account costs that depend on decision timing.

Problem Definition

The electricity market has different prices at different times of day. If you have generators supplying electricity, you can take advantage of this variable pricing by scheduling your generators to operate when prices are high. Suppose that you control two generators. Each generator has three power levels (off, low, and high). Each generator has a specified rate of fuel consumption and power production at each power level. Fuel consumption is 0 when the generator is off.

load dispatchPrice; % Get poolPrice, which is the revenue per MWh
bar(poolPrice,.5)
xlim([.5,48.5])
xlabel('Price per MWh at each period')

There is a cost to start a generator after it has been off. Also, there is a constraint on the maximum fuel usage for the day. This constraint exists because you buy your fuel a day ahead of time, so you can use only what you just bought.

Problem Notation and Parameters

You can formulate the scheduling problem as a binary integer programming problem. Define indexes i, j, and k, and a binary scheduling vector y, as follows:

nPeriods = the number of time periods, 48 in this case.

i = a time period, 1 <= i <= 48.

j = a generator index, 1 <= j <= 2 for this example.

y(i,j,k) = 1 when period i, generator j is operating at power level k. Let low power be k = 1, and high power be k = 2. The generator is off when sum_k y(i,j,k) = 0.

Determine when a generator starts after being off. To do so, define the auxiliary binary variable z(i,j) that indicates whether to charge for turning on generator j at period i.

z(i,j) = 1 when generator j is off at period i, but is on at period i + 1. z(i,j) = 0 otherwise. In other words, z(i,j) = 1 when sum_k y(i,j,k) = 0 and sum_k y(i+1,j,k) = 1.

You need a way to set z automatically based on the settings of y. A linear constraint below handles this setting.

You also need the parameters of the problem for costs, generation levels for each generator, consumption levels of the generators, and fuel available.

poolPrice(i) -- Revenue in dollars per MWh in interval i

gen(j,k) -- MW generated by generator j at power level k

fuel(j,k) -- Fuel used by generator j at power level k

totalFuel -- Fuel available in one day

startCost -- Cost in dollars to start a generator after it has been off

fuelPrice -- Cost for a unit of fuel

You got poolPrice when you executed load dispatchPrice;. Set the other parameters as follows.

Notice that generator 2 is a bit more efficient than generator 1 at its corresponding operating points (low and high), but generator 1 at its high operating point is more efficient than generator 2 at its low operating point.

Variables for Solution

To set up the problem, you need to encode all the problem data and constraints in problem form. The variables y(i,j,k) represent the solution of the problem, and the auxiliary variables z(i,j) indicate whether to charge for turning on a generator. y is an nPeriods-by-nGens-by-2 array, and z is an nPeriods-by-nGens array. All variables are binary.

The constraint is that the fuel used is no more than the fuel available.

fuelcons = fuelUsed <= totalFuel;

Set the Generator Startup Indicator Variables

How can you get the solver to set the z variables automatically to match the active/off periods of the y variables? Recall that the condition to satisfy is z(i,j) = 1 exactly when sum_k y(i,j,k) = 0 and sum_k y(i+1,j,k) = 1.

Therefore, include these linear inequality constraints in the problem formulation.

sum_k ( - y(i,j,k) + y(i+1,j,k) ) - z(i,j) < = 0.

Also, include the z variables in the objective function cost. With the z variables in the objective function, the solver attempts to lower their values, meaning it tries to set them all equal to 0. But for those intervals when a generator turns on, the linear inequality forces z(i,j) to equal 1.

Generator 2 runs longer than generator 1, which you would expect because it is more efficient. Generator 2 runs at its high power level whenever it is on. Generator 1 runs mainly at its high power level, but dips down to low power for one time unit. Each generator runs for one contiguous set of periods daily, and, therefore, incurs only one startup cost each day.

Check that the z variable is 1 for the periods when the generators start.