Presentation of the example

The example illustrates the use of the Herd entity to model a small cattle herd in a tropical dry region, and the impact of a severe drought on such a herd. A first Herd model is developed to represent the herd in the absence of drought, then the model is copied and edited to produce a second model simulating a drought occurring in year 3 by changing the values of various parameters for that year, namely offtake rate and price, mortality, and birth rate.

The two Herd models require the definition of a number of commodities, for milk, feed, hides and manure. A plan is defined for each herd model, together with a table with the herd population projection and a small script to trigger the corresponding table production in each plan. Finally, a plan made of the difference between the two herd situations and an associated script and table are used to show the impact, in offtake numbers, stock variations, and financial terms.

Herd classes (age groups) are defined by an ID which is unique to the entire data set. The implications are:

The full .mads file and the output are shown below. The simulation clearly demonstrates that the herd would never recover from the drought in the absence of any animal intakes.

The complete herd.mads text

Country Name = 'countryName' ;
Project Name = 'projectName' ;
Data Set Name = 'dataSetName' ;
Currency Name = '000 CU' ;
Exchange Rate = 1000 to the US Dollar ;
OCC = 12 % ;
Project life = 20 years ;
File specs:
fileSpec F2 = 'c:/Users/msimeon/Documents/test2.ods' ; 
end;
Results as html;

// A model is made of declarations of type Commodity, Plan, Script or Table
// A script item can be a command (print, display, filespec or export), a variable declaration 
// or an instruction (variable declaration or variable Reference = expression)  
// where expression combines numbers, [series], varRef, commRef, functions using + - / * ^ or ()
// 
// Use ctrl-space for content proposals

commodity CowMilk = 'Cow Milk' , unit = 'liter' , price = 1.25 ;
commodity DM = 'Dry Matter' , unit = 'Kg' , price = 0.1 ;
commodity Hides = 'Hides' , unit = 'kg' , price = 1 ;
commodity Manure = 'Manure' , unit = 'kg/year' , price = 0.2 ;
//=====================================================================
herd CowHerd = 'Small herd' , unit = 'farm' ;

Herd Classes
Female groups
Female: JF ,label = 'Juvenile Female' , duration = 12 , Size : initial = 4.5 , maximum = 0 ,  
LiveWeight at entry = [ 20 ], CarcassYield = [47 ],  
Offtake : rate = [ 0 0 ], price = [40 ],
Death rate = [ 13 ] ;
Female: SF ,label = 'Subadult Female' , duration = 36 , Size : initial = 10 , maximum = 0 , 
LiveWeight at entry = [ 50 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 5 ], price = [ 90 ],
Death rate = [5 ] ;
Female: AF ,label = 'Adult Female' , duration = 132 , Size : initial = 20.5 , maximum = 0 , 
LiveWeight at entry = [ 250 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 5 ], price = [ 150 ],
Death rate = [ 3 ] ;
Male groups
Male: JM ,label = 'Juvenile Male' , duration = 12 , Size : initial = 4 , maximum = 0 ,
LiveWeight at entry = [ 20 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 10 ], price = [ 40 ],
Death rate = [ 13 ] ;
Male: SM ,label = 'Subadult Male' , duration = 36 , Size : initial = 7 , maximum = 0 ,
LiveWeight at entry = [ 70 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 20 ], price = [ 110 ],
Death rate = [ 5 ] ;
Male: AM ,label = 'Adult Male' , duration = 72 , Size : initial = 4 , maximum = 0 ,
LiveWeight at entry = [ 300 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 21 ], price = [ 200 ],
Death rate = [ 3 ] ;

Parturition and milk
Milk = CowMilk prod ;
Class AF :  
Birth rate per year = [ 50 ], 
Net Prolificacy Rate = [ 100 ] , Prob. of female at birth = [ 50 ] ,
Quantity per lactation = [ 136 ] ;

Intakes
Class SF :  Numbers = [ 0 0 0 0], price = [ 0 0 ] ;

Feed Requirements
Feed Item DM cons ;
Daily Quantity per unit LW
	// use template "-Herd Class Data" 
JF = [ 0.025 ] ;
SF = [ 0.025 ] ;
AF = [ 0.025 ] ;
JM = [ 0.025 ] ;
SM = [ 0.025 ] ;
AM = [ 0.025 ] ;

Other products and costs
// specify here commodity items proportional to herd classes 
// use template "-Herd Item"
Proportional Item Hides prod ;
Quantity per head per year
AF = [ 5 ] ;
AM = [2 ] ;
Proportional Item Manure prod ;
Quantity per head per year
JF = [ 0.5 ] ;
SF = [ 0.8 ] ;
AF = [ 1.5 ] ;
JM = [ 0.5 ] ;
SM = [ 0.8 ] ;
AM = [ 1.5 ] ;
end ;
//=====================================================================
herd CowHerd2 = 'Small herd - drought' , unit = 'farm' ;

Herd Classes
Female groups
Female: JFd ,label = 'Juvenile Female' , duration = 12 , Size : initial = 4.5 , maximum = 0 ,  
LiveWeight at entry = [ 20 ], CarcassYield = [47 ],  
Offtake : rate = [ 0 0 ], price = [40 40 24 40 ],
Death rate = [ 13 13 45 13 ] ;
Female: SFd ,label = 'Subadult Female' , duration = 36 , Size : initial = 10 , maximum = 0 , 
LiveWeight at entry = [ 50 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 5 5 10 5 ], price = [ 90 90 54 90 ],
Death rate = [5 5 13 5 ] ;
Female: AFd ,label = 'Adult Female' , duration = 132 , Size : initial = 20.5 , maximum = 0 , 
LiveWeight at entry = [ 250 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 5 5 25 5 ], price = [ 150 150 90 150],
Death rate = [ 3 3 21 3 ] ;
Male groups
Male: JMd ,label = 'Juvenile Male' , duration = 12 , Size : initial = 4 , maximum = 0 ,
LiveWeight at entry = [ 20 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 10 ], price = [ 40 40 24 40 ],
Death rate = [ 13 13 45 13  ] ;
Male: SMd ,label = 'Subadult Male' , duration = 36 , Size : initial = 7 , maximum = 0 ,
LiveWeight at entry = [ 70 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 20 20 30 20 ], price = [ 110 110 66 110],
Death rate = [ 5 5 13 5 ] ;
Male: AMd ,label = 'Adult Male' , duration = 72 , Size : initial = 4 , maximum = 0 ,
LiveWeight at entry = [ 300 ], CarcassYield = [ 47 ], 
Offtake : rate = [ 21 21 50 21 ], price = [ 200 200 120 200 ],
Death rate = [ 3 3 21 3  ] ;

Parturition and milk
Milk = CowMilk prod ;
Class AFd :  
Birth rate per year = [ 50 50 30 50 ], 
Net Prolificacy Rate = [ 100 ] , Prob. of female at birth = [ 50 ] ,
Quantity per lactation = [ 136 ] ;

Intakes
Class SFd :  Numbers = [ 0 0 0 0], price = [ 0 0 ] ;

Feed Requirements
Feed Item DM cons ;
Daily Quantity per unit LW
	// use template "-Herd Class Data" 
JFd = [ 0.025 ] ;
SFd = [ 0.025 ] ;
AFd = [ 0.025 ] ;
JMd = [ 0.025 ] ;
SMd = [ 0.025 ] ;
AMd = [ 0.025 ] ;

Other products and costs
// specify here commodity items proportional to herd classes 
// use template "-Herd Item"
Proportional Item Hides prod ;
Quantity per head per year
AFd = [ 5 ] ;
AMd = [2 ] ;
Proportional Item Manure prod ;
Quantity per head per year
JFd = [ 0.5 ] ;
SFd = [ 0.8 ] ;
AFd = [ 1.5 ] ;
JMd = [ 0.5 ] ;
SMd = [ 0.8 ] ;
AMd = [ 1.5 ] ;
end ;

//================================================

table HerdProjection = 'Herd Development projection' , unit = 'unit herd' ;
'Small farm herd';
// optional titles: STRING ;
// totals, allColumns, colWidth=1, decDigits=2, tabScale=1,
Table type = yrlist, years = [1~20];
//table blocks
block  = 'Average Female Population' ; //, Block totals ; // , decDigits = 2;
CowHerd~avgSize~JF;
CowHerd~avgSize~SF;
CowHerd~avgSize~AF;
CowHerd~nbrTotF, label='-- Total Female';
end block;
block  = 'Average Male Population' ; //, Block totals ; // , decDigits = 2;
CowHerd~avgSize~JM;
CowHerd~avgSize~SM;
CowHerd~avgSize~AM;
CowHerd~nbrTotM, label='-- Total Male';
end block;
block = 'Average Yotal Population';
CowHerd~nbrTotal , label = '-- Total Herd' ; //, footnote = 'footnote' ; //, decDigits = 2;

end block;

end;

//================================================

table HerdProjectionDrought = 'Herd Development projection' , unit = 'unit herd' ;
'Small farm herd with drought';
// optional titles: STRING ;
// totals, allColumns, colWidth=1, decDigits=2, tabScale=1,
Table type = yrlist, years = [1~20];
//table blocks
block  = 'Average Female Population' ; //, Block totals ; // , decDigits = 2;
CowHerd2~avgSize~JFd;
CowHerd2~avgSize~SFd;
CowHerd2~avgSize~AFd;
CowHerd2~nbrTotF, label='-- Total Female';
end block;
block  = 'Average Male Population' ; //, Block totals ; // , decDigits = 2;
CowHerd2~avgSize~JMd;
CowHerd2~avgSize~SMd;
CowHerd2~avgSize~AMd;
CowHerd2~nbrTotM, label='-- Total Male';
end block;
block = 'Average Yotal Population';
CowHerd2~nbrTotal , label = '-- Total Herd' ; //, footnote = 'footnote' ; //, decDigits = 2;

end block;

end;

//================================================

script PrintOut = 'label' ; //, unit = 'unit' ;
print table HerdProjection;
end;

//================================================

plan SmallFarm = 'Small farm' , unit = 'farm' ;
// plan items
CowHerd phased [1 0];
run PrintOut;
end;

//================================================
script PrintOutD = 'label' ; //, unit = 'unit' ;
print table HerdProjectionDrought;
end;

//================================================

plan SmallFarmDrought = 'Small farm with drought' , unit = 'farm' ;
// plan items
CowHerd2 phased [1 0];
run PrintOutD;
end;

//================================================

plan DroughtImpact = 'Small farm: Drought Impact' , unit = 'farm' ;
// plan items
CowHerd2 phased [1 0];
CowHerd phased [-1 0];
run PrintOutImpact;
end;

//================================================

script PrintOutImpact = 'label' ; //, unit = 'unit' ;
var NbrOFF0 = 'Female Offtake number, no drought'  = CowHerd~NbrOFF * (-1); //or = expression ;
var NbrOFM0 = 'Male Offtake number, no drought'  = CowHerd~NbrOFM * (-1); //or = expression ;
var NbrOFTot0 = 'Total Offtake number, no drought'  = CowHerd~NbrOFTot * (-1); //or = expression ;
var FinOFTot0 = 'Offtake value, no drought'  = CowHerd~FinOFTot * (-1); //or = expression ;
var ChangeOFF = 'Change in offtake, Female' = CowHerd2~NbrOFF - NbrOFF0;
var ChangeOFM = 'Change in offtake, Male' = CowHerd2~NbrOFM - NbrOFM0;
var ChangeOFTot = 'Change in offtake, Total' = CowHerd2~NbrOFTot - NbrOFTot0;
var ChangeFinOFTot = 'Change in total offtake value' = CowHerd2~FinOFTot - FinOFTot0;
var NbrSVF0 = 'Female Stock Variation number, no drought'  = CowHerd~NbrSVF * (-1); //or = expression ;
var NbrSVM0 = 'Male Stock Variation number, no drought'  = CowHerd~NbrSVM * (-1); //or = expression ;
var NbrSVTot0 = 'Total Stock Variation number, no drought'  = CowHerd~NbrSVTot * (-1); //or = expression ;
var FinSVTot0 = ' Stock Variation, no drought'  = CowHerd~FinSVTot * (-1); //or = expression ;
var ChangeSVF = 'Change in Stock Variation, Female' = CowHerd2~NbrSVF - NbrSVF0;
var ChangeSVM = 'Change in Stock Variation, Male' = CowHerd2~NbrSVM - NbrSVM0;
var ChangeSVTot = 'Change in Stock Variation, Total' = CowHerd2~NbrSVTot - NbrSVTot0;
var ChangeFinSVTot = 'Change in total stock variation value' = CowHerd2~FinSVTot + CowHerd~FinSVTot;
var ChangeCashTot = 'Total Cash-income Impact' = ChangeFinOFTot + CowMilk~prodV + Hides~prodV + Manure~prodV;
var ChangeFinTot = 'Total Financial Impact' = ChangeCashTot + ChangeFinSVTot;
print table Impact;
end;

//================================================

table Impact = 'Economic Impact of Drought' ; //, unit = 'unit' ;
// optional titles: STRING ;
// totals, allColumns, colWidth=1, decDigits=2, tabScale=1,
Table type = yrlist, years = [1~5, 10, 15, 20];
block  = 'Offtake (numbers)' ; //, Block totals ; // , decDigits = 2;
CowHerd2~NbrOFF , label = 'Female, with drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
CowHerd2~NbrOFM , label = 'Male, with drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
CowHerd2~NbrOFTot , label = 'Total, with drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
NbrOFF0 , label = 'Female, no drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
NbrOFM0 , label = 'Male, no drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
NbrOFTot0 , label = 'Total, no drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
ChangeOFF , label = 'Change, Female' , footnote = 'Positive values are a surplus in drought situation, negative values are a deficit';
ChangeOFM , label = 'Change, Male' ;
ChangeOFTot , label = 'Change, Total' ;
end block;

block  = 'Stock variation (numbers)' ; //, Block totals ; // , decDigits = 2;
CowHerd2~NbrSVF , label = 'Female, with drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
CowHerd2~NbrSVM , label = 'Male, with drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
CowHerd2~NbrSVTot , label = 'Total, with drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
NbrSVF0 , label = 'Female, no drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
NbrSVM0 , label = 'Male, no drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
NbrSVTot0 , label = 'Total, no drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
ChangeSVF , label = 'Change, Female' ; //, footnote = 'Positive values are a surplus in grought situation, negative values are a deficit';
ChangeSVM , label = 'Change, Male' ;
ChangeSVTot , label = 'Change, Total' ;
end block;

block = 'Financial impact';
CowHerd2~FinOFTot , label = 'Offtake value, with drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
FinOFTot0 , label = 'Offtake value, no drought' ; //, footnote = 'footnote' ; //, decDigits = 2;
ChangeFinOFTot, label = 'Change in total offtake value';
CowMilk~prodV, label = 'Change in milk value';
Hides~prodV, label = 'Change in hides value';
Manure~prodV, label = 'Change in manure value';
ChangeCashTot, label = 'Total Cash-income Impact';
ChangeFinSVTot, label = 'Change in total stock variation value';
ChangeFinTot, label = 'Total Financial Impact';
end block;
end;

end model

//=======================================

The output tables

Small Farm Herd projection

Herd projection with drought

Drought impact