liveBook · Manning

Optimization

As explained in Grokking AI Algorithms, Second Edition

An optimizer is an algorithm that adjusts model parameters to minimize or otherwise improve an objective function.

Optimization searches for the best solution among many valid possibilities. Each solution differs in how well it satisfies a goal and its constraints. section 1.9

Optimization is useful whenever a complex problem has historical data or a large search space. The best nearby solution may not be the best overall: a local best can hide a global best. section 1.24 section 1.9

Optimization problems commonly involve:

  • Many valid solutions, with some more effective than others. section 4.2
  • Constraints that rule out otherwise attractive choices. section 1.9
  • Search traps called local optima, where a single searcher can stop too early. section 4.2
  • Trade-offs between solution quality and computational expense. section 4.2

A constrained knapsack

A knapsack holds at most 9 kg. Among eight items, choose a combination that maximizes value without exceeding that limit. Items 1, 3, and 7 weigh 9 kg and are worth $14; items 2, 3, and 6 are worth $15 but weigh 15 kg, so they violate the constraint. The example contains 256 possible choices, illustrating how possibilities grow as the number of items increases. section 4.2

Figure 4.4 A simple example Knapsack Problem
04_04

Use the simple knapsack diagram to see how capacity, item selection, weight, and value define an optimization problem. section 4.2

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Defines constraints, local and global bests, and search-space growth, but defers detailed optimizer implementation.
Examples
Uses luggage packing, restaurant selection, and constrained knapsack choices to illustrate search and trade-offs.
What you can do after
Evaluate optimization problems by identifying valid solutions, constraints, local optima, and global objectives.
How it connects
Connects optimization with search algorithms, evolutionary algorithms, and particle swarm optimization.

Also explained in

Compare how 30 books explain optimization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.