Table of Contents#### Download Safari Books Online apps: Apple iOS | Android | BlackBerry

# The Cost Function

Entire Site

Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

The *cost function* is the key to solving any
problem using optimization, and it’s usually the most difficult thing to
determine. The goal of any optimization algorithm is to find a set of
inputs—flights, in this case—that minimizes the cost function, so the
cost function has to return a value that represents how bad a solution
is. There is no particular scale for *badness*; the
only requirement is that the function returns larger values for worse
solutions.

Often it is difficult to determine what makes a solution good or bad across many variables. Consider a few of the things that can be measured in the group travel example:

*Price*-
The total price of all the plane tickets, or possibly a weighted average that takes financial situations into account.