## 7.3 Cost Functions and Constraints

• Cost functions quantify things that we want to minimize, or maximize. These should be aligned with system objectives. Typical cost functions include,

- money

- time

- some combination of factors

• Systems also have constraints that limit available solutions

• Expressed as a function of variables that provides a value

• Consider the example of building a fenced pasture. In this case when the area becomes too large, there is a reduced value. We want to maximize the value of V.

Figure 1.29 Example cost function for building a fence around a pasture

• The cost function can be written as..

Figure 1.30 A subroutine for cost function calculation

• Constraints are boundaries that cannot be crossed.

• Example of constraints, the pasture cannot be larger than one 1600m be 1600m beacuse of the constraints of an existing road system.

Figure 1.31 Example constraint functions for a pasture

• The cost function can be written as..

Figure 1.32 A subroutine for cost function calculation

• Slack variables allow constraints to be considered as part of the cost function. Helps with a system with many local minimum.

Figure 1.33 Example of slack variables for including constraints

• The cost function can be written as..

Figure 1.34 A subroutine for cost function calculation