1 - What is Planning Optimization?
Introduction to planning optimization and constraint satisfaction.
Planning
The need to create plans generally arises from a desire to achieve a goal:
- Build a house
- Correctly staff a hospital shift
- Complete work at all customer locations
- Deliver packages efficiently
Achieving those goals involves organizing the available resources. To correctly staff a hospital you need enough qualified personnel in a variety of fields and specializations to cover the opening hours of the hospital.
Any plan to deploy resources, whether to staff a hospital shift or to assemble the building materials for a new house, is done under constraints.
Constraints could be:
- Physical laws - People can’t work two shifts in two separate locations at the same time, and you can’t mount a roof on a house that doesn’t exist
- Regulations - Employees need a certain number of hours between shifts or are only allowed to work a maximum number of hours per week
- Preferences - Certain employees prefer to work specific shift patterns
Feasible Plans
Any plan needs to consider all three elements—goals, resources, and constraints—in balance to be a feasible plan. A plan that fails to account for all the elements of the problem is an infeasible plan.
For instance, if a hospital staff roster covers all shifts, but assigns employees back-to-back shifts with no breaks for sleep or life outside work, it is not a valid plan.
Why Planning Problems are Hard
Planning problems become harder to solve as the number of resources and constraints increase. Creating an employee shift schedule for a small team of four employees is fairly straightforward. However, if each employee performs a specific function within the business and those functions need to be performed in a specific order, changes that affect one employee quickly cascade and affect everybody on the team.
As more employees and different work specializations are added, things become much more complicated.
Example: For a trivial field service routing problem with 4 vehicles and 8 visits, the number of possibilities that a brute force algorithm considers is 19,958,418.
What would take a team of planners many hours to schedule can be automatically scheduled by SolverForge in a fraction of the time.
Operations Research
Operations Research (OR) is a field of research focused on finding optimal (or near optimal) solutions to problems with techniques that improve decision-making.
Constraint satisfaction programming is part of Operations Research that aims to satisfy all the constraints of a problem.
Planning AI
Planning AI is a type of artificial intelligence designed specifically to handle complex planning and scheduling tasks, and to satisfy the constraints of planning problems. Instead of just automating simple, repetitive tasks, it helps you make better decisions by sorting through countless possibilities to find the best solutions—saving you time, reducing costs, and improving efficiency.
Why Planning AI is Different
Traditional methods of planning often involve manually sifting through options or relying on basic tools that can’t keep up with the complexity of real-world problems. Planning AI, on the other hand, uses advanced strategies to quickly focus on the most promising solutions, even when the situation is extremely complicated.
Planning AI also makes it possible to understand the final solution with a breakdown of:
- Which constraints have been violated
- Scores for individual constraints
- An overall score
This makes Planning AI incredibly valuable in industries where getting the right plan is crucial—whether that’s scheduling workers, routing deliveries, or managing resources in a factory.
Constraints and Scoring
Constraints can be considered hard, medium, or soft.
Hard Constraints
Hard constraints represent rules and limitations of the real world that any planning solution has to respect. For instance, there are only 24 hours in a day and people can only be in one place at a time. Hard constraints also include rules that must be adhered to, such as employee contracts and the order in which dependent tasks are completed.
Breaking hard constraints results in infeasible plans.
Medium Constraints
Medium constraints help manage plans when resources are limited (for instance, when there aren’t enough technicians to complete all the customer visits or there aren’t enough employees to work all the available shifts). Medium constraints incentivize SolverForge to assign as many entities (visits or shifts) as possible.
Soft Constraints
Soft constraints help optimize plans based on the business goals, for instance:
- Minimize travel time between customer visits
- Assign employees to their preferred shifts
- Keep teachers in the same room for consecutive lessons
Understanding Scores
To help determine the quality of the solution, plans are assigned a score with values for hard, medium, and soft constraints.
0hard/-257medium/-6119520soft
From this example score we can see:
- Zero hard constraints were broken (feasible!)
- Medium and soft scores have negative values (room for optimization)
Note: The scores do not show how many constraints were broken, but weighted values associated with those constraints.
Score Comparison
Because breaking hard constraints would result in an infeasible solution, a solution that breaks zero hard constraints and has a soft constraint score of -1,000,000 is better than a solution that breaks one hard constraint and has a soft constraint score of 0.
The weight of constraints can be tweaked to adjust their impact on the solution.
2 - Problem Types
Common categories of planning and scheduling problems.
SolverForge can solve a wide variety of planning and scheduling problems. Here
are some common categories:
Scheduling Problems
Assign activities to time slots and resources.
Employee Scheduling (Rostering)
Assign employees to shifts based on:
- Skills and qualifications
- Availability and preferences
- Labor regulations (max hours, rest periods)
- Fairness (balanced workload)
Examples: Hospital nurse scheduling, retail staff scheduling, call center
scheduling
Assign lessons to timeslots and rooms:
- Teachers can only teach one class at a time
- Rooms have limited capacity
- Student groups shouldn’t have conflicts
- Preference for consecutive lessons
Examples: University course scheduling, school class scheduling
Meeting Scheduling
Find optimal times for meetings:
- Required attendees must be available
- Rooms must be available and large enough
- Minimize conflicts with other meetings
- Consider timezone differences
Job Shop Scheduling
Schedule jobs on machines:
- Operations must follow a specific order
- Machines can only do one job at a time
- Minimize total completion time (makespan)
Examples: Manufacturing scheduling, print shop scheduling
Routing Problems
Plan routes and sequences for vehicles or resources.
Vehicle Routing Problem (VRP)
Plan delivery or service routes:
- Vehicle capacity constraints
- Time windows for deliveries
- Minimize total travel distance/time
- Multiple depots possible
Variants:
- CVRP - Capacitated VRP
- VRPTW - VRP with Time Windows
- PDPTW - Pickup and Delivery with Time Windows
Examples: Delivery route planning, field service scheduling, waste
collection
Traveling Salesman Problem (TSP)
Visit all locations exactly once with minimum travel:
- Single vehicle
- Return to starting point
- Minimize total distance
Examples: Sales territory planning, circuit board drilling
Assignment Problems
Assign entities to resources or positions.
Task Assignment
Assign tasks to workers or machines:
- Match skills/capabilities
- Balance workload
- Meet deadlines
- Minimize cost
Examples: Project team assignment, warehouse task allocation
Bin Packing
Pack items into containers:
- Items have sizes/weights
- Containers have capacity limits
- Minimize number of containers used
Examples: Truck loading, cloud server allocation, cutting stock
Resource Allocation
Allocate limited resources to competing demands:
- Budget allocation
- Equipment assignment
- Space allocation
Complex Planning Problems
Real-world problems often combine multiple problem types:
Field Service Scheduling
Combines:
- Routing - Travel between customer locations
- Scheduling - Time windows and appointment slots
- Assignment - Match technician skills to job requirements
Project Planning
Combines:
- Task scheduling - Activities with durations and dependencies
- Resource assignment - Assign people/equipment to tasks
- Constraint satisfaction - Deadlines, budgets, availability
Problem Characteristics
When modeling your problem, consider these characteristics:
| Characteristic | Description | Example |
|---|
| Hard constraints | Must be satisfied | Legal requirements |
| Soft constraints | Should be optimized | Customer preferences |
| Planning entities | What gets assigned | Lessons, visits, shifts |
| Planning variables | The assignments | Timeslot, room, vehicle |
| Problem facts | Fixed data | Employees, rooms, skills |
Choosing the Right Model
When modeling your problem:
- Identify entities - What things need to be assigned or scheduled?
- Identify variables - What values are you assigning?
- Identify constraints - What rules must be followed?
- Define the score - How do you measure solution quality?
The Getting Started section provides complete examples
for common problem types.
3 - Terminology
Glossary of terms used in SolverForge documentation.
Core Concepts
Planning Problem
The input to the solver: a set of planning entities with uninitialized planning variables, plus all problem facts and constraints.
Planning Solution
The root Rust struct that holds all problem facts, planning entities, and the current score. Annotated with #[planning_solution].
Planning Entity
A Rust struct whose instances are modified during solving. Planning entities contain genuine planning variables or list variables. Annotated with #[planning_entity].
Planning Variable
A field on a planning entity that the solver changes during optimization. Annotated with #[planning_variable(...)].
Problem Fact
Immutable input data that constraints reference but the solver does not modify. Annotated with #[problem_fact] and stored in a #[problem_fact_collection].
Planning ID
A stable identifier for an entity or fact. Annotated with #[planning_id]. Most user-facing examples use one so joins, telemetry, and analysis stay easy to read.
Value Range
The set of possible values for a planning variable. In the common stock runtime, the planning variable names its provider with value_range = "solution_field".
Scoring
Score
A measure of solution quality. Higher scores are better. Common types: SoftScore, HardSoftScore, and HardMediumSoftScore.
Hard Constraint
A constraint that must be satisfied for a solution to be feasible. Broken hard constraints make a solution invalid.
Soft Constraint
A constraint that should be optimized but isn’t required. Used for preferences and optimization goals.
Medium Constraint
A constraint between hard and soft, typically used for “assign as many as possible” scenarios.
Feasible Solution
A solution with no broken hard constraints (hard score of 0 or positive).
Optimal Solution
A feasible solution with the best possible soft score. May be impractical to find for large problems.
Constraint Stream
The fluent API for defining constraints. Streams start from ConstraintFactory::<Solution, Score>::new(), then either for_each(...) or a generated collection accessor such as .shifts().
Algorithms
Construction Heuristic
An algorithm that builds an initial solution quickly by assigning values to all planning variables.
Local Search
An algorithm that improves an existing solution by making incremental changes (moves).
Move
A change to the solution, such as swapping two assignments or changing a single variable.
Step
One iteration of the optimization algorithm, consisting of selecting and applying a move.
Termination
The condition that stops the solver (time limit, score target, no improvement, etc.).
Advanced Concepts
Shadow Variable
A planning variable whose value is calculated from other variables, not directly assigned by the solver. Used for derived values like arrival times.
Inverse Shadow Variable
A shadow variable that maintains a reverse reference to the owner or assignment created by a genuine variable.
Previous/Next Element Shadow Variable
Shadow variables that track the previous or next element in a list variable.
Cascading Update Shadow Variable
A shadow variable that triggers recalculation when upstream variables change.
List Variable
A planning variable that holds an ordered list of element indices. Used for routing and sequencing problems. Annotated with #[planning_list_variable(...)].
Nearby Selection
Distance-pruned move generation for large neighborhoods. In the config-driven runtime, this is expressed by choosing nearby move-selector variants such as nearby_list_change_move_selector.
Pinning
Locking certain assignments so the solver cannot change them. Useful for preserving manual decisions or already-executed plans.
Problem Change
A modification to the problem while the solver is running (real-time planning).
Solver Components
Solver
The search engine that applies phases, selectors, acceptors, and incremental scoring to improve a solution.
SolverConfig
Configuration object for runtime behavior such as termination, random seed, phases, and move-thread count.
SolverManager
Manages retained solve jobs, authoritative lifecycle state, streamed
SolverEvent values, snapshots, and exact in-process pause/resume. Useful for
services and web applications that need job ids, status polling, cancellation,
or score analysis after the solve finishes.
Analyzable
Trait generated for #[planning_solution] types that specify a constraints path. It enables score analysis for a concrete solution instance.
ScoreDirector
Internal component that calculates scores efficiently and powers score analysis.
ConstraintSet
The trait implemented for tuples of finalized constraints returned by your constraint function.
Constraint Stream Operations
for_each
Start a constraint stream by iterating over items produced by an extractor closure.
Generated Collection Accessor
A method like .shifts() or .employees() generated by #[planning_solution] for use on ConstraintFactory.
unassigned
A generated helper on streams of entities with a single Option<_> planning variable. It filters to entities whose planning variable is currently None.
filter
Remove items that don’t match a predicate.
join
Combine two streams by matching on joiners. The current API uses one unified .join(target) entry point for self-joins, cross-joins, and predicate joins.
Joiner
A condition for matching items in joins, such as equal, equal_bi, or overlapping.
group_by
Aggregate items by key with collectors.
flatten_last
Flatten the final element of a tuple stream into a child collection, then continue matching on the flattened values.
balance
Compute load imbalance directly from a uni-stream without manually writing group_by aggregation code.
if_exists_filtered / if_not_exists_filtered
Keep or reject items based on whether matching items exist in another collection.
Collector
Aggregation function (count, sum, min, max, toList, etc.).
penalize / reward
Apply score impact for matching items.
named
Finalize the constraint with a human-readable name.
Score Analysis
Score Explanation
Breakdown of which constraints contributed to the score.
Constraint Match
A single instance of a constraint being triggered.
Indictment
List of constraint violations associated with a specific entity.
Justification
Explanation of why a constraint was triggered.