Dispatch
Dispatch(demand, capacity, resources, active, minimum, increment)
Allocates «capacity» of a list of «resources» to meet the total «demand». For example, given the generating capacity in MW of a set of power plants «resources», it dispatches them so that the sum of the amount capacity dispatched for all plants meets the «demand» in MW. It works along the list of plants («resources») allocating its generation up to its maximum capacity, until it reaches the demand. If the plants have been ordered by marginal cost ($/MWh), this method meets the demand at minimum generation cost. It returns an array of allocated capacity, each with a value between 0 and «capacity», indexed by «resources». Usually, the first n-1 elements of «resources» are allocated at full «capacity»; the nth «resources» may be allocated partially; and the remaining «resources» are allocated at zero. If the «demand» is greater than sum of «capacity» over «resources», all elements will be equal to their full «capacity», but the result will not meet the demand.
The optional «active» flag, also indexed by «Resource», is true (1) or false (0) to indicate whether each «Resource» can be used to fill the demand. This is useful if some elements are unavailable, or if you want to dispatch over a number of regions, in which resources in each region may only supply the demand in that region. (See the Electric power example below.)
The optional parameter «minimum» specifies that the resource, if dispatched at all must be at least «minimum» capacity. The optional parameter «increment» specifies that the resource must be dispatched with an integral number of increments of capacity. Parameters «minimum» and «increment» may be indexed by «resources» to specify different values for each resource. If «minimum» (or «increment») has the same value as «capacity», it means that that resource must be allocated fully or not at all. A Null or zero values for «increment» (or «minimum») for a resource specifies that there is no minimum increment (or the minimum is zero). Even if «minimum» is not a multiple of «increment», the result will always be a multiple of «increment». Thus, with positive «increment» or «minimum» values, it is possible that the total capacity dispatched will be greater than the demand.
Null values in capacity are passed through as Null values in the result.
Example Uses
Electrical power dispatch
A certain country has a set of electrical power plants (the Resources), each with a maximum power that it can supply, its capacity in Megawatts (MW), to meet the total demand in MW. Each plant has a marginal cost of generation in $/KWh as Marginal_cost. We sort the plants in order of increasing marginal cost. Then the Dispatch function computes compute how much power to dispatch from each plant to minimize the total cost:
Index Plants_ordered := SortIndex(Marginal_cost, Plants) Dispatch(Demand, Plant_Capacity[Plants = Plants_ordered], Plants_ordered)
In a variation on this problem, the country is divided into regions. Each region has its own demand (so Demand_by_region is indexed by Region), and each region can only consume power from plants located in that region. Region_by_plant gives the region in which each Plant is located. We use the optional parameter active to control which plants are available for allocation in each Region
Index Plants_ordered := SortIndex(Marginal_cost, Plants) Dispatch(Demand_by_county, Capacity[Plants = Plants_ordered], Plants_ordered, active: Region_by_plant[Plants = Plants_ordered]=Region)
Investment Allocation
An investor creates a model that ranks possible investment by quality (perhaps MIrr, for example). He has a fixed budget to invest, and has limits on the maximum amount that can be allocated to any given investment (the maximum varies by investment). He's already sorted his investments by ascending quality. He uses Dispatch to determine how much money to place in each investment.
Dispatch( investment_amount, allocation_maximum, Investments )
Project Budgeting
A company has a set of potential projects, sorted by expected ROI. They have a fixed budget to invest. Each project undertaken must be funded at a minimum level, or not at all. However, once funded, a project with a better ROI should receive as much funding as possible, up to the full project_cost.
Dispatch( Budget, Project_cost, Project, minimum:Project_minimum )
Dispatching in reverse
In come cases, you may want to dispatch from the end of the «Resource» index first, just because of how you defined your index. For example, you want to may dispatch the oldest along an Age index, where index Age is in increasing order. This is facilitated by creating a reverse index mapping.
- Variable ReverseAge :=
Slice(Age, size(Age)+1-@Age)
Each parameter that uses an array indexed by «Resource» is then reversed, and the final result of Dispatch is reversed.
Dispatch( Consumption, Inventory[Age=ReverseAge], ReverseAge, isActive[Age=ReverseAge] )[ ReverseAge=Age ]
Notice that you have to reverse the «capacity», «active», «minimum» and «increment» parameter.
Enable comment auto-refresher