### User-defined constraints

One of the more challenging issues in developing *CropOptimiser* was designing a mechanism to allow the user to define social and management constraints, and subsequently incorporate them into the LP model. While user-defined constraints may be easy to formulate in words, translating these words into their equivalent algebraic representation required by the LP model is much more complex, given the range of constraint formulations possible and the need to automate this process within the software application.

The key factor in automating this translation is recognizing the underlying patterns accounting for all possible types of constraint formation. Central to this is identifying the effect of the constraint on each of the fundamental seasonal, subarea and cropping elements. This includes:

- Identifying whether the constraint affects ALL seasons simultaneously or just SELECTED seasons (or each season individually);
- Identifying whether the constraint affects ALL subareas simultaneously or just SELECTED subareas (or each subarea individually); and
- Identifying whether the constraint affects ALL crops simultaneously or just SELECTED crops (or each crop individually).

A total of eight patterns were recognized based on all possible combinations of the ‘ALL’ and ‘SELECTED’ element states. They typically involve breaking down the user-defined constraint into many individual algebraic statements. Examples of these patterns are presented in the following sections 3.3.1 to 3.3.8 and are accompanied by their algebraic formulation and sample matrix representation. The ordering of iterations of seasonal, subarea and cropping elements is also presented to simplify the matrix building process when automating the translation process.

#### User-defined constraint affecting SELECTED seasons SELECTED subareas SELECTED crops

This pattern effectively places limits on individual constraint elements. Practical examples include statements such as “*Crop Areas (in each season) > 5% of each subarea” *or “*Rice Area (S1,S2) > 10% of MATARAM area*”. Mathematically, this is represented by:

Matrix-building (Table 1) can be in any order of seasons, subarea, and then crop type.

#### User-defined constraint affecting SELECTED seasons SELECTED subareas ALL crops

This pattern adjusts total crop production in selected subareas and seasons to an (in)equality. Practical examples include statements such as “*Total Cropping Area (S1) < 90% of subarea totals” *or “*Total Cropping WaterUse (S2,S3) < 80% of MATARAM total*”. Mathematically, this is represented by:

Matrix-building (Table 2) should be in the order of seasons, subarea, and then crop type.

#### User-defined constraint affecting SELECTED seasons ALL subareas SELECTED crops

This pattern sets scheme-wide constraints for selected seasons and crops. Practical examples include statements such as “*Total Rice Area (S1) > 5000ha” *or “*Total Corn Area (S1,S2) < 20% of combined subareas*”. Mathematically, this is represented by:

Matrix-building (Table 3) should be in the order of seasons, crops, and then subareas.

#### User-defined constraint affecting ALL seasons SELECTED subareas SELECTED crops

This pattern places annual constraints on selected subareas and crops. Practical examples include statements such as “*Rice Area (Annual) <80% of MATARAM totals” *or “*Corn Area (Annual) >20% of subarea totals*”. Mathematically, this is represented by:

Matrix-building (Table 4) should be in the order of subareas, crops, and then seasons.

#### User-defined constraint affecting SELECTED seasons ALL subareas ALL crops

This pattern constrains scheme-wide total crop production around an (in)equality for selected seasons. Practical examples include statements such as “*Total Cropping Area (S1) <90% of combined subarea” *or “*Total Cropping Area (S2,S2) >50% of combined subarea*”. Mathematically, this is represented by:

Matrix-building (Table 5) should be in the order of seasons, subareas, and then crop type.

#### User-defined constraint affecting ALL seasons SELECTED subareas ALL crops

This pattern constrains annual total crop production around an (in)equality for selected subareas. Practical examples include statements such as “*Total Cropping Area (Annual) <95% of MATARAM total” *or “*Total Cropping WaterUse (Annual) >50% of MATARAM total*”. Mathematically, this is represented by:

Matrix-building (Table 6) should be in the order of subareas, seasons, and then crop type.

#### User-defined constraint affecting ALL seasons ALL subareas SELECTED crops

This pattern constrains annual scheme-wide production of selected crops around an (in)equality. Practical examples include statements such as “*Total Corn Area (Annual) > 10% of combined subareas” *or “*Total Rice Aare (Annual) < 9000ha*”. Mathematically, this is represented by:

Matrix-building (Table 7) should be in the order of crops, seasons, and then subareas.

#### User-defined constraint affecting ALL seasons ALL subarea ALL crops

This pattern constrains the annual, scheme-wide, total crop production around an (in)equality. Practical examples include statements such as “*Total Cropping Area (Annual) <12000ha” *or “*Total Cropping WaterUse (Annual) >50% total available*”. Mathematically, this is represented by a single equation:

Matrix-building (Table 8) can be undertaken in any order of seasons, subareas, and crop type.