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 are the soft constraints that involve . Let . Suppose are the variables, other than , that are involved in . A value for variable is strictly dominated if, for all values of , some value of 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 that is not assigned in the node to split; there is a neighbor of the node for each value of . Assigning a value to allows the constraints that involve 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 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 and are variables with domain . The constraint
is converted into nonnegative form by subtracting (i.e., adding 4) to each cost, so the costs range from 0 to 10, rather than from 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 is eliminated as follows. Let be the set of constraints that involve . Compute, , a new constraint whose scope is the union of the scopes of the constraints in and whose value is the sum of the values of . Let . For each value of the variables in , select a value of that minimizes , resulting in a new soft constraint, , with scope . The constraint replaces the constraints in . This results in a new problem, with fewer variables and a new set of constraints, which can be solved recursively. A solution, , to the reduced problem is an assignment to the variables in . Thus, , the constraint under the assignment , is a function of . An optimal value for is obtained by choosing a value that results in the minimum value of .
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 and by only constructing an extensional representation of .
Consider Example 4.27. First consider eliminating
. It appears in only one constraint, . Eliminating
: Cost 1 0 2 2 3 2
The constraint is replaced by .
Suppose is eliminated next. appears in three constraints: ,
, and . These three constraints are added, giving
: 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 , , and are replaced by
: Cost 1 1 4 1 2 4 …
There are now three remaining constraints: , , and . These can be optimized recursively.
Suppose the recursive call returns the solution , , . An optimal value for is the value with the minimum in , which is .
From , the value of that minimizes is . Thus, an optimal solution is , , , , , 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.