...

/

Introducing Penalty Functions

Introducing Penalty Functions

Get to know what penalty functions are and how they can be applied to the shipping problem.

What are penalty functions?

We need a way to account for solutions that aren’t considered valid, meaning they don’t meet the constraints defined by the problem. For example, in the cargo problem, you need a way to penalize solutions that exceed the weight limit, so your algorithm doesn’t produce an invalid solution.

A penalty function is a function applied to constraint satisfaction problems for the purpose of reducing them into an unconstrained problem. Rather than putting constraints on possible solutions, penalty functions incur a cost on solutions that violate a constraint of the original problem. In layman’s terms, that means to take points away from solutions that aren’t valid, so they don’t get considered better than solutions that are valid.

To better understand penalty ...