Search⌘ K

Introducing Penalty Functions

Explore how penalty functions are used in genetic algorithms to manage invalid solutions by assigning costs to constraint violations. Understand their role in problems like cargo loading and how they help maintain valid outcomes without explicit constraints.

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 ...