Intelligence 2E

foundations of computational agents

One way to find the minimal assignment, corresponding to generate and test, is to compute the sum of the soft constraints and to select an assignment with minimum value. This is infeasible for large problems.

Arc consistency can be generalized to optimization problems by allowing pruning of dominated assignments. Suppose ${c}_{1},\mathrm{\dots},{c}_{k}$ are the soft constraints that involve $X$. Let $c={c}_{1}+\mathrm{\dots}+{c}_{k}$. Suppose ${Y}_{1},\mathrm{\dots},{Y}_{m}$ are the variables, other than $X$, that are involved in $c$. A value $v$ for variable $X$ is strictly dominated if, for all values ${y}_{1},\mathrm{\dots},{y}_{k}$ of ${Y}_{1},\mathrm{\dots},{Y}_{m}$, some value ${v}^{\prime}$ of $X$ exists such that $$. Pruning strictly dominated values does not remove a minimal solution. The pruning of domains can be done repeatedly, as in the GAC algorithm.

Weakly dominated has the same definition as strictly dominated, but with “less than” replaced by “less than or equal to.” If only one solution is required, weakly dominated values can be pruned sequentially. Which weakly dominated values are removed may affect which optimal solution is found, but removing a weakly dominated value does not remove all optimal solutions. As with arc consistency for hard constraints, pruning (strictly or weakly) dominated values may greatly simplify the problem but does not, by itself, always solve the problem.

Domain splitting is used to build a search tree. A node is an assignment of a value to a subset of the variables. The neighbors of a node are obtained by selecting a variable $X$ that is not assigned in the node to split; there is a neighbor of the node for each value of $X$. Assigning a value to $X$ allows the constraints that involve $X$ to be simplified and values for other variables to be pruned due to hard constraints or to domination. The arc cost is the evaluation of the soft constraints that are able to be evaluated. A goal node is one where all of the variables are assigned.

By assigning costs as soon as a soft constraint is able to be evaluated, search algorithms such as ${A}^{*}$ or branch-and-bound can be used to find a minimal solution. These methods require each arc cost to be non-negative. To achieve this, the lowest cost in each soft constraint – even if it is negative – is subtracted from each of the costs in the soft constraint. This cost then needs to be added to the cost of a final solution.

Suppose ${X}$ and ${Y}$ are variables with domain ${\mathrm{\{}}{\mathrm{0}}{\mathrm{,}}{\mathrm{1}}{\mathrm{\}}}$. The constraint

${X}$ | ${Y}$ | Cost |
---|---|---|

0 | 0 | ${-}{4}$ |

0 | 1 | ${-}{1}$ |

1 | 0 | 5 |

1 | 1 | 6 |

is converted into nonnegative form by subtracting ${\mathrm{-}}{\mathrm{4}}$ (i.e., adding 4) to each cost, so the costs range from 0 to 10, rather than from ${\mathrm{-}}{\mathrm{4}}$ to 6. The 4 is then subtracted from the cost of the solution.

Variable elimination can also be used for soft constraints. The variables are eliminated one at a time. A variable $X$ is eliminated as follows. Let $R$ be the set of constraints that involve $X$. Compute, $T$, a new constraint whose scope is the union of the scopes of the constraints in $R$ and whose value is the sum of the values of $R$. Let $V=\text{scope}(T)\setminus \{X\}$. For each value of the variables in $V$, select a value of $X$ that minimizes $T$, resulting in a new soft constraint, $N$, with scope $V$. The constraint $N$ replaces the constraints in $R$. This results in a new problem, with fewer variables and a new set of constraints, which can be solved recursively. A solution, $S$, to the reduced problem is an assignment to the variables in $V$. Thus, $T(S)$, the constraint $T$ under the assignment $S$, is a function of $X$. An optimal value for $X$ is obtained by choosing a value that results in the minimum value of $T(S)$.

Figure 4.12 gives pseudocode for the variable elimination with soft constraints (VE_SC) algorithm. The elimination ordering can be given a priori or may be computed on the fly, for example, using the elimination ordering heuristics discussed for VE_CSP. It is possible to implement VE_SC without storing $T$ and by only constructing an extensional representation of $N$.

Consider Example 4.27. First consider eliminating
${A}$. It appears in only one constraint, ${{c}}_{{\mathrm{1}}}{\mathit{}}{\mathrm{(}}{A}{\mathrm{,}}{B}{\mathrm{)}}$. Eliminating ${A}$
gives

${{c}}_{{6}}{}{(}{B}{)}{=}{\mathrm{arg}}{}{{\mathrm{min}}}_{{A}}{}{{c}}_{{1}}{}{(}{A}{,}{B}{)}$: ${B}$ Cost 1 0 2 2 3 2

The constraint ${{c}}_{{\mathrm{1}}}{\mathit{}}{\mathrm{(}}{A}{\mathrm{,}}{B}{\mathrm{)}}$ is replaced by ${{c}}_{{\mathrm{6}}}{\mathit{}}{\mathrm{(}}{B}{\mathrm{)}}$.

Suppose ${B}$ is eliminated next. ${B}$ appears in three constraints: ${{c}}_{{\mathrm{2}}}{\mathit{}}{\mathrm{(}}{B}{\mathrm{,}}{C}{\mathrm{)}}$,
${{c}}_{{\mathrm{3}}}{\mathit{}}{\mathrm{(}}{B}{\mathrm{,}}{D}{\mathrm{)}}$, and ${{c}}_{{\mathrm{6}}}{\mathit{}}{\mathrm{(}}{B}{\mathrm{)}}$. These three constraints are added, giving

${{c}}_{{\mathrm{2}}}{\mathit{}}{\mathrm{(}}{B}{\mathrm{,}}{C}{\mathrm{)}}{\mathrm{+}}{{c}}_{{\mathrm{3}}}{\mathit{}}{\mathrm{(}}{B}{\mathrm{,}}{D}{\mathrm{)}}{\mathrm{+}}{{c}}_{{\mathrm{6}}}{\mathit{}}{\mathrm{(}}{B}{\mathrm{)}}$:
${B}$
${C}$
${D}$
Cost
1
1
1
8
1
1
2
5
…
2
1
1
4
2
1
2
4
…
3
1
1
6
3
1
2
8

The constraints ${{c}}_{{\mathrm{2}}}$, ${{c}}_{{\mathrm{3}}}$, and ${{c}}_{{\mathrm{6}}}$ are replaced by

${{c}}_{{7}}{}{(}{C}{,}{D}{)}{=}{{\mathrm{min}}}_{{B}}{}{\left(}{{c}}_{{2}}{}{(}{B}{,}{C}{)}{+}{{c}}_{{3}}{}{(}{B}{,}{D}{)}{+}{{c}}_{{6}}{}{(}{B}{)}{\right)}$: ${C}$ ${D}$ Cost 1 1 4 1 2 4 …

There are now three remaining constraints: ${{c}}_{{\mathrm{4}}}{\mathit{}}{\mathrm{(}}{C}{\mathrm{,}}{E}{\mathrm{)}}$, ${{C}}_{{\mathrm{5}}}{\mathit{}}{\mathrm{(}}{D}{\mathrm{,}}{E}{\mathrm{)}}$, and ${{c}}_{{\mathrm{7}}}{\mathit{}}{\mathrm{(}}{C}{\mathrm{,}}{D}{\mathrm{)}}$. These can be optimized recursively.

Suppose the recursive call returns the solution ${C}{\mathrm{=}}{\mathrm{1}}$, ${D}{\mathrm{=}}{\mathrm{2}}$, ${E}{\mathrm{=}}{\mathrm{2}}$. An optimal value for ${B}$ is the value with the minimum in ${{c}}_{{\mathrm{2}}}{\mathrm{(}}{B}{\mathrm{,}}{C}{\mathrm{=}}{\mathrm{1}}{\mathrm{)}}{\mathrm{+}}{{c}}_{{\mathrm{3}}}{\mathrm{(}}{B}{\mathrm{,}}{D}{\mathrm{=}}{\mathrm{2}}{\mathrm{)}}{\mathrm{+}}{{c}}_{{\mathrm{6}}}{\mathrm{(}}{B}{\mathrm{)}}$, which is ${B}{\mathrm{=}}{\mathrm{2}}$.

From ${{c}}_{{\mathrm{1}}}{\mathit{}}{\mathrm{(}}{A}{\mathrm{,}}{B}{\mathrm{)}}$, the value of ${A}$ that minimizes ${{c}}_{{\mathrm{1}}}{\mathrm{(}}{A}{\mathrm{,}}{B}{\mathrm{=}}{\mathrm{2}}{\mathrm{)}}$ is ${A}{\mathrm{=}}{\mathrm{1}}$. Thus, an optimal solution is ${A}{\mathrm{=}}{\mathrm{1}}$, ${B}{\mathrm{=}}{\mathrm{2}}$, ${C}{\mathrm{=}}{\mathrm{1}}$, ${D}{\mathrm{=}}{\mathrm{2}}$, ${E}{\mathrm{=}}{\mathrm{2}}$, with a cost of 4.

The complexity of VE_SC depends on the structure of the constraint graph, as it does with hard constraints. Sparse graphs may result in small intermediate constraints in VE algorithms, including VE_SC. Densely connected graphs result in large intermediate constraints.