Artificial intelligence • Original RRTutors lesson
Local Search and Optimization
Improve candidate solutions using neighboring changes when path history is less important than final quality.
Concept and explanation
Local-search methods work with a candidate configuration and iteratively seek a better neighbor. Hill climbing can stop at local optima; simulated annealing sometimes accepts worse moves to explore; genetic methods use populations and variation. These methods often find good solutions but may not prove global optimality.
How to apply it
Define a candidate encoding, objective function, neighborhood, stopping rule, and a way to compare repeated runs.
Worked example
A timetable optimizer can swap two sessions and keep the change when it reduces conflicts.
Illustrative Python example
score = 10
candidate_score = 8
if candidate_score < score:
score = candidate_score
print(score)
Expected result
The candidate is accepted because it improves a cost-minimization objective.
Limitations and cautions
A local improvement strategy can get stuck and its result depends on initialization and neighborhood design.
Practice exercise
Define a neighborhood and objective for reducing travel distance across several stops.
Key takeaway: Optimization methods need a well-defined objective and honest quality guarantees.