Constraint Satisfaction Problems

Many scheduling, assignment and puzzle tasks come down to choosing values for a set of variables so that every rule holds. This material shows how to describe such tasks as constraint satisfaction problems and how to solve them: backtracking search with smart ordering of variables and values, forward checking and arc consistency to prune impossible values, the min-conflicts local search for large problems and quick repairs, and methods that use the shape of the constraint graph, such as the linear-time algorithm for tree-structured problems and cutset conditioning. Every method is worked through step by step on small examples, including a workshop timetable, map coloring and the n-queens puzzle.

IntermediateLesson 3 of 10 in Artificial Intelligence Course

What you will learn

  1. Describe a problem by its variables, domains and constraints, recognize the kinds of constraints, and turn real scheduling and assignment tasks into well-formed constraint satisfaction problems.
    • Describe the parts of a constraint satisfaction problem
      Name the variables, domains and constraints of a problem, tell partial, consistent and complete assignments apart, and draw the constraint graph.
    • Distinguish the kinds of constraints
      Classify constraints as unary, binary, higher-order or global, rewrite higher-order constraints as binary ones, and separate hard constraints from preferences.
    • Model scheduling and assignment problems as CSPs
      Turn timetabling, job-shop scheduling, assignment tasks and puzzles into CSPs, choosing variables and domains so the constraints stay simple.
  2. Search for a solution one variable at a time, back up at dead ends, and choose the order of variables and values so the search finds a solution, or proves there is none, with far less work.
    • Run backtracking search step by step
      Explain why backtracking assigns one variable per level, carry out the algorithm by hand and state its completeness and cost.
    • Choose variables and values with ordering heuristics
      Apply minimum remaining values, the degree heuristic and least constraining value, explain why they point in opposite directions, and measure their effect on a search.
    • Back up intelligently after a dead end
      Use conflict sets to backjump past variables that did not cause a failure, and record nogoods so the same failure is not repeated.
  3. Use inference to delete values that cannot be part of any solution, before and during search, and judge what forward checking, arc consistency and stronger consistency each guarantee.
    • Apply forward checking during search
      Prune the domains of a newly assigned variable’s neighbors, detect empty domains, restore values on backtracking and recognize what forward checking misses.
    • Enforce arc consistency with AC-3
      Apply node and arc consistency, run AC-3 by hand, know its cost and limits, and maintain arc consistency during search.
    • Use stronger consistency and global constraints
      Explain path and k-consistency, propagate Alldiff and bounds constraints, and weigh the extra pruning against its cost.
  4. Start from a complete assignment and repair it with the min-conflicts heuristic, escape plateaus and local minima, and judge when local search or backtracking is the better tool.
    • Repair assignments with the min-conflicts heuristic
      Run min-conflicts by hand on a complete-state formulation, explain why it works well on large problems and use it to repair a schedule after a change.
    • Escape plateaus and local minima, and choose between local search and backtracking
      Use sideways moves, tabu search, constraint weighting and restarts, and decide which method fits a given problem.
  5. Read the constraint graph to split a problem into independent parts, solve tree-shaped problems in linear time, and turn nearly tree-shaped problems into trees.
    • Split independent subproblems and solve tree-structured CSPs
      Find independent subproblems in the constraint graph and solve a tree-structured CSP with the backward and forward passes of the tree algorithm.
    • Reduce nearly tree-structured problems to trees
      Apply cutset conditioning and tree decomposition, relate their cost to cutset size and tree width, and break value symmetry.

Constraint Satisfaction Problems study guide

5 chapters

1

Formulate problems as constraint satisfaction problems

Choosing a timetable or assigning reviewers starts with a model: what needs a value, which values are possible, and which combinations are allowed. A clear model lets the same solving methods work across very different tasks. You will build that model, distinguish requirements from preferences, and see how the choice of variables changes the work a solver faces. Small scheduling and puzzle examples make each part concrete.

1.1 Describe the parts of a constraint satisfaction problem

A constraint satisfaction problem, or CSP, describes a set of choices and the rules that connect them. Its state is a factored representation: you can inspect individual variables and their values, then reuse general methods for pruning and search.

Variables, domains, and constraints

A variable names something to choose. Its domain lists its allowed values. A constraint specifies which combinations may occur together. For workshops A and B, let each value be a time slot from {1,2,3}. The rule “A comes before B” has scope {A,B} and relation {(1,2),(1,3),(2,3)}. Writing A<B expresses the same relation compactly.

The scope names the variables involved; the relation gives the allowed tuples of values. Mixing these up leads to a model in which “red” becomes a variable. In map coloring, regions are variables and colors are values.

What counts as a solution?

An assignment gives values to variables. Three checks describe its status:

  • It is partial if some variables have no value.
  • It is complete if every variable has a value.
  • It is consistent if it violates no constraint among the assigned variables.

A solution must be complete and consistent. With A=2 alone, the assignment is consistent but partial. Extending it with B=1 makes it complete and inconsistent. Choosing B=3 gives a solution to this two-variable example. A consistent partial assignment may still have no possible completion: unassigned variables can run out of compatible choices.

Read a constraint graph

For a binary CSP, draw one node per variable and one edge for each constrained pair. In a simplified Australia map, the variables are WA, NT, SA, Q, NSW, V, and T, each with domain {red, green, blue}. The neighboring pairs are WA–NT, WA–SA, NT–SA, NT–Q, SA–Q, SA–NSW, SA–V, Q–NSW, and NSW–V. Each edge requires different colors.

One solution is WA red, NT green, SA blue, Q red, NSW green, V red, and T red. Check every edge, including SA–V. T has no edge, so its color is independent of the mainland. There are 6 mainland colorings and 3 choices for T, giving 18 solutions. A constraint involving several variables needs a hypergraph representation; an extra constraint node can connect to every variable in its scope.

Domains and search size

A finite discrete domain is a fixed list, such as three colors. An infinite discrete domain might contain every nonnegative integer start time. A continuous domain might contain real-valued times. The latter two need representations and methods suited to those domains; linear programming handles continuous linear constraints.

For n variables with d values each, there are dn complete assignments. The map has 37=2187 candidates before constraints remove any. Finite CSPs include NP-complete problems, so a general polynomial-time solution method is not known. Their internal structure still makes pruning possible: the solver can rule out a choice without listing every full assignment containing it. Only the final values determine whether the answer is valid; the path used to find them is irrelevant.

Key Takeaways

  • A CSP specifies variables, their domains, and constraints over combinations of values.
  • A solution is both complete and consistent.
  • A binary constraint graph exposes which variables directly affect one another.
  • With equal domain size, the number of complete assignments is dn.

1.2 Distinguish the kinds of constraints

Constraints differ in how many variables they connect and in whether they state requirements or preferences. Recognizing that structure helps you write a faithful model and choose useful propagation methods.

Classify the scope

A unary constraint restricts one variable. If workshop E cannot use slot 1, apply E≠1 by shrinking its domain from {1,2,3} to {2,3} before search. A binary constraint relates two variables, such as A<B or A≠D. A binary CSP contains unary and binary constraints only.

A higher-order constraint involves at least three variables. If task durations X, Y, and Z must fill 10 hours, write X+Y+Z=10. With each duration in {1,2,3,4,5}, the tuple (2,3,4) fails, while (2,3,5) works. Checking a higher-order rule requires the values to work together.

Keep useful global constraints

A global constraint gives a named rule over a variable-sized group. Alldiff⁡(X1,…,Xk) requires different values for every pair. Its solution set equals the set defined by k(k−1)/2 pairwise inequalities. For nine Sudoku cells, that is 36 binary constraints.

The global form also gives a solver access to group reasoning. Three variables restricted to two distinct values cannot all differ, even though each pair separately has a compatible assignment. Equal solution sets do not guarantee equal pruning strength.

A capacity rule can also be global. Here Atmost⁡(10,P1,P2,P3) means P1+P2+P3≤10: the total number of people assigned to the three tasks cannot exceed ten. The arguments represent quantities being added, so this rule permits, for example, (3,4,3).

Convert a finite constraint to binary form

Introduce an auxiliary variable U whose values are the allowed triples for X+Y+Z=10. One possible value is (2,3,5). Add three binary constraints: the first component of U equals X, the second equals Y, and the third equals Z. Selecting that value for U therefore requires X=2, Y=3, and Z=5.

Every original valid triple corresponds to a value of U, and every consistent assignment involving U yields a valid original triple. This construction lets binary methods handle a finite higher-order constraint. Its cost is the potentially large tuple domain, which is why solvers often retain the original global or higher-order rule.

Requirements and preferences
KindWhat it meansScheduling example
Hard constraintEvery solution must satisfy it.A trainer cannot teach two workshops at once.
Soft constraintA violation adds a cost to an otherwise feasible choice.A trainer prefers an afternoon session.

With soft constraints, the task becomes a constraint optimization problem, or COP: satisfy all hard rules and minimize total preference cost. Branch-and-bound and local search can be used for optimization.

Test the model against a known valid assignment and a known invalid one. An invented inequality between unrelated workshops removes legitimate schedules; a missing shared-trainer constraint admits impossible ones. Preferences also need care: turning “afternoon preferred” into “afternoon required” can eliminate every feasible schedule.

Key Takeaways

  • Unary constraints prune one domain; binary constraints connect two variables.
  • Alldiff requires pairwise different values but can support stronger group pruning.
  • Auxiliary tuple variables can convert finite higher-order constraints to binary form.
  • Hard constraints define feasibility; soft constraints rank feasible choices.
  • Check both a valid and an invalid case when testing a model.

1.3 Model scheduling and assignment problems as CSPs

A model should describe the decisions directly enough that the rules are easy to express. Start by identifying what must be chosen, then assign domains and translate each requirement over the variables it actually involves.

Build a workshop timetable

Five one-slot workshops share three time slots: 1 morning, 2 midday, and 3 afternoon. Let A be Python Basics, B Python Advanced, C Statistics, D Databases, and E Ethics. Each workshop is a variable with initial domain {1,2,3}.

Shared participants require A≠C, A≠D, C≠D, B≠C, C≠E, and D≠E. Basics must precede Advanced, so A<B. The Ethics trainer arrives at midday, so E≠1. These give seven binary edges and one unary rule; C has four neighbors.

The assignment A=2,B=3,C=1,D=3,E=2 satisfies every rule: each shared-participant pair differs, Basics precedes Advanced, and Ethics is not in slot 1. It is the only valid assignment among the 35=243 candidates. Workshops B and D may both use slot 3 because no rule requires them to differ.

Choosing one variable per slot instead would make each value a subset of workshops, with up to 25=32 possible subsets per slot. Rules would then have to inspect those sets and ensure every workshop occurs once. Choosing workshops as variables keeps the constraints simpler.

Express task timing and shared resources

In job-shop scheduling, use a start-time variable for each task. Prepare takes 20 minutes, Analyze 40, and Report 30. Start times are nonnegative integer minutes. The order and 120-minute deadline give

SP+20≤SA,SA+40≤SR,SR+30≤120.

The earliest starts are 0, 20, and 60. Working backward from the deadline gives latest starts 30, 50, and 90. Thus the windows are SP∈[0,30], SA∈[20,50], and SR∈[60,90].

Two tasks sharing a machine need a disjunctive constraint: SX+dX≤SY or SY+dY≤SX. Either task may go first, but they cannot overlap. A simple precedence constraint would force one particular order and remove the other possibility.

Model assignments and puzzles

For three reports assigned to three reviewers, make each report a variable with reviewer values. Use Alldiff if every reviewer handles one report. A conflict of interest removes a reviewer from the relevant report's domain.

For n-queens, let Qi be the row of the queen in column i. One queen per column is built into the model. For every pair, require Qi≠Qj and ∣Qi−Qj∣≠∣i−j∣ to prevent row and diagonal attacks. For eight queens this reduces the candidate space from choosing 8 squares out of 64, 4,426,165,368 placements, to 88=16,777,216 assignments. There are 92 solutions.

For Sudoku, the 81 cell variables have domains 1–9. Given digits impose unary constraints, and 9 rows, 9 columns, and 9 boxes each impose Alldiff.

Choose the coarsest time units that still represent every permitted start. Hourly sessions need hourly choices; minute-by-minute domains would enlarge the work without adding a useful schedule. Finish by separating preferences from hard rules and checking a small case with a known answer.

Key Takeaways

  • Choose variables that keep constraints simple and domains no finer than needed.
  • Precedence uses finish-before-start inequalities; shared resources require non-overlap.
  • One queen per column can be built into the choice of variables.
  • A correct model includes implicit resource rules and preserves legitimate shared slots.
2

Solve CSPs with backtracking search

A search can waste most of its effort revisiting the same choices or discovering conflicts too late. Backtracking builds an assignment one variable at a time and returns to earlier choices when a branch fails. Variable and value ordering help it find useful branches sooner, while conflict analysis identifies which choices caused a dead end. Tracing the decisions makes both the basic method and its improvements easier to judge.

2.1 Run backtracking search step by step

Backtracking builds a partial assignment using depth-first search. It chooses one variable, tries a value, and continues until it finds a solution or must undo a choice. The search retains the useful earlier choices when a later one fails.

Branch on values, one variable at a time

Assigning A then B produces the same final assignment as assigning B then A. This commutativity means a CSP solver can choose one variable at each level and branch on its values. Allowing every variable order would produce n!dn leaves for only dn distinct complete assignments. For five variables with three values, that is 29,160 leaves instead of 243.

The next variable may depend on the current domains. What matters is choosing a single next variable at a node; the search does not need separate branches for all possible assignment orders.

Follow the recursive steps
  1. If the assignment is complete and consistent, return it.
  2. Choose an unassigned variable.
  3. Try each domain value that is consistent with the current assignment.
  4. Recurse after adding a value. If the recursive call fails, remove that assignment and try the next value.
  5. If no value works, return failure to the caller.

Plain backtracking tests a constraint once all variables in its scope have values. With A=1 and B unassigned, A<B has no completed pair to reject. Trying B=1 then fails immediately. Waiting until every variable is assigned would postpone this easy rejection.

Trace a dead end

Use the workshop rules: A≠C,A≠D,C≠D,B≠C,C≠E,D≠E,A<B,E≠1. Take variables in order A, B, C, D, E and try values 1, 2, 3.

  • Set A=1. Reject B=1 and choose B=2.
  • Reject C=1 because of A and C=2 because of B; choose C=3.
  • Reject D=1 because of A; choose D=2.
  • E has no legal value: 1 is forbidden, 2 clashes with D, and 3 clashes with C.

Failure at E returns control to D. Its next value, 3, clashes with C. C has no later value, so control returns to B. Trying B=3 eventually produces another dead end under A=1. The search then tries A=2 and reaches A=2,B=3,C=1,D=3,E=2. With this order, plain backtracking tests 32 candidate values in total, including rejected ones.

What the method guarantees
PropertyPlain backtracking on finite domains
CompletenessFinds a solution if one exists; exhausting the search establishes infeasibility.
Worst-case search sizeExponential, O(dn) assignments in the usual bound.
Search-path memoryLinear in n; one active path is stored.

Checking constraints and storing the model also have costs. The linear memory description concerns the search path, while propagation may store domains and undo records as well.

Chronological backtracking returns to the most recent choice. Faster variants improve four separate decisions: the next variable, the order of its values, the consequences inferred after a choice, and the earlier choice to revisit after failure. These improvements reduce practical work without changing what counts as a solution.

Key Takeaways

  • Commutativity removes the need to search every assignment order.
  • Backtracking assigns one variable per level and rejects completed constraint violations.
  • A failed recursive call undoes its choice and tries another value.
  • Finite-domain backtracking is complete but has exponential worst-case search.
  • Linear search-path memory does not include all model and propagation storage.

2.2 Choose variables and values with ordering heuristics

Good ordering can expose failure near the top of a search tree or preserve useful choices for later. Variable ordering and value ordering serve different purposes, so the best-looking direction differs between them.

Choose the most restricted variable

Minimum remaining values (MRV) selects the unassigned variable with the fewest currently legal values. It is also called the most-constrained-variable or fail-first heuristic. A nearly exhausted domain is likely to reveal a contradiction soon. If a domain is empty, the branch fails immediately.

Count current values after pruning, not the initial domain sizes. Without stored domains, a solver must determine which original values are still consistent with the assignment before applying MRV.

The degree heuristic breaks an MRV tie by choosing the variable with the most constraints on other unassigned variables. Such a choice affects more remaining decisions. Already assigned neighbors do not count toward this remaining degree. At the start of the Australia map, equal three-color domains tie, and SA's five neighbors give it the highest degree.

Keep options open when choosing a value

Least constraining value (LCV) tries the value that removes the fewest values from neighboring unassigned domains. Evaluating candidate values adds computation, but may avoid an expensive failed branch.

With WA red and NT green, SA can only be blue, while Q can be red or blue. Choosing Q blue would empty SA's domain. Choosing Q red removes red from NSW while preserving SA's blue. LCV therefore tries Q red.

Ordering decisionPreferred choiceReason
Next variableFewest remaining valuesExpose a likely failure early.
Tied variableMost unassigned neighborsAffect more remaining decisions.
Next valueFewest deleted neighbor valuesPreserve chances of completing the assignment.

Every variable must eventually receive a value, which makes an early test of a fragile variable useful. Only one value is needed to complete a first solution, which favors a value that leaves room for other decisions.

Combine ordering with forward checking

In the workshop schedule, apply E≠1 first. E has two values; A, B, C, and D each have three. MRV chooses E. Try E=2, and forward checking removes 2 from C and D.

C and D now tie with domains {1,3}. C has three unassigned neighbors, A, B, and D; D has two, A and C. Degree selects C. Choose C=1, leaving DD={3} and DA=DB={2,3}. MRV picks D=3, which forces A=2; the precedence rule then gives B=3. Five assignments find the solution with no backtracking. Fixed variable order with forward checking needs 12 assignments and reaches two dead ends.

Ordering preserves completeness because it changes the sequence of choices, without discarding legal branches. The worst-case search remains exponential. When enumerating every solution or proving infeasibility, all relevant values must eventually be explored, so LCV's early-success advantage is reduced. Its main use is finding a first solution sooner.

Key Takeaways

  • MRV uses the current number of legal values.
  • Degree breaks ties using constraints on unassigned variables.
  • LCV preserves neighboring choices when trying a value.
  • Ordering changes search effort while preserving completeness.

2.3 Back up intelligently after a dead end

A dead end often has a smaller cause than the whole current assignment. Backjumping uses that cause to decide where to return, and constraint learning remembers a failure so it need not be rediscovered.

Find the choices that caused failure

On the Australia map, take the assignment order Q, NSW, V, T, SA. Let Q be red, NSW green, V blue, and T red. SA touches Q, NSW, and V, so all three colors are forbidden. Its conflict set is {Q,NSW,V}: earlier variables whose choices exclude its values.

Chronological backtracking would try changing T. Tasmania has no edge to SA, so changing its color cannot restore any option for SA. Backjumping returns to V, the most recently assigned member of the conflict set, and skips T.

A conflict set contains variables; a nogood records particular assignments. That distinction matters: another color for V may fix the failure, even though V is still a neighbor of SA.

Carry a conflict through earlier failures

Simple backjumping uses the current failure's direct conflict set. Conflict-directed backjumping carries information through several failed levels. When a failed variable X jumps to Y, Y absorbs X's conflict set with Y removed. If Y later exhausts all its values, its combined set identifies a cause further back in the assignment.

For example, use order WA, NSW, T, NT, Q, V, SA, and start with WA red, NSW red, T red. WA and NSW are not neighbors, so this partial assignment is consistent. Their choices remove red from NT, Q, and SA. Those three regions form a triangle, which cannot be colored using only green and blue.

No choice made for T changes that triangle. Conflict information can travel backward through the failed attempts and identify WA and NSW as the underlying cause. The search returns to NSW, the later of those two decisions, instead of spending time recoloring T.

Learn the failed combination

A solver can record {WA=red,NSW=red} as a nogood. Whenever both choices recur, the same triangle contradiction follows, so the branch can be rejected immediately. It would be incorrect to forbid WA red on its own: WA can be red in valid solutions with a different NSW color.

Learning adds a constraint or a cached forbidden combination. The learned condition must follow from the original constraints; failure caused merely by reaching a time limit supplies no such logical justification. A useful nogood keeps enough assignments to explain the impossibility without including unrelated choices.

Combine looking ahead and looking back

Forward checking and arc consistency remove unsupported values before a deep failure occurs. Backjumping diagnoses a failure after it occurs. Simple direct backjumping adds no pruning beyond what forward checking already detects, but conflict-directed methods can combine explanations of deeper failures. Learning preserves those explanations across later branches.

Key Takeaways

  • A conflict set identifies earlier variables responsible for a failure.
  • Backjumping skips choices unrelated to that failure.
  • Conflict-directed backjumping combines conflict information across failed levels.
  • A nogood forbids an impossible combination of assignments, not each assignment separately.
  • Look-ahead pruning and learned explanations can work together.
3

Prune domains with constraint propagation

A value can be impossible even before its variable is chosen. Constraint propagation follows the consequences of current domains and assignments, deleting values that lack the support they need. The methods differ in how far they look: from the immediate neighbors of a decision to pairs, triples, and whole groups of variables. Worked domain changes show what each method detects, what it misses, and when the extra work pays off.

Forward checking asks what a new assignment immediately rules out for unassigned neighbors. It deletes incompatible values before search reaches those variables, making some dead ends visible several levels earlier.

Prune after an assignment

After choosing X=x, inspect each unassigned Y sharing a constraint with X. Delete every value in DY that conflicts with the choice. An empty domain means the current branch has no completion, so backtrack immediately.

For X≠Y, assigning X=2 removes 2 from Y. For X<Y, assigning X=2 removes every Y value at most 2. The actual relation determines what is removed; forward checking is not limited to deleting equal values.

Pruning changes the current branch's domains. Keep an undo record, often called a trail, of every deletion caused by the choice. When that choice is undone, restore its deletions while retaining restrictions that belong to earlier choices. Copies of domains at each level provide another implementation.

Follow the workshop domains

Use slots 1–3 and rules A≠C,A≠D,C≠D,B≠C,C≠E,D≠E,A<B,E≠1. Apply the unary rule to get DE={2,3}, then use fixed order A, B, C, D, E.

  1. A=1 leaves B, C, and D with {2,3}.
  2. B=2 leaves C with {3}.
  3. C=3 leaves D and E each with {2}.
  4. D=2 removes 2 from E, emptying its domain. Backtrack.

Restoring domains and trying B=3 forces C to 2. D and E both become 3, so assigning D empties E again. The search must change A. With A=2, it can reach B=3,C=1,D=3,E=2. This trace tries 12 values, compared with 32 candidate tests for plain backtracking in the same order.

Recognize the limit of one-step checking

After step 3, D and E both have the sole value 2 and must differ. Forward checking still has not checked that constraint: neither D nor E was newly assigned. It detects the failure only when D receives its value.

This is the central limit of forward checking. It tests the assigned variable against its unassigned neighbors, without propagating a neighbor's smaller domain onward. Arc consistency can follow those consequences between unassigned variables.

Use the maintained domains

MRV can now select the smallest remaining domain directly. A singleton domain often becomes the next choice; an empty domain signals failure without adding another assignment. Keeping domains up to date helps both inference and ordering.

For at most n−1 neighbors and at most d values per neighbor, a forward-checking pass uses about O(nd) binary checks, assuming a constant-time relation test. It removes only values incompatible with the current assignment, so backtracking stays complete. Forgetting to restore a deletion can make a later branch lose a valid solution; pruning an unrelated variable can do the same.

Key Takeaways

  • Forward checking prunes unassigned neighbors of the new assignment.
  • An empty domain rejects the current branch immediately.
  • Restore branch-specific deletions when undoing a choice.
  • Forward checking does not propagate between two unassigned variables.

3.2 Enforce arc consistency with AC-3

A value needs a compatible partner in every neighboring domain. Arc consistency makes that support requirement explicit and follows the effects of domain changes throughout a binary CSP.

Support has a direction

Node consistency first removes values forbidden by unary rules. For a binary constraint, the directed arc X→Y is consistent when every value in X has at least one compatible value in Y. That value in Y is a support. Revising the arc deletes unsupported values from its tail, X.

For A<B with both domains {1,2,3}, revising A→B deletes 3 from A. Revising B→A deletes 1 from B. The resulting domains are DA={1,2} and DB={2,3}. A surviving value may use a different support for each neighbor; the supports need not form one joint solution.

Run AC-3

AC-3 uses a queue of directed arcs:

  1. Initially put every arc in the queue.
  2. Remove X→Y and revise X using Y's domain.
  3. If X becomes empty, stop with failure.
  4. If X shrinks, add Z→X for each other neighbor Z of X, excluding Y.
  5. Continue until the queue is empty.

A deletion in X can remove a support for Z, so the queue must point back into the changed domain. The arc from Y needs no immediate recheck: the deleted X values supported no value in Y, since none was compatible with Y in the first place. Nonempty closure domains are independent of processing order; different orders can reach failure at different empty domains.

Propagate a workshop decision

For the workshop rules A≠C,A≠D,C≠D,B≠C,C≠E,D≠E,A<B,E≠1, initial AC-3 removes 3 from A and 1 from B. It leaves C and D at {1,2,3} and E at {2,3}.

Now decide C=1. The arc A→C removes 1 from A, leaving A=2. Revising B against A forces B=3. D differs from C and A, so D=3. E differs from D and cannot be 1, so E=2. Domain reductions have traveled beyond the original decision's immediate neighbors.

Maintaining arc consistency (MAC) applies this inference after every search decision. Starting from arc-consistent domains, restricting X=x requires a queue of incoming arcs from its unassigned neighbors. Domain deletions must be restored when search undoes the branch.

Interpret the result and cost
Result after node and arc consistencyMeaning
An empty domainNo solution extends the current restrictions.
Every domain is a singletonThe unique remaining assignment satisfies the binary CSP.
Some domains have multiple valuesFurther inference or search may be needed.

A triangle with domains {red, blue} and inequalities on all three edges remains arc-consistent, yet has no solution. Each edge has supports separately, but the three choices cannot work together.

With c binary constraints and maximum domain size d, AC-3 takes O(cd3) time: an arc revision checks up to d2 pairs, and each arc can require up to d rounds as its head loses values. MAC spends more per search node than forward checking, often in exchange for a much smaller search tree.

Key Takeaways

  • Revising X→Y removes unsupported values from X.
  • After X shrinks, AC-3 rechecks arcs pointing into X.
  • Nonempty arc-consistent domains can still describe an unsatisfiable CSP.
  • MAC maintains arc consistency after search decisions.
  • AC-3 has the standard worst-case bound O(cd3).
  • Singleton conclusions require unary and binary constraints to have been enforced.

3.3 Use stronger consistency and global constraints

Separate pairwise supports can hide a group contradiction. Stronger consistency and specialized global propagation examine combinations that arc consistency misses, while numeric bounds can compress large domains into useful intervals.

Extend assignments to another variable

Path consistency examines triples. Every consistent assignment to two variables must have an extension to a third that agrees with both. In a triangle colored red or blue, X red and Y blue leave no value for Z. Path consistency removes that allowed pair and ultimately exposes infeasibility. It can remove tuples from relations, so it does more than delete individual domain values.

k-consistency requires every consistent assignment to any k−1 variables to extend to any additional variable. For binary CSPs, 1-consistency corresponds to node consistency, 2 to arc consistency, and 3 to path consistency. Strong k-consistency includes every level from 1 through k. With strong n-consistency on n variables and nonempty domains, any consistent partial assignment can be extended until it is a solution, without backtracking. Establishing this property has exponential worst-case time and memory costs.

Count values in Alldiff

Alldiff requires distinct values for all variables in its scope. If a group of m variables has only n distinct possible values and m>n, no assignment can satisfy it.

For three cells with domains {4,7}, pairwise inequalities are arc-consistent: each 4 has support 7 in every neighbor, and each 7 has support 4. The global count nevertheless fails because three different values are needed and only two exist.

If two cells both have domain {4,7}, they must use 4 and 7 between them. Those values can be removed from every other cell in that row. This naked pair reasoning uses a subset of the whole Alldiff scope. A simple global propagator can also process singleton variables repeatedly, remove their values elsewhere, and check whether too few distinct values remain. Stronger propagators recognize constrained subsets as well.

Tighten numeric bounds

Bounds propagation stores a domain by its minimum and maximum. Bounds consistency requires each endpoint to have a satisfying extension for each relevant constraint; it does not check every interior value.

For two buses carrying 100 people, let B1∈[0,50] and B2∈[0,70], with B1+B2=100. The second bus carries at most 70, forcing B1≥30. The first carries at most 50, forcing B2≥50. The tightened windows are [30,50] and [50,70].

For Prepare, Analyze, and Report taking 20, 40, and 30 minutes in that order, a 120-minute deadline gives latest starts 30, 50, and 90. Nonnegative starts give earliest starts 0, 20, and 60. Propagating forward and backward obtains these windows before a start time is chosen.

Choose useful strength

Each Sudoku cell has 20 distinct peers: 8 in its row, 8 in its column, and 4 additional cells in its box. Across 81 cells that gives 81×20/2=810 distinct unequal pairs. Global constraints preserve the same solutions as those pairs but can expose naked pairs and shortages sooner. Stronger inference costs more per pass; practical solvers balance that cost against the search it saves, often combining arc consistency with specialized global and bounds propagation.

Key Takeaways

  • Path consistency checks whether a consistent pair extends to a third variable.
  • Strong k-consistency includes every smaller consistency level.
  • Alldiff detects groups with too few distinct values.
  • A naked pair reserves its two values for those two variables.
  • Bounds propagation tightens endpoints without enumerating a large numeric domain.
  • Stronger inference trades extra work per pass for less search.
4

Solve CSPs with local search

A timetable that violates a few rules can still be a useful starting point. Local search keeps a value for every variable and repairs conflicts one move at a time. The challenge is to select productive moves and escape regions where progress stops. You will follow min-conflicts on a small board, examine ways to keep repairs moving, and choose a solving method that matches the evidence a scheduling or assignment task needs.

4.1 Repair assignments with the min-conflicts heuristic

Local search starts with a value for every variable, even when some constraints fail. Min-conflicts repairs this complete assignment by moving one conflicted variable to a value with as few conflicts as possible.

Choose a repair
  1. Construct a complete assignment, randomly or greedily.
  2. If no constraint is violated, return the solution.
  3. Randomly choose a variable involved in a violated constraint.
  4. Evaluate each of its domain values against the other variables, which stay fixed.
  5. Choose a value with the fewest conflicts, breaking ties randomly, and repeat until success or a step limit.

A conflicted variable participates in at least one violated constraint. It is not necessarily the variable with the largest number of violations. Random choice among conflicted variables and tied values helps prevent a rigid repeated sequence.

Repair a 4-queens board

Use one queen per column, with row variables Q1,Q2,Q3,Q4. A pair conflicts if its rows are equal or its row difference equals its column difference. Begin with (2,4,2,3). Columns 1 and 3 share row 2; columns 3 and 4 attack diagonally. The conflicted variables are Q1, Q3, and Q4.

Choose Q3 and evaluate rows while Q1, Q2, and Q4 remain fixed:

Candidate row for Q3Conflicts involving Q3
10
22
32
43

Row 1 yields (2,4,1,3), a solution. If Q1 had been chosen instead, its counts for rows 1–4 would be 0, 1, 2, and 2. Moving it to row 1 gives (1,4,2,3), leaving the Q3–Q4 diagonal conflict. A locally best repair can therefore lead to another incomplete repair process.

Count constraints involving the selected variable. Counting all violations in each resulting board gives the same ordering, because unrelated constraints contribute a constant to every candidate. It simply requires more work. Use one consistent conflict definition when comparing candidates.

Repair an existing schedule

When a trainer becomes unavailable, the current timetable is already a complete assignment. Min-conflicts can start there and move sessions until the new and existing constraints hold. A small change often needs few repairs, although one move can create new conflicts elsewhere. If retaining the old plan matters, attach an explicit cost to changing an assignment; minimizing violations alone does not minimize disruption.

Experiments with a good initial assignment have required relatively few repair steps even for a million queens. Larger boards still make each step more expensive. Min-conflicts has also been used for Hubble scheduling, with a reported reduction from about three weeks to about 10 minutes to schedule a week of observations.

Interpret search behavior

Many random CSP families change from mostly solvable to mostly unsolvable as the constraint-to-variable ratio rises. Near that transition, deciding how choices interact is often hardest. Loosely constrained problems can have many easily reached solutions. Highly constrained unsatisfiable problems may be quickly rejected by complete propagation-based solvers.

Reaching a min-conflicts step limit means no solution was found in that run. The problem may still be solvable. The method's practical strength comes from efficient repairs, including equal-score moves, despite solutions being a tiny fraction of all possible assignments.

Key Takeaways

  • Min-conflicts starts with a complete assignment and repairs violated constraints.
  • Choose a conflicted variable, then a minimum-conflict value with random tie-breaking.
  • Candidate scores can ignore constraints unrelated to the chosen variable.
  • Repairing feasibility and minimizing changes are different objectives.
  • A step-limit failure leaves feasibility unresolved.

4.2 Escape plateaus and local minima, and choose between local search and backtracking

Repair search can stop improving while conflicts remain. To continue, the solver needs a way to move through equal-score states or change which moves appear worthwhile. The required outcome also matters: a quick feasible repair and a proof of infeasibility demand different methods.

Move through a plateau

A local minimum has violations but no single-variable move that lowers their count. A plateau is a connected region of assignments with the same score. Downhill-only moves can become trapped; a sideways move changes the state without lowering the score.

For 4-queens, (1,4,2,3) has one conflict between Q3 and Q4. With other queens fixed, Q3's counts for rows 1–4 are 1, 1, 3, and 2; Q4's are 2, 2, 1, and 2. Neither variable has an improving move.

Moving Q3 to row 1 gives (1,4,1,3), still with one conflict, now Q1–Q3 sharing a row. In this new state Q1's counts are 1, 0, 3, and 1. Moving Q1 to row 2 produces (2,4,1,3) and eliminates the conflict. The sideways move changed which improving moves were available.

Keep search moving
MethodHow it changes search
Tabu searchTemporarily forbids recent states or moves to reduce cycling.
Constraint weightingRaises the importance of constraints that remain violated.
Random restartsBegins again from a different complete assignment after fruitless steps.
Simulated annealingSometimes accepts worse moves, with acceptance reduced as temperature falls.

A tabu list is short-lived memory. It discourages returning immediately to a state just left. A restart explores a different region, while annealing can cross a higher-conflict region within the current run.

With constraint weighting, start each weight at 1 and score a state by the sum of the weights of its violated constraints. Choose a change that reduces this weighted score, then increase the weights of constraints that remain violated. Repeated failures become more costly, reshaping the search landscape. A zero weighted score still means that every positively weighted hard constraint is satisfied.

Choose the evidence you need

Local search is incomplete: it may miss an existing solution, and a finite unsuccessful run leaves infeasibility unresolved. Finite-domain backtracking with propagation is complete: eventually it finds a solution or exhausts every possible completion.

Use local search when a large, loosely constrained problem needs one feasible assignment or a fast repair. Backtracking with MRV and MAC is a strong choice for tight puzzles and whenever the task requires an infeasibility result. Runtime still depends on the instance; these are method choices grounded in their guarantees.

The workshop schedule has the unique solution A=2,B=3,C=1,D=3,E=2. Adding C≠1 eliminates it. Min-conflicts may try repairs until its limit, but only a complete search that exhausts the remaining cases establishes that the organizer must change a requirement, such as adding another slot.

Key Takeaways

  • A sideways move can expose an improving move beyond a plateau.
  • Tabu memory, weights, restarts, and annealing address different obstacles to progress.
  • Local search is incomplete; exhaustive finite-domain backtracking is complete.
  • Choose a complete method when infeasibility must be established.
5

Exploit the structure of a problem

The shape of a constraint graph can matter as much as the size of its domains. Separate components can be solved independently, and a tree allows a backward pruning pass followed by forward assignment without backtracking. Cycles require more work, but a small cutset or a narrow tree decomposition can control it. These methods connect graph structure with the time needed to find a consistent assignment.

5.1 Split independent subproblems and solve tree-structured CSPs

A constraint graph can reveal smaller problems inside a large one. Independent components can be solved separately, and acyclic components admit a particularly efficient algorithm with a backward pruning pass and a forward assignment pass.

Split disconnected components

A connected component is independent when no constraint links its variables to another component. Solve each component, then combine one solution from each. If any component is unsatisfiable, the full CSP is unsatisfiable. In the Australia map, Tasmania is independent of the mainland.

With n variables divided into independent groups of size c, solving one full assignment takes work on the order of O((n/c)dc) instead of O(dn). For 60 binary variables split into three groups of 20, separate exhaustive searches consider at most 3×220=3,145,728 assignments instead of about 1.15×1018. Enumerating every combined solution would still require listing the combinations; the saving describes solving the component problems.

Order a tree from its root

A binary CSP is tree-structured when its constraint graph is acyclic. A connected tree has one path between each pair of variables; a forest contains separate trees. First apply unary restrictions. Choose any root and order variables so that every parent appears before its children.

Directed arc consistency in this order requires each earlier variable to have support in every later neighbor. On a tree, those later neighbors are its children. The direction of support is parent to child, even though the algorithm processes children before parents.

Prune backward, assign forward
  1. Read the order backward, excluding the root. For each child, revise the arc from its parent to that child. Delete unsupported values from the parent's domain.
  2. If a domain empties, report no solution.
  3. Read the order forward. Choose any surviving root value, then give each child a value compatible with its assigned parent.

The child's descendants have already been processed when its parent is revised. A surviving parent value therefore has support in each child, and each child value already has support farther down. Different child branches have no edges connecting them, so those supports can be chosen independently. That is why the forward pass needs no backtracking.

Follow the workshop tree

Fix C=1 in the workshop schedule and remove 1 from the other workshops' domains. The remaining graph is the path B–A–D–E, with domains {2,3} and constraints A<B,A≠D,D≠E.

Choose root A and order A, B, D, E. The backward pass revises D→E, then A→D, with no changes. Finally A→B removes 3 from A because B has no larger value. Assigning forward gives A=2,B=3,D=3,E=2. Restoring C=1 gives the complete timetable.

For n variables with maximum domain size d, the backward pass revises n−1 arcs at up to O(d2) each, yielding O(nd2) time. The guarantee depends on acyclicity. A cycle can connect separate child branches and invalidate the independence that made those local choices safe.

Key Takeaways

  • Disconnected components can be solved independently and combined.
  • The tree method first enforces unary restrictions and orders parents before children.
  • The backward pass revises parent-to-child arcs and prunes parents.
  • The forward pass chooses compatible values without backtracking.
  • The standard tree-CSP time bound is O(nd2).

5.2 Reduce nearly tree-structured problems to trees

A graph with a few cycles may still be close enough to a tree to solve efficiently. Cutset conditioning assigns selected variables first; tree decomposition groups variables into overlapping parts. Both make the remaining coordination tree-shaped.

Condition on a cycle cutset

A cycle cutset is a set of variables whose removal leaves a tree or forest. Check every remaining cycle, not just the most visible one. For the Australia map, removing SA leaves the path WA–NT–Q–NSW–V plus isolated T. For the workshop graph, removing C leaves B–A–D–E.

For each assignment to the cutset that satisfies its internal constraints:

  1. Remove incompatible values from the remaining domains.
  2. Solve each remaining tree using backward pruning and forward assignment.
  3. If all succeed, combine their assignments with the cutset values. Otherwise try another cutset assignment.

In the workshop problem, C=1 leaves a solvable tree. With C=2, A and B must come from {1,3} and A<B forces A=1,B=3. D must differ from both A and C, giving D=3. E cannot be 1 and must differ from C and D, leaving no value. With C=3, A and B must be 1 and 2; D must then be 2, again leaving E no value.

For cutset size c, there are at most dc assignments, each followed by a tree problem of cost O((n−c)d2). The total is O(dc(n−c)d2). Small c makes this useful; it remains exponential in c. Finding a minimum cutset is NP-hard, but a valid nonminimum cutset still gives a correct procedure.

Join overlapping bags

A tree decomposition arranges sets of variables, called bags, in a tree. It must satisfy three conditions:

  • Every variable appears in a bag.
  • Every constraint's scope fits inside at least one bag.
  • Bags containing any one variable form a connected part of the bag tree.

The third rule is the running-intersection property. If X appears at both ends of a bag path, it must appear throughout that path. Otherwise distant bags could choose inconsistent X values without any intervening agreement check.

Each bag's locally valid assignments become values of a mega-variable. Adjacent bags must agree on shared variables. The resulting tree coordinates the local solutions. For a triangle X–Y–Z–X plus edge Z–W, bags {X,Y,Z} and {Z,W} cover every edge and agree on Z.

The decomposition's tree width is its largest bag size minus 1. A graph's tree width is the minimum across valid decompositions. For width w, the standard CSP bound is O(ndw+1). Fixed bounded width controls the exponent.

Remove value symmetry

When color names have no special meaning, permuting red, green, and blue preserves validity. The six mainland Australia solutions are six renamings of one pattern. Fixing the order NT before SA before WA in the color order red, green, blue keeps one representative. Such a symmetry-breaking constraint is valid only when the renaming preserves the original rules. A rule requiring a particular region to be red makes that color special and changes which permutations remain symmetries.

Key Takeaways

  • A cycle cutset must remove every cycle.
  • Conditioning tries cutset assignments and solves the remaining forest.
  • Conditioning cost is exponential in cutset size.
  • Tree decompositions cover variables and constraints and satisfy running intersection.
  • Tree width is maximum bag size minus one, minimized over decompositions for the graph.
  • Break value symmetry only for renamings that preserve the original constraints.

Constraint Satisfaction Problems examples

5 Walkthroughs

1

Build and check a CSP model

13 steps
Model schedules and assignments, inspect constraint scopes, and test whether the model preserves the real rules.
  1. 1
    IntroductionTurn a task into choices

    A solver needs a precise account of what can be chosen and which combinations work. That account is a set of variables with domains of values, plus constraints that each cover a scope of variables, and any error in it carries into every search. Build a small timetable, then compare it with assignment and puzzle models. The goal is to make the decisions and their dependencies visible before trying to solve them.

  2. 2
    ExplanationName each decision

    Let A and B be workshop time slots, each in {1,2,3}. A must precede B, so write A<B. The variables are the workshops’ slot choices; the numbers are values.

    The constraint’s scope is A and B. Its relation allows the pairs (1,2),(1,3),(2,3). A solver can use either that tuple list or the ordering rule to test a candidate.

  3. 3
    ExampleCheck a candidate assignment

    With A=2 alone, the assignment is partial and consistent. Choosing B=1 completes it but violates the ordering rule. Choosing B=3 instead gives a complete, consistent assignment.

    These are separate checks: every variable needs a domain value, and every constraint must hold. A partial assignment can pass the current checks yet leave no possible completion.

  4. 4
    ChallengeCan the partial choice be completed?

    Three variables X, Y, and Z have domains {1,2} and constraints X≠Y,Y≠Z,X≠Z. X is assigned 1. Is this consistent partial assignment extendable?

    ---reveal---

    No. X alone violates no constraint. Completing it forces both Y and Z to 2, which violates their inequality. Current consistency and possible completion are different requirements.

  5. 5
    ConnectionRead dependencies from the graph

    A binary constraint graph places one node at each variable and an edge at each constrained pair. The triangle from the challenge shows three interacting choices. An isolated variable has no binary dependency on another variable.

    This graph supports later methods: pruning follows edges, and disconnected components can be solved independently. A higher-order constraint needs its whole scope represented, such as by a separate constraint node.

  6. 6
    ExplanationMatch the rule to its scope

    A unary rule restricts one domain: E≠1 removes the earliest slot from Ethics. A binary rule connects two variables: A<B orders workshops. A higher-order rule such as X+Y+Z=10 connects three choices.

    A global constraint gives a named rule over a variable-sized group. Alldiff requires every value in its scope to differ from every other value.

  7. 7
    ExampleWhy keep Alldiff?

    Three report variables each allow reviewers 1 and 2. Every pair can be assigned different reviewers, but three reports cannot use three distinct reviewers from a set of two.

    Alldiff exposes this shortage at the group level. Its pairwise inequality form has the same solutions, yet separate pair checks can miss the contradiction. Representation affects the inference a solver can perform.

  8. 8
    ChallengeRequirement or preference?

    A room plan must keep meetings within capacity. One organizer prefers a room near the entrance, but an eligible room farther away is available. Should choosing the farther room make the plan infeasible?

    ---reveal---

    No. Capacity is a hard requirement, while location is a soft preference. The farther room can carry a preference cost without invalidating the plan. Feasibility still requires every hard rule to hold.

  9. 9
    ExampleModel the workshop day

    Use variables A–E for Python Basics, Python Advanced, Statistics, Databases, and Ethics. Each takes slot 1, 2, or 3.

    Shared participants give A≠C,A≠D,C≠D,B≠C,C≠E,D≠E. Basics precedes Advanced, so A<B. Ethics cannot be in slot 1, so E≠1. Each rule connects exactly the decisions it governs.

  10. 10
    ExampleVerify the complete schedule

    Try A=2,B=3,C=1,D=3,E=2. The six shared-participant pairs differ. Basics is before Advanced, and Ethics is not in the morning. Every workshop has a permitted slot, so this is a solution.

    B and D share slot 3, which is allowed because no constraint connects them. Adding a rule that every workshop differs would reject this legitimate schedule.

  11. 11
    ExplanationWrite non-overlap correctly

    If task X lasts 20 minutes and task Y lasts 35, their shared machine allows either order:

    SX+20≤SYorSY+35≤SX.

    Each alternative compares one finish time with the other start time. Using “and” would require both positive-duration tasks to precede each other. Use a single precedence rule only when the task order is actually fixed.

  12. 12
    ChallengeBuild an assignment model

    Three reports need three different reviewers. Reviewer 2 has a conflict of interest with report A. What variables, domains, and constraints express the task?

    ---reveal---

    Use one variable per report with reviewer values 1–3. Remove 2 from A’s domain and apply Alldiff to all three reports. These are a unary eligibility restriction and a global distinctness rule; the model gives each report exactly one reviewer.

  13. 13
    RecapCheck the model before searching

    Identify the decisions, list their allowed values, and write the actual requirements over them. Check a valid and an invalid case. Hard rules determine feasibility; preference costs guide optimization. The variable choice should keep these rules easy to express.

2

Trace and improve backtracking

14 steps
Follow recursive choices, apply variable and value ordering, and use conflict explanations to avoid repeated failed work.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionBuild a solution one choice at a time
  2. 2
    Key InsightOne next variable is enough
  3. 3
    ExampleStart the fixed-order search
  4. 4
    ExampleRecognize the dead end
  5. 5
    ChallengeWhich call tries another value?
  6. 6
    ExplanationChoose the variable likely to fail
  7. 7
    ExampleLet domains drive the workshop order
  8. 8
    Key InsightKeep options open for the value
  9. 9
    ChallengeChoose a value after selecting the variable
  10. 10
    ExampleSkip an unrelated decision
  11. 11
    ExplanationCarry causes back through search
  12. 12
    ExampleLearn a failed combination
  13. 13
    ChallengeReconcile ordering and learning
  14. 14
    RecapSeparate the search improvements
3

Trace pruning from one decision to a group conflict

17 steps
Follow forward checking, AC-3, MAC, and stronger propagation, including the limits of each inference level.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionFollow what a domain change implies
  2. 2
    ExplanationPrune immediate neighbors
  3. 3
    ExampleWatch the missed interaction
  4. 4
    ChallengeRestore just the right values
  5. 5
    ExplanationSupport is checked from tail to head
  6. 6
    ExampleStart a chain of consequences
  7. 7
    ExampleFinish the arc-consistent closure
  8. 8
    TipQueue the arcs that may lose support
  9. 9
    ChallengeWhat does nonempty closure mean?
  10. 10
    ConnectionMaintain consistency during search
  11. 11
    ExplanationCheck a pair against a third variable
  12. 12
    Key InsightWhy strong consistency matters
  13. 13
    ExampleReserve a pair of values
  14. 14
    ExamplePush numeric bounds in both directions
  15. 15
    ChallengeDetect a group shortage
  16. 16
    ChallengeChoose the inference that explains the failure
  17. 17
    RecapRead each guarantee precisely
4

Repair a board and escape a plateau

11 steps
Run min-conflicts, follow a sideways move, and select a method that supplies the required feasibility evidence.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionRepair a complete candidate
  2. 2
    ExplanationChoose a conflicted variable
  3. 3
    ExampleLocate attacks on the board
  4. 4
    ExampleScore one queen’s candidate rows
  5. 5
    ChallengeIgnore the constant background
  6. 6
    ExampleReach a state with no improving move
  7. 7
    ExampleUse a sideways move to open a repair
  8. 8
    TipMatch the escape method to the obstacle
  9. 9
    ChallengeChoose a solver for an infeasibility decision
  10. 10
    ConnectionRepair while controlling disruption
  11. 11
    RecapJudge the outcome of repair
5

Solve trees and control the remaining cycles

15 steps
Trace component solving, tree passes, cutset trials, and the requirements of a valid tree decomposition.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionUse the graph to reduce the work
  2. 2
    ExplanationSolve independent components separately
  3. 3
    ExplanationSet up the tree order
  4. 4
    ExamplePrune the workshop tree backward
  5. 5
    ExampleAssign the surviving values forward
  6. 6
    ChallengeCatch a reversed arc
  7. 7
    ExplanationBreak every cycle with a cutset
  8. 8
    ExampleTry the workshop cutset
  9. 9
    Key InsightSmall cutsets control the exponent
  10. 10
    ExplanationReplace cycles with overlapping bags
  11. 11
    ChallengeCheck the bag path
  12. 12
    ConnectionUse bag size to read the cost
  13. 13
    ConnectionRemove interchangeable color names
  14. 14
    ChallengeCombine a cutset with the tree guarantee
  15. 15
    RecapCheck the structural condition

Constraint Satisfaction Problems practice questions

40 Practice Questions in 4 sets

Set 1: Model choices and follow the basic algorithms10 Practice Questions

Question 1 of 10

Four sensor channels must all use different frequencies. How many pairwise inequalities express the same requirement as Alldiff on these four variables?
  1. 4
  2. 8
  3. 12
  4. 6
Show answerHide answer
Answer: D
Each of the four variables must differ from each of the other three, but counting in both directions counts every pair twice. The total is therefore four times three divided by two, or six. Four inequalities would check too few pairs to enforce the whole requirement.

Question 2 of 10

Three delivery jobs J, K, and L each take a value from {1,2}. The only constraint is J≠K. How should the assignment J=1,K=2 be classified?
  1. Complete and consistent
  2. Partial and consistent
  3. Partial and inconsistent
  4. Complete and inconsistent
Show answerHide answer
Answer: B
The assigned values satisfy the only constraint, so the assignment is consistent. L has no value yet, which makes it partial. Satisfying every constraint whose variables are assigned does not turn a partial assignment into a complete one.

Question 3 of 10

Tests U and V require the same device for 12 and 18 minutes. Their nonnegative start times are SU and SV. What constraint permits either order while preventing overlap?
  1. SU+12≤SV or SV+18≤SU
  2. SU+12≤SV and SV+18≤SU
  3. SU+18≤SV or SV+12≤SU
  4. SU+12≤SV or SV+12≤SU
Show answerHide answer
Answer: A
Non-overlap allows U to finish before V starts or V to finish before U starts. Each finish time uses that task’s own duration. Joining the two orders with “and” would require each positive-duration test to finish before the other starts, making the model infeasible.

Question 4 of 10

A depth-first CSP solver tries P=2, explores every consistent continuation, and finds that all fail. P also has untried value 4. What should the solver do next?
  1. Keep P = 2, retry children
  2. Undo P and return failure
  3. Undo P = 2 and try P = 4
  4. Undo all and restart search
Show answerHide answer
Answer: C
Failure of every continuation under P = 2 rejects that branch, so the solver removes the choice and tries P = 4. Returning failure from P immediately would skip an untried value. The earlier assignments stay in place unless P eventually exhausts its whole domain.

Question 5 of 10

Unassigned variables have domains DH={1,4}, DJ={2}, and DK={1,2}. H has four unassigned neighbors, J has one, and K has three. Using MRV with degree as a tie-breaker, which variable comes next?
  1. J
  2. H
  3. K
  4. H or K
Show answerHide answer
Answer: A
J has one remaining value, while H and K each have two, so MRV chooses J. Degree is used only when the smallest domain sizes tie. Choosing H because it has the most unassigned neighbors would reverse the priority of the two heuristics.

Question 6 of 10

Let DM={1,2,3,4} and DN={2,3,4}, with M<N. After assigning M=3, what domain does forward checking leave for N?
  1. {2,4}
  2. {3,4}
  3. {4}
  4. {2,3}
Show answerHide answer
Answer: C
N must be greater than the assigned value 3, so only 4 remains. Deleting just the equal value 3 would leave 2, which also violates the ordering rule. Forward checking applies the actual binary relation, whether it is inequality, precedence, or another condition.

Question 7 of 10

For X+Y+Z=7, an auxiliary variable U contains all allowed triples and is linked to X, Y, and Z by component-equality constraints. If U=(1,4,2), what values are required?
  1. X=4,Y=2,Z=1
  2. X=1,Y=2,Z=4
  3. X=1,Y=4,Z=2
  4. X=2,Y=4,Z=1
Show answerHide answer
Answer: C
The first, second, and third components of U are constrained to equal X, Y, and Z in that order. Thus the chosen tuple requires 1, 4, and 2, respectively. Another permutation may also sum to 7, but it is incompatible with this particular value of the auxiliary variable.

Question 8 of 10

A complete assignment has four violated constraints. A selected variable R participates in one of them. Candidate values a, b, and c give R conflict counts 2, 0, and 1, respectively. Which value does min-conflicts select?
  1. a
  2. c
  3. a or c
  4. b
Show answerHide answer
Answer: D
Min-conflicts compares the violations involving R while other variables stay fixed, so b wins with zero. The three unrelated violations add the same amount to every resulting state. Choosing c because it seems to reduce the total by only one confuses the local score with that constant background.

Question 9 of 10

A binary constraint graph has components {U,V} and {W,Z} with no edge between them. Each component has a solution. How can a solution of the full CSP be formed?
  1. Use only one component’s solution
  2. Combine one solution from each component
  3. Require matching values across components
  4. Assign both components the same values
Show answerHide answer
Answer: B
No constraint connects the components, so combining any solution of the first with any solution of the second satisfies every rule. Requiring their values to match would add a restriction absent from the model. Independence allows each component to choose its own valid assignment.

Question 10 of 10

A graph has edges P–Q, Q–R, R–S, S–P, R–T, T–U, and U–R. One variable will be conditioned on to leave an acyclic graph. Which single-variable cutset works?
  1. R
  2. P
  3. T
  4. Q
Show answerHide answer
Answer: A
Removing R breaks both the four-node cycle and the triangle, leaving the path Q–P–S and the separate edge T–U. Removing P or Q breaks only the four-node cycle, leaving R–T–U–R intact. A cycle cutset must eliminate every cycle in the graph.
Set 2: Trace propagation and diagnose failed search10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

Variables P, Q, and R have domains DP=DQ={1,2} and DR={1}. The rules are P≠Q and Q≠R. What happens when the partial assignment P=1 is extended?
  1. Q must be 2, so R = 1 works
  2. Q must be 1, which clashes with P
  3. Q and R must both be 2
  4. P must be 2 because R is 1
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

For X<Y, let DX={2,5} and DY={3,4}. What happens when the arc X→Y is revised?
  1. Y loses 3; X stays unchanged
  2. X loses 2; Y stays unchanged
  3. X loses 5; Y stays unchanged
  4. Y loses 4; X stays unchanged
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

Four variables each have three values. A search branches over every unassigned variable and every value until complete assignments are reached. By what factor does selecting one variable per level reduce the number of leaves before constraint pruning?
  1. 4
  2. 12
  3. 81
  4. 24
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

The assignment order is A, B, C, D, E, F. F has no legal value and its conflict set is {A,C}. Where does simple backjumping return?
  1. A
  2. C
  3. D
  4. E
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

Let DU=DV=DW={2,5,8}, with U<V and V<W. What domains remain after AC-3 finishes?
  1. DU={2,5},DV={5},DW={5,8}
  2. DU={2},DV={5},DW={8}
  3. DU={2,5},DV={5,8},DW={2,5,8}
  4. DU={2},DV={2,5},DW={5,8}
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Three distinct access codes satisfy Alldiff⁡(H,J,K), with DH=DJ={2,8} and DK={2,5,8}. What does global propagation force for K?
  1. 5
  2. 2
  3. 8
  4. 2 or 8
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A repair run selects variable T. Its candidate values have local violation counts 1, 3, and 2, while four violated constraints do not involve T. What are the total violation counts of the three resulting states?
  1. 1, 3, 2
  2. 4, 4, 4
  3. 5, 7, 6
  4. 4, 12, 8
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A solver repeatedly moves between two assignments that each violate one constraint. What change directly discourages returning immediately to the assignment just left?
  1. Always choose the same conflicted variable
  2. Allow only moves with the same score
  3. Restart with the same initial assignment
  4. Keep a short tabu list of recent states
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A rooted tree is the path R–S–T–W, with order R, S, T, W and constraints R<S,S<T,T<W. Domains are DR={1,2,3},DS={2,3,4},DT={3,4},DW={4}. What domains remain after the backward pass?
  1. DR={1},DS={2},DT={3},DW={4}
  2. DR={1,2},DS={2,3},DT={3},DW={4}
  3. DR={1},DS={2,3},DT={3,4},DW={4}
  4. DR={1,2,3},DS={2},DT={3},DW={4}
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Bags {A,B,C}, {C,D}, and {A,D} form a path covering cycle A–B–C–D–A. The end bags will stay fixed. What is the smallest change to the middle bag that makes the decomposition valid, and what width results?
  1. Replace C by A; width 2
  2. Add A to the middle bag; width 2
  3. Remove D from the middle bag; width 2
  4. Add a separate end bag {A}; width 2
Show answerHide answer

Save this lesson to see this answer.

Set 3: Combine decisions, inference, and repair10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

Processing takes 16 minutes, followed by checking for 24 minutes, then packing for 10 minutes. All start times are nonnegative integer minutes, idle time is allowed, and packing must finish by minute 80. What are the tight start-time windows in that order?
  1. [0,64], [16,56], [40,70]
  2. [0,30], [16,40], [40,70]
  3. [0,30], [16,46], [40,70]
  4. [0,40], [16,56], [40,80]
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Unassigned variables have DA=DB={1,2} and DC={1,2,3}. The rules are A≠B and A<C. Use MRV, degree for ties, and LCV. What variable and value are chosen?
  1. B = 1
  2. A = 2
  3. C = 3
  4. A = 1
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

The assignment order is L, M, N, P, Q. Q fails with conflict set {L,N} and jumps to N, whose current conflict set is {M}. N then exhausts its values with no new conflict contributors. Where does conflict-directed backjumping return next?
  1. M
  2. L
  3. P
  4. Q
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Let DA=DB=DC={1,2,3}, with A≠B,A≠C,B≠C. Forward checking follows A=1 and then B=2. If B is undone while A stays assigned, what domains must B and C have before trying the next B value?
  1. DB={1,2,3},DC={1,2,3}
  2. DB={2,3},DC={2,3}
  3. DB={2,3},DC={3}
  4. DB={2},DC={2,3}
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A binary CSP has domains DP={1,2}, DQ={1,2}, and DR={2,3} with P≠Q,Q<R,P=R. What happens when AC-3 runs to completion?
  1. It leaves P = 1, Q = 2, R = 3
  2. It finds an empty domain
  3. It leaves every domain unchanged
  4. It leaves P = 2, Q = 1, R = 2
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Two integer quantities satisfy U+V=68, with U∈[0,30] and V∈[0,50]. A new capacity rule lowers V’s maximum to 42. After bounds propagation, what are the tight intervals?
  1. U∈[26,30], V∈[38,42]
  2. U∈[18,30], V∈[38,42]
  3. U∈[26,30], V∈[26,42]
  4. U∈[26,38], V∈[30,42]
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A complete assignment satisfies every old scheduling rule. A new availability constraint creates conflicts. The organizer requires the fewest changed assignments among feasible repairs. What must the repair objective include?
  1. Only the number of violated constraints
  2. A cost for changing each assignment
  3. Only the size of each variable’s domain
  4. A fixed order for selecting variables
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

Constraints a, b, and c have weights 4, 2, and 1. Three candidate moves leave violations {a}, {b,c}, and {c}, respectively. After choosing the lowest-weight result and increasing each still-violated constraint’s weight by 1, what weights result?
  1. 5, 2, 1
  2. 4, 3, 2
  3. 4, 2, 2
  4. 5, 3, 2
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A CSP has 24 binary-valued variables divided into six independent groups of four. How many complete group assignments would separate exhaustive searches examine at most to solve the groups?
  1. 16
  2. 64
  3. 96
  4. 256
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Four binary-valued variables have rules A=B,B≠C,C=D,A≠D. How many complete assignments satisfy all four rules?
  1. 2
  2. 0
  3. 4
  4. 8
Show answerHide answer

Save this lesson to see this answer.

Set 4: Transfer the methods to new constraint patterns10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A graph has edges A–B, B–C, C–A, C–D, D–E, and E–C. Two proposed bags {A,B,C} and {C,D,E} are joined by one edge. With at most five values per variable, is this decomposition valid, and what width and standard bound does it give?
  1. Invalid; C’s two occurrences prevent a tree decomposition
  2. Valid, width 2, with bound O(n53)
  3. Valid, width 2, with bound O(n52)
  4. Valid, width 3, with bound O(n53)
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A roster must cover every required shift and should preferably avoid late duties for one worker. The worker’s preference is the only soft constraint. What makes a roster feasible?
  1. It minimizes late duties alone
  2. It satisfies most hard rules
  3. It has zero preference cost
  4. It satisfies every hard rule
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A 5-queens model uses row variables Q1–Q5, one per column. A learner proposes the candidate (1,3,5,2,4) and says a second constraint requiring one queen per column is still needed. What is the correct assessment?
  1. The candidate is valid; columns are already enforced
  2. The candidate fails; columns 1 and 3 attack
  3. The candidate fails; columns 2 and 5 attack
  4. The candidate is valid; row inequalities enforce columns
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A finite-domain backtracking solver has explored every branch and returned failure. A min-conflicts solver stopped after 2,000 moves without success. What conclusion is justified for each run?
  1. Both runs establish infeasibility because they found no solution
  2. Both runs leave feasibility open because they returned failure
  3. Backtracking establishes infeasibility; local search leaves it open
  4. Local search establishes infeasibility; backtracking leaves it open
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

Unassigned X and Y each have two legal values; Z has three. X has one unassigned neighbor and Y has two. Y’s candidate values remove 3 and 1 values from neighboring domains, respectively. With MRV, degree, and LCV, what is chosen?
  1. X’s first value
  2. Y’s second value
  3. Y’s first value
  4. Z’s second value
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Variables P, Q, and R have domain {1,2} and constraints P≠R,Q≠R. U is independent. A branch with P=1,Q=2,U=1 fails. In a later branch with P=1,U=2, what restriction on Q can be justified by learning from that failure?
  1. Reject Q = 2 while P = 1
  2. Reject Q = 1 while P = 1
  3. Reject Q = 2 in every branch
  4. Allow either Q value after U changes
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Before a decision, unassigned Y and Z have domains {2,6} and must differ. Assigning X removes 6 from both through constraints X–Y and X–Z. What does ordinary forward checking report immediately?
  1. An empty domain because Y and Z must differ
  2. No pruning because Y and Z are unassigned
  3. A solution because all remaining values are fixed
  4. No empty domain yet; Y and Z both retain 2
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

Let DA={1,2,3}, DB={2,3}, and DC={2}, with A<B and B≠C. What are the final AC-3 domains?
  1. DA={1},DB={3},DC={2}
  2. DA={1,2},DB={2,3},DC={2}
  3. DA={1,2},DB={3},DC={2}
  4. DA={1,2,3},DB={3},DC={2}
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Four variables must all differ. Their domains are DJ=DK={1,4}, DL={1,4,7}, and DM={4,7,9}. What does full Alldiff propagation force?
  1. L=1,M=7
  2. L=7,M=9
  3. L=7,M∈{4,9}
  4. L∈{1,7},M=9
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A plan has 6 violations. Its available single-variable moves lead to scores 6, 7, and 8. The score-6 move reaches a state with a score-4 move. What search behavior can reach score 4 without first increasing violations?
  1. Allow a sideways move, then an improving move
  2. Require a strict decrease at every single move
  3. Allow a worse move, then an improving move
  4. Change constraint weights but keep the state fixed
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

73 Key Terms, each with its definition

A

AC-3
AC-3 is a queue-based algorithm that repeatedly revises directed arcs and rechecks neighbors affected by domain reductions.
After X loses values, incoming arcs from its other neighbors are queued because their supports may have disappeared.
Alldiff
Alldiff is a global constraint requiring all variables in its scope to take pairwise different values from their domains.
Three reports assigned through Alldiff cannot give the same reviewer more than one of those reports.
Arc consistency
Arc consistency requires every value at the tail of a directed binary arc to have a compatible value in the head’s domain.
A start time is removed when the successor has no remaining time late enough to satisfy precedence.
Arc revision
An arc revision deletes tail-domain values lacking support in the head’s current domain under the relevant binary relation.
Revising X→Y changes X’s domain; the opposite direction must be checked separately.
Assignment problem
An assignment problem matches entities such as people, jobs, or rooms while enforcing eligibility and resource restrictions.
A report-review model chooses one eligible reviewer for each report and can forbid duplicate reviewer use.

B

Backjumping
Backjumping returns from a failed variable to the latest assigned member of its conflict set, skipping unrelated decisions.
A mainland coloring failure lets the solver skip reconsidering an island with no constraint edges.
Backtracking search
Backtracking search is depth-first search that assigns one variable at a time and undoes choices when their continuations fail.
When no slot works for the last session, the solver returns to an earlier session and tries another slot.
Backward tree pass
A backward tree pass processes children before parents and revises parent-to-child arcs, removing unsupported parent values.
The root is checked against a child only after that child’s possible values reflect its descendants.
Binary constraint
A binary constraint restricts allowed value combinations for two variables, such as their order or whether their values differ.
Two tests sharing a technician need a binary rule that prevents their execution times from overlapping.
Bounds consistency
Bounds consistency requires each endpoint of a variable’s domain to have a satisfying extension for each constraint involving it.
An interval can have supported endpoints even when some of its interior values would fail a constraint.
Bounds propagation
Bounds propagation tightens numeric domain endpoints using constraints, avoiding enumeration of all values in a large interval.
When two buses share a group of passengers, one bus’s maximum capacity forces a lower bound on how many passengers the other bus must carry.

C

Chronological backtracking
Chronological backtracking returns from a dead end to the most recently assigned variable, regardless of the failure’s cause.
In map coloring, a solver may reconsider an independent region’s color before it returns to the choice that caused a conflict.
Commutativity
Commutativity of CSP assignments means that assigning the same variable values in different orders produces the same final state.
Setting A to 1 before B to 3 gives the same complete pair as choosing B’s value before A’s.
Complete search
A complete search finds a solution when one exists and can establish infeasibility by exhausting all necessary finite possibilities.
After every finite-domain branch fails, exhaustive backtracking can report that the schedule is infeasible.
Complete-state formulation
A complete-state formulation keeps every variable assigned throughout local search, while permitting temporary constraint violations.
A repair algorithm begins with a full timetable even when a new availability rule makes two sessions conflict.
Conflict set
A conflict set identifies earlier variables whose assigned values contributed to eliminating a failed variable’s possible choices.
If three neighboring colors exhaust a region’s palette, those earlier neighbors explain its empty domain.
Conflict-directed backjumping
Conflict-directed backjumping merges conflict explanations across failed levels to identify an earlier responsible decision.
A cause discovered below an independent choice can be carried backward until the search reaches a relevant variable.
Conflicted variable
A conflicted variable participates in at least one violated constraint in the current complete assignment used by local search.
Either meeting in a double-booked room is conflicted, even if only one needs to move to fix the clash.
Consistent assignment
A consistent assignment violates no constraint on its assigned values, although it may still have no complete solution extension.
Two colored regions can be compatible even when their choices leave an uncolored region with no available color.
Constraint graph
A constraint graph represents variables as nodes and connects two nodes when their variables share a binary constraint.
In a map-coloring graph, an isolated island node reveals that its color can be chosen independently of the connected mainland regions.
Constraint learning
Constraint learning records logical consequences of search failures as restrictions or cached nogoods to avoid rediscovering them.
A later branch can reject a learned impossible color combination even after unrelated choices have changed.
Constraint optimization problem
A constraint optimization problem seeks a feasible assignment with the best objective value, such as minimum total preference cost.
A roster optimizer can cover every required shift while minimizing the cost of undesirable working times.
Constraint relation
A constraint relation is the set of allowed value combinations for the variables in a constraint’s scope, expressed as tuples or a rule.
The relation for a before-rule can list allowed slot pairs such as (1,2) and (1,3).
Constraint satisfaction problem
A constraint satisfaction problem assigns values to variables from their domains while requiring every constraint to hold.
A timetable CSP chooses a slot for every workshop while enforcing attendance and trainer availability rules.
Constraint scope
A constraint scope is the set of variables whose combined values are restricted by that constraint’s allowed relation.
The rule that session A precedes session B has scope containing A and B, regardless of their domains.
Constraint weighting
Constraint weighting raises the penalties of constraints that remain violated, reshaping the scores used to choose later repairs.
A repeatedly unresolved clash becomes more expensive, directing later moves toward repairing it.
Critical constraint ratio
A critical constraint ratio marks a transition region between mostly solvable and mostly unsolvable instances in many random CSP families.
Instances near this transition often require more search than loosely constrained or clearly infeasible ones.
Cutset conditioning
Cutset conditioning tries cutset assignments, prunes the remaining domains, and solves the resulting tree or forest for each trial.
A failed tree completion makes the solver try another cutset assignment instead of rejecting the whole CSP immediately.
Cycle cutset
A cycle cutset is a set of variables whose removal, with their incident edges, leaves a tree or a forest without cycles.
Removing the shared vertex of two triangles breaks both cycles while preserving two separate edges.

D

Degree heuristic
The degree heuristic favors a variable with more constraints on unassigned variables, commonly to break a tie in domain size.
Two regions have two colors left; the region with more uncolored neighbors wins the degree tie-break.
Directed arc consistency
Directed arc consistency requires each variable to be arc-consistent with every constrained neighbor that appears later in an ordering.
In a parent-before-child tree order, surviving parent values must have support in each child’s domain.
Disjunctive constraint
A disjunctive constraint requires at least one alternative relation to hold, such as either of two possible non-overlap orders.
Two tasks using one machine can run X before Y or Y before X, provided their execution intervals do not overlap.
Domain
A domain is the set of values a variable may take; propagation can remove values that are incompatible with the current restrictions.
A session initially has three possible slots, but its trainer’s arrival removes the earliest one.
Domain wipeout
A domain wipeout occurs when pruning leaves a variable with no available value, establishing failure under the current restrictions.
A session loses its last compatible slot after a neighboring session is assigned, so the branch stops.

F

Factored model
A factored model represents a state through separate variables and values, allowing a solver to inspect constraints between choices.
One queen’s row can change without rebuilding a description of every square on the chessboard.
Fail-first principle
The fail-first principle favors an early decision likely to reveal a dead end, so search avoids building a long doomed continuation.
MRV tests a nearly exhausted session domain early while many other scheduling choices remain unassigned.
Forward checking
Forward checking removes values from unassigned neighbors when they conflict with the newly assigned variable’s selected value.
Assigning slot 2 to a test removes slot 2 from another test that shares the same technician.
Forward tree pass
A forward tree pass chooses a surviving root value and then assigns each child a value compatible with its assigned parent.
Separate child branches can choose their supporting values independently after backward pruning has finished.

G

Global constraint
A global constraint is a named relation defined over a variable-sized group, often with a specialized method for pruning domains.
Alldiff lets a solver recognize that three cells cannot all differ when only two digits remain.

H

Hard constraint
A hard constraint is a mandatory requirement that every feasible assignment must satisfy, regardless of preference costs.
A room-capacity limit remains mandatory even when violating it would make the timetable more convenient.
Higher-order constraint
A higher-order constraint restricts a combination of values involving at least three variables within the same relation.
A rule requiring three task durations to total ten hours links all three duration variables together.

I

Independent component
An independent component is a connected part of a constraint graph with no constraint linking its variables to another component.
Tasmania’s isolated node can be colored after the mainland without checking any additional mainland edge.

J

Job-shop scheduling
Job-shop scheduling assigns task start times while satisfying order requirements and the limits of shared machines or people.
A lab plan must sequence preparation and analysis while keeping two analyses from using one instrument at once.

K

k-consistency
k-consistency requires any consistent assignment to any k − 1 variables to extend consistently to any additional variable.
At level three, a compatible pair must leave a value for each third variable that agrees with both.

L

Least constraining value
Least constraining value tries the candidate value that removes the fewest choices from neighboring unassigned domains.
A room choice that preserves another meeting’s only eligible room is tried before one that takes it away.
Local minimum
A local minimum is an assignment with violations where no single-variable change lowers the chosen conflict score.
A queen board can retain one attack even though every immediate change has an equal or worse score.

M

Maintaining arc consistency
Maintaining arc consistency, or MAC, enforces arc consistency after each decision within backtracking search and restores domains on undo.
A decision’s consequences can travel through several unassigned sessions before the next variable is selected.
Min-conflicts
Min-conflicts repairs a complete assignment by selecting a conflicted variable and giving it a value with the fewest violations.
A queen is moved to a row with the fewest attacks from the other queens, breaking equal-score ties randomly.
Minimum remaining values
Minimum remaining values selects an unassigned variable with the fewest legal values left under the current restrictions.
A session with one remaining slot is chosen before a session that can still use three different slots.

N

Naked pair
A naked pair consists of two variables in one Alldiff scope restricted to the same two values, reserving those values for that pair.
Two row cells limited to 4 and 7 let a Sudoku solver remove both digits from every other cell in that row.
Node consistency
Node consistency means every value remaining in a variable’s domain satisfies all unary constraints on that variable.
After a morning ban is applied, the session’s node-consistent domain contains only midday and afternoon.
Nogood
A nogood is a specific combination of assignments that has no extension satisfying the CSP, so that combination can be forbidden.
Two earlier region colors may jointly force a triangle to use only two colors, making their combination a nogood.

O

Online repair
Online repair starts from an existing assignment and updates it as requirements change, seeking to restore a feasible plan.
When a technician becomes unavailable, the solver can repair the current schedule instead of building a new one.

P

Path consistency
Path consistency requires every consistent assignment to a pair of variables to extend compatibly to any third variable in a binary CSP.
Two different colors on a two-color triangle leave no compatible color for its third region.
Plateau
A plateau is a connected region of assignments with the same local-search score, where strictly improving moves may be unavailable.
Several queen moves may preserve one attack before a different arrangement exposes a move to zero attacks.
Precedence constraint
A precedence constraint requires a task to finish before another begins, relating its start time and duration to the next start.
A 20-minute preparation task starting at minute 5 makes minute 25 the earliest start for analysis.

R

Random restart
A random restart begins local search from a newly chosen complete assignment after the current attempt makes insufficient progress.
After many moves on a plateau, the solver starts from a different full board to explore another region.
Running-intersection property
The running-intersection property requires every bag on a path between two occurrences of a variable to contain that variable too.
If X occurs in both end bags but is absent from the middle bag, the proposed decomposition is invalid.

S

Sideways move
A sideways move changes an assignment while leaving its score unchanged, potentially opening access to a later improvement.
Moving one queen exchanges a diagonal attack for a row attack, then allows another queen to solve the board.
Simulated annealing
Simulated annealing sometimes accepts worse-scoring local-search moves, with the acceptance probability decreasing as temperature falls.
Early worse moves can escape a local minimum; later lower-temperature decisions favor settling into better states.
Soft constraint
A soft constraint expresses a preference whose violation contributes a cost used to compare otherwise feasible assignments.
An afternoon preference can be violated when morning placement is necessary to satisfy every hard rule.
Solution
A solution is an assignment that gives every variable a value from its domain and satisfies every constraint at the same time.
A fully filled Sudoku grid is a solution only when every row, column, box, and given digit agrees.
Strong k-consistency
Strong k-consistency means a CSP satisfies every consistency level from 1 through k, including all the smaller extension requirements.
Strong n-consistency lets a nonempty n-variable CSP be assigned without backtracking in any variable order.
Support
A support is a value in a neighboring domain that satisfies the connecting binary constraint together with a particular tail value.
For X<Y, Y equal to 4 supports X equal to 3, while Y equal to 2 does not.
Symmetry-breaking constraint
A symmetry-breaking constraint keeps representatives of equivalent solutions by restricting choices that differ only through a valid symmetry.
Fixing a color order on a three-region clique removes repeated color-name permutations when the colors are interchangeable.

T

Tabu search
Tabu search temporarily forbids recent states or moves, using short-term memory to discourage repeated cycles in local search.
A solver avoids immediately moving a session back to the slot it just left when that would repeat the same conflict.
Tree decomposition
A tree decomposition arranges overlapping variable bags in a tree while covering all variables and constraints and preserving connected occurrences.
Two bags sharing one variable can coordinate their local solutions by agreeing on that variable’s value.
Tree width
The tree width of a graph is the smallest possible largest-bag size minus one across all valid tree decompositions of that graph.
A decomposition with bags of at most three variables shows that the graph’s tree width is at most two.
Tree-structured CSP
A tree-structured CSP is a binary CSP with an acyclic constraint graph, enabling backward pruning followed by forward assignment.
Once one workshop variable is fixed, the remaining workshop graph forms the path B–A–D–E, which becomes solvable by tree passes.

U

Unary constraint
A unary constraint restricts one variable’s values and can be enforced by deleting disallowed values from its domain.
The rule that a session cannot begin before midday removes morning choices before any search decisions.
Undo trail
An undo trail records domain deletions caused by search decisions so the solver can restore the right values during backtracking.
Undoing a later decision restores its deletions while retaining those required by an earlier assignment.

V

Value symmetry
Value symmetry occurs when renaming interchangeable domain values preserves the original constraints and maps solutions to solutions.
Renaming three map colors produces equivalent colorings when no rule gives one color a special role.
Variable
A variable names a decision whose value must be selected as part of a solution to a constraint satisfaction problem.
In a room-assignment model, each meeting can be a variable whose value names its assigned room.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started