1. Home
  2. Explore
  3. Computer Science
  4. Optimization Problems in AI

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Optimization Problems in AI

Speaker 1Speaker 2

Optimization Problems in AI

4:08
0:00-4:08
  1. Corey

    Alright Maria, today we're diving into optimization problems—basically, choosing the best option from a set of possibilities. We've seen optimization before in game playing, but now we're looking at a broader class of problems.

  2. Maria

    Right, and the first algorithm we're covering is local search. Unlike breadth-first or A* search where we keep multiple paths, local search just maintains a single state and moves to its neighbors.

  3. Corey

    Exactly. And it's useful when we don't care about the path, only the solution itself. Think of placing hospitals on a map to minimize the distance from each house to the nearest hospital.

  4. Maria

    So we have a state-space landscape where each vertical bar is a possible configuration, and its height is the cost—like the sum of distances from houses to hospitals. We want to find the global minimum of that cost function.

  5. Corey

    And the simplest way to do that is hill climbing. Start somewhere, look at neighbors, and move to the neighbor that improves the cost the most. Repeat until no neighbor is better.

  6. Maria

    But hill climbing can get stuck at local minima, right? Like in your hospital example, you moved one hospital down and left, ended up with cost 11, but a diagonal move would give you cost 9—but that was never a neighbor.

  7. Corey

    Right, local optima are a problem. You also have plateaus where all neighbors are the same, and shoulders where you can still make progress but it's flat. That's why there are variants: steepest-ascent, stochastic, first-choice, and random-restart hill climbing.

  8. Maria

    Random-restart makes sense—run hill climbing multiple times from different starting points and pick the best result. That improved our hospital cost from 56 to 41.

  9. Corey

    Another powerful technique is simulated annealing. It's inspired by physics—heating up a system so particles move randomly, then cooling down so they settle. In AI, we start with a high 'temperature' so we sometimes accept worse moves, then gradually reduce that probability.

  10. Maria

    So you can escape local minima by temporarily going uphill, then settle into the global minimum as temperature drops. The acceptance probability depends on how much worse the move is and the current temperature.

  11. Corey

    Right. There's also the traveling salesman problem—find the shortest route visiting all cities. It's NP-complete, so we approximate using local search. A neighbor might be swapping two edges in the route.

  12. Maria

    Now let's switch to linear programming. That's when we have a linear cost function to minimize, subject to linear constraints. For example, running two machines with different costs and resource limits.

  13. Corey

    You set up variables x1 and x2, an objective like 50x1 + 80x2, and constraints like 5x1 + 2x2 ≤ 20. Then algorithms like simplex or interior-point find the optimal solution—like running machine 1 for 1.5 hours and machine 2 for 6.25 hours.

  14. Maria

    And finally, constraint satisfaction problems. We have variables that need values from their domains, and constraints like 'A ≠ B'. The classic example is exam scheduling—assign courses to days so no student has two exams on the same day.

  15. Corey

    We can enforce node consistency by removing values that violate unary constraints, and arc consistency using the AC-3 algorithm. AC-3 maintains a queue of arcs and iteratively removes domain values that don't have a consistent partner.

  16. Maria

    But even with arc consistency, we often still need search. That's where backtracking search comes in—assign variables one by one, and if we hit a dead end, undo the last assignment and try a different value.

  17. Corey

    And we can make that search smarter with heuristics. The Minimum Remaining Values heuristic picks the variable with the fewest options left. The Degree heuristic picks the variable with the most constraints. And the Least Constraining Value heuristic orders values by how few options they eliminate for neighbors.

  18. Maria

    So combining inference like arc consistency with heuristics can dramatically reduce the search space. In the exam scheduling example, by enforcing arc consistency after each assignment, we could solve the problem without any backtracking at all.

  19. Corey

    Exactly. The big takeaway is that many problems—whether it's placing hospitals, optimizing production, or scheduling exams—can be formulated as optimization or constraint satisfaction problems. Then we can apply a toolbox of algorithms: hill climbing, simulated annealing, linear programming, and backtracking with heuristics.

  20. Maria

    It's all about choosing the right formulation and the right algorithm for the problem. That's what makes AI so powerful.

  21. Corey

    Well said, Maria. That wraps up today's episode on optimization. Thanks for listening!

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent