# Plan

A plan is defined by a unique ID, a label, a unit, and a list of components, with their corresponding level (time series of values). Components can be commodities, herds or plans. The nature of the information corresponding to the level of the component within the plan is defined in the corresponding section for each data type. In addition, an attribute specifying the type of calculation to be performed is required for such components of the Plan, depending on their type.

In addition to commodities, herds or plans, a plan can also include a reference to a Script, meaning that the script will be executed in the context of the containing Plan when that plan is evaluated. In such a case there is no level and no calculation type attribute, but the keyword run is used before the script name (new feature as from version 1.1.0).

If the component is a Commodity, it can be consumed, produced or available, as mentioned in the corresponding section.

If the component is a Herd, the calculation type attribute can take only one value, namely phased (new feature as from version 1.1.0), as the level always correspond to phasing over an incremental set of values. The meaning of phasing is explained below for plans.

If the component is itself a plan, calculation can be performed in two different ways, annual or phasing, and the level can correspond to either total or to incremental values, as explained below over a small example.

### Plan-in-plan Basic calculation modes: annual and phasing

Let us assume a commodity Rice grain, a plan Rice crop representing one hectare of rice, and a plan Rice perimeter specifying the number of hectares of rice being put under irrigation during a project, as shown below:

Years | 1 | 2 | 3 | 4-20
--- | --- | --- | --- | ---
Plan Rice crop (1 ha)
Rice grain produced | 2.0 | 2.5 | 3.0 | 3.5
Plan Rice perimeter
Plan Rice crop | 100 | 200 | 300 | 0
(ha, incremental number)

The price of rice is constant at 150 per ton. The yield is 1.2 ton/ha without project, and would gradually increase to 3.5 t/ha with project. Rice area would be 100 ha in year 1, 200 more in year 2, 300 more in year 3.

Rice production can be calculated in two different ways:

(i) If the yield depends on the project’s year, then the yield for a given year is multiplied by the total area. In the above example, production year 3 would be equal to 600 ha x 3.0 t/ha = 1.800 t. This calculation mechanism is called the annual mode. The calculation type attribute is annual.

(ii) a) If the yield in a given year depends on the age of the activity, i.e. on the number of years since a particular unit of the activity got into the project, the calculation will have to be done a different way, the so called phasing mode. This is very common when a new policy or a new technology being introduced by a program would have a learning phase over several years.

In the above example, production in year 3 would be equal to:

100 ha started in year 1 × 3.0 t/ha = 300
200 ha started in year 2 × 2,5 t/ha = 500
300 ha started in year 3 × 2.0 t/ha = 600

Total = 1.400 t

The calculation type attribute for phasing mode is phasadd in the above case, it would be phastot if the level of Plan Rice crop was in total number of hectares, i.e. [100 300 600].

(ii) b) If the yield depends on the actual «age» of the activity at the beginning of the project, then a «reverse» phasing compared to the above example is done. A typical use would be to project the production of a set of an existing perennial tree crop with a mix of trees of different age.

With the above example data, production in year 3 would be equal to:

100 ha age 1 in year 1 × 3.0 t/ha = 300
200 ha age 2 in year 1 × 3,5 t/ha = 700
300 ha age 3 in year 1 × 3,5 t/ha = 1.050

Total 2.050 t

The calculation type attribute for reverse phasing mode is phasold.

This example illustrates several important points:

- When defining a plan, it is necessary to specify the calculation mode for each commodity or plan component.
- When the without project situation is not zero, it will have to be defined as a different plan (e.g. a plan «rice without project»), and the incremental values can be calculated by difference (a plan made of a plan «project» at level 1 and a plan «without project» at level – 1, with annual calculation mode).
- In the case of standard phasing mode, it is necessary to specify whether the level of the component is expressed in total number of units or in incremental numbers (over the previous year).
- The level will always be in total numbers in the case of annual mode and reverse phasing mode.

It is important to have a clear understanding of the phasing calculation mechanism, particularly if there are several nested levels of phasing calculations.

In the current MADS specifications, phasing is an option only for Plans (within a Plan definition). Commodities are always calculated in annual mode; they can be phased in by first defining them within an inner Plan. Herds are always calculated in phasing mode over an incremental set of values.

### Example of Plan

plan Project = ‹Project› , unit = ‹Full network› ;
Irrigated_Rice phastot [0 100 250 450] ;
Floating_Rice phastot [0 75 150 250] ;
Corn_Crop phastot [0 20 60 120 150] ;
Traditional_Rice annual [-200] ;
Ag_extension cons [4.0] ;
Land_development cons [396.6 486.4 177.7 64.7 39.8 0] ;
run Eco_Analysis ;
end;

The first three components of the plan are other plans in phasing mode, the fourth component is a plan in annual mode, then there are two commodities, and a script (see the Plaine de Daye case for a complete example).

### Editor templates

A Plan is defined as follows, possibly using the -Plan template:

plan ID = ‹label› , unit = ‹unit› ;
// plan items
end;

Each item in a Plan is then defined following its syntax, as shown in the above example. When activating Content-Assist (with Ctrl-Space key combination), the following options will be offered:

- four templates, one for each possible type of Plan Item (commodity, herd, plan or script)
- the list of all defined commodities, herds or plans (with the exception of the current plan, that is not allowed to include itself)
- the list of possible keywords, i.e. run to be followed by a script name, or end / fin to terminate the plan definition.

Commodity or plan in plan:

Riz cons [ 0 0 ]; // or read function
RizTrad annual [ 0 0 ]; // or read function

The commodity or plan reference and calculation attributes are picked from lists.

Herd or Script:

SmallHerd phased [ 0 0 ]; // or read function
run AScript ;

The corresponding template provides the required keyword and a list to select from.