CorePyomo

Contains constraints for core equations and objective.

author: young

AfoLogic.CorePyomo.coremodel_all(trial_name, model, method, nv)

Wraps all of the core model into a function so it can be run multiple times in a loop

Returns

None.

AfoLogic.CorePyomo.f_con_asset(model)

Tallies the total asset value to ensure that there is a minimum ROI on farm assets. The asset value multiplied by opportunity cost on capital is then passed to the objective.

AfoLogic.CorePyomo.f_con_biomass_transfer(model)

Tracks the biomass of each phase and allows the transfer of biomass to either grain, hay or fodder for grazing. Biomass penalties associated with untimely sowing and/or crop grazing are accounted for here as well.

Biomass doesn’t carry between seasons because the choice biomass use must before or at harvest time.

AfoLogic.CorePyomo.f_con_cashflow(model)

Tallies all cashflow in each period and transfers to the next period. Season periods exist so that a transfer can exist between parent and child seasons.

AfoLogic.CorePyomo.f_con_dep(model)

Tallies the depreciation of capital, which is then passed to the objective.

AfoLogic.CorePyomo.f_con_harv(model)

Links the harvest requirement for each rotation with harvesting capacity. Harvest capacity can be provided from farmer labour and machinery or contract services.

AfoLogic.CorePyomo.f_con_harv_stub_nap_cons(model)

Constrains the ME from stubble and non arable pasture in the feed period that harvest occurs. To consume ME from stubble and non arable pasture sheep must also consume a proportion (depending on when harvest occurs within the feed period) of their total intake from pasture. This stops sheep consuming all their energy intake for a given period from stubble and non arable pasture when they don’t become available until after harvest (the logic behind this is explained in the stubble section of this document).

AfoLogic.CorePyomo.f_con_labour_fixed_anyone(model)

Tallies labour used for fixed activities that can be completed by anyone (casual/permanent/manager) and ensures that there is sufficient labour available to carry out the jobs.

AfoLogic.CorePyomo.f_con_labour_fixed_manager(model)

Tallies labour used for fixed activities that can only be completed by the manager and ensures that there is sufficient labour available to carry out the jobs.

AfoLogic.CorePyomo.f_con_labour_phase_anyone(model)

Tallies labour used in the crop enterprise that can be completed by anyone (casual/permanent/manager) and ensures that there is sufficient labour available to carry out the jobs.

AfoLogic.CorePyomo.f_con_labour_phase_perm(model)

Tallies labour used in the crop enterprise that can be completed by permanent or manager staff and ensures that there is sufficient labour available to carry out the jobs.

AfoLogic.CorePyomo.f_con_labour_sheep_anyone(model)

Tallies labour used in the sheep enterprise that can be completed by anyone (casual/permanent/manager) and ensures that there is sufficient labour available to carry out the jobs.

AfoLogic.CorePyomo.f_con_labour_sheep_manager(model)

Tallies labour used in the sheep enterprise that can be completed by manager staff and ensures that there is sufficient labour available to carry out the jobs.

AfoLogic.CorePyomo.f_con_labour_sheep_perm(model)

Tallies labour used in the sheep enterprise that can be completed by permanent or manager staff and ensures that there is sufficient labour available to carry out the jobs.

Constrains the consumption of paddock feed with supplement if the animal is not in confinement. This is to represent the fact that livestock will still eat pasture if they’re being fed supplement.

Note: this constraint can make the model infeasible for n11 because the optimal fs cant be met without supplement. To fix this run n33. This may still be infeasible due to sires who are always n33. But sires nut can be changed in sinp or sires can be removed from ME and vol in stockpyomo.

Constrains the consumption of understory and saltbush based on the estimated diet selection of animals grazing salt land pasture. Saltbush info comes from saltbushpyomo and understory comes from pasturepyomo.

AfoLogic.CorePyomo.f_con_makehay(model)

Constrains the hay making requirement for each rotation by hay making capacity. Hay making capacity is provided by contract services.

