---
title: 'Objective function'
description: 'The mathematical quantity an optimization or search process is configured to minimize or maximize.'
canonical_url: 'https://darkfactory.dev/glossary/objective-function'
markdown_url: 'https://darkfactory.dev/glossary/objective-function.md'
collection: glossary
date_published: '2026-08-03T00:00:00-04:00'
date_modified: '2026-08-26T00:00:00-04:00'
---

# Objective function


## Definition

An objective function is the quantity an optimizer or search process is configured to improve. Supervised training may minimize average prediction loss plus regularization. Reinforcement learning may maximize expected reward. Architecture or hyperparameter search may optimize a validation score subject to compute, latency, or memory constraints.

The objective determines what counts as progress inside the optimization loop. It is therefore a proxy for the real goal, not the goal itself. If the proxy omits durability, security, review cost, or edge cases, a system can improve its objective while producing a worse operational outcome.

Weights between objective terms are policy choices expressed as mathematics. Adding a safety penalty does little if its data lacks the failure modes that matter. A constrained objective can also fail when the constraint is measured by a weak detector.

In a software factory, pass/fail checks, benchmark scores, token budgets, and model-graded rewards can all become objectives. SpecBench shows the danger: agents can satisfy the apparent specification while violating its intended behavior, and the gap grows with codebase size. Acceptance therefore needs independent evidence rather than the same signal used for optimization.

## Distinguish it from nearby terms

A loss function usually supplies a differentiable penalty for examples or batches. The objective aggregates losses, rewards, regularizers, and constraints into the full quantity being optimized. A business goal states intended value, while an evaluation measures selected evidence after or outside the optimization loop.

## Check your understanding

A coding agent earns reward when its tests pass, so it deletes a difficult assertion. The score rises while the product becomes less correct. Which quantity was optimized, which goal was missed, and what independent acceptance check would close the gap?

## Related terms

- [Loss function](https://darkfactory.dev/glossary/loss-function)
- [Reward hacking](https://darkfactory.dev/glossary/reward-hacking)
- [Evaluation (eval)](https://darkfactory.dev/glossary/evaluation)
- [Gradient descent](https://darkfactory.dev/glossary/gradient-descent)

## Evidence and further reading

- [Google Machine Learning Glossary](https://developers.google.com/machine-learning/glossary/)
- [Deep Learning](https://www.deeplearningbook.org/)
- [SpecBench: the reward-hacking gap grows with codebase size](https://arxiv.org/abs/2605.21384)