AfoLogic.CorePyomo.f_con_me(model)

All livestock activities require energy. Provided by pastures, stubbles, supplementary feeding, grazing of green crops and other fodder crops.

The livestock require energy and the quantity required per head depends on the target liveweight profile of the animals (are the animals gaining or losing condition), the proportion of ewes in the flock (because ewes generally require more energy than dry animals) and the level of productivity (particularly the level of reproduction).

The combination of a minimum energy requirement and maximum intake capacity sets a minimum diet quality for the animal that must be provided by the diet selected. This ensures that the diet selected is feasible for the animal to consume i.e. the diet selected cannot consist purely of a large quantity of low quality (cheap) fodder that is beyond the capacity of the animal to consume.

AfoLogic.CorePyomo.f_con_minroe(model)

Tallies the total expenditure to ensure that there is a minimum ROI on cash expenditure.

AfoLogic.CorePyomo.f_con_phasesow(model)

Ensures that the seeding requirements for each rotation phase selected can be met by the capacity of the machinery and/or with the help of contract work.

Links seeding requirement with machinery sowing activity (which accounts for machinery use and labour needed to sow pasture). No p5 set in the constraint because model can optimise sowing time (can only optimise within the periods provided eg dry sowing activity only provides sowing capacity before the break).

p_sow_prov links k and p5 so that:

  1. dry sown landuses are sown before the break.

  2. pasture is sown in the correct p5 periods based on the inputted reseeding date.

  3. wet sown crops are sown after the break of season.

v_seeding_machdays is bound in con_seed_period_days to ensure that the correct days of seeding are provided in each p7 and p5 period.

Notes:

  1. The requirement for seeding is based on v_phase_change_increase rather than v_phase_area

  2. a phase can only be sown in the phase_period for which the phase_increment is selected. If there is insufficient seeding capacity then the selection of v_phase_change_increase must be made in a later phase_period.

Note: this is an equals to constraint to stop the model sowing without a landuse so it can get poc and crop

grazing (both of those activities are provided by seeding).

AfoLogic.CorePyomo.f_con_poc_available(model)

Constrains the foo consumed on crop paddocks before seeding. The foo available is determined by the number of hectares sown and the number of days each hectare can be grazed (calculated in Mach.py) multiplied by the foo available to be consumed on each hectare each day (calculated in Pasture.py).

AfoLogic.CorePyomo.f_con_product_transfer(model)

Links rotation product (grain or baled biomass), feed requirement for supplementary feeding and the sale and purchase of grain/hay. Grain fed to the sheep is purchased unless it is produced on farm. The net grain is either purchased or sold depending on the final balance.

This constraint exists (as well as biomass transfer) because supplement requirement needs to be tracked and fulfilled by either purchasing or harvesting grain.

Currently, the supplement fed during the year is either purchased or transferred from the cropping enterprise at the end of the season. This means we are underestimating variable and fixed storage costs in good seasons because less supplement is fed but in reality the same amount would be stored since a farmer doesn’t know it is going to be a good year when making storage decisions.

AfoLogic.CorePyomo.f_con_totalcap_between(model)

Tallies total capital and transfers to the next period. Cashflow periods exist so that a transfer can exist between parent and child seasons.

Cashflow at the end of the previous yr becomes the starting balance for working capital (cashflow broadcasts to both c0 slices). This only happens between years in the sequence. End to start doesn’t carry over. This is because it was decided that the working capital constraint is more useful if there is no starting balance at the start of the sequence. This means an expensive strategy with a high reward can be bounded using wc (if the end cashflow became the start then a high expense high income strategy would not trigger the constraint).

AfoLogic.CorePyomo.f_con_totalcap_within(model)

Tallies total capital and transfers to the next period. Cashflow periods exist so that a transfer can exist between parent and child seasons.

Total capital is a combination of assets and working capital. Working capital is the sum of the expenses minus any income, since the previous ‘main’ income (e.g. harvest or shearing). This constraint exists so the model user can examine how the farm is structured under different levels of finance. The default is to allow a large amount of finance so that this constraint it not impacting the solution.

Start asset value is included to ensure that retaining sheep from the end of last year until the start of the current cashflow period doesn’t reduce wc (on farm this does not work because there is no concept of start and end of cashflow like there is in the model). If start asset value was not included the model shift strategical off spring sales that would usually occur at shearing until the start of next season which would reduce wc because sales after main shearing offset wc costs (this would be a problem in both SE and DSP).

Note: trade value is not included because it is a valid tactic to sell more animals in a poor season and then buy them back after peak debt or in SQ start the following year understocked.

AfoLogic.CorePyomo.f_con_vol(model)

All livestock activities provide volume to consume feed. The volume required by each feed changes depending on quality and quality of availability.

The combination of a minimum energy requirement and maximum intake capacity sets a minimum diet quality for the animal that must be provided by the diet selected. This ensures that the diet selected is feasible for the animal to consume i.e. the diet selected cannot consist purely of a large quantity of low quality (cheap) fodder that is beyond the capacity of the animal to consume.

AfoLogic.CorePyomo.f_objective(model)

The objective of the model is to maximise expected utility. In the case of risk neutrality, expected utility is equivalent to expected profit, meaning that the optimal farm management plan is that which maximises farm profit. In the case of risk aversion, utility increases at a diminishing rate as profit increases. Thus, when farm profit is low, an extra dollar of profit provide more utility than when farm profit is high. This means, a risk adverse farmer aims to reduce profit variation (i.e. increase profit in poor years at the cost of reduced profit in the good years). For example, if the crop and stock enterprise on the modelled farm are similar but grain prices are more volatile, then risk aversion will shift resources towards the stock enterprise to reduce risk (profit variation).

The expected return used to calculate utility includes the net cash flow for a given price and weather scenario, minus a cost to represent a minimum return on operating costs incurred (MINROE), minus the cost of depreciation, and minus the opportunity cost on the farm assets (total value of all assets times the discount rate (to ensure that the assets generate a minimum ROA)). MINROE and asset opportunity costs are discussed in more detail in the finance section, and their inclusion is controlled by the user.

Constant absolute risk-aversion (CARA) and constant relative risk-aversion (CRRA) are two well known utility functions. Both have been previously used in stochastic farm modelling (see [Kin94, Kin96]) and both methods are included in AFO (note: alternative utility functions can easily be added). CARA is a negative exponential curve: \(U = 1-exp(-a*x)\) where \(U\) is utility, \(a\) is the Pratt-Arrow coefficient of absolute risk aversion and x is the return to management and capital. The Pratt-Arrow coefficient is a user input that controls the level of risk aversion. [Kin94] used two levels: 0.000 003 and 0.000 005 to represent moderate and high levels risk-aversion. CRRA is a power function denoted by: \(U = W^(1-R) / (1-R)\) where \(U\) is utility, \(W\) is terminal wealth and \(R\) is the relative risk aversion coefficient. The relative risk aversion coefficient is a user defined input that controls the level of risk aversion. [Kin96] used values within the range of 0.1 to 3.0 to represent low to high levels of risk-aversion.

Both methods have limitations, most of which can be minimised if the modeler is aware. A CARA specification implies there are no wealth effects on a farmer’s income and price security decisions. In practice, the CARA specification means that the farmer’s risk management decisions, particularly in favourable states of nature (e.g. good weather-years with high commodity prices) when a farmer’s wealth is boosted, will be different and more concerned with income stability than those that would arise with a CRRA specification. The limitation of the CRRA method is that it cannot handle a negative terminal state. Additionally, because CRRA is impacted by terminal wealth, MINROE and asset opportunity cost (discussed in the finance section) will affect the impact of risk aversion, which is not technically correct because these are not real costs incurred by the farmer.

The utility functions discussed above are non-linear. To accommodate this in AFO, a piecewise technique is applied which approximates the function using 13 linear segments.