Enhanced with the generated estimated costs, the solving algorithm simply proceeds selecting the most expensive flaw f from the f laws set, selecting its cheapest resolver r and assuming, through the sat_core’s assume() method, the trueness of r’s ρ variable.
v o i d s o l v e ( ) { b u i l d ( ) w h i l e ( t r u e ) { s o l v e _ i n c o n s i s t e n c i e s ( ) f l a w f _ n e x t = s e l e c t _ f l a w ( ) i f ( f _ n e x t ! = n u l l ) { i f ( f _ n e x t . e s t _ c o s t == +∞ ) { n e x t ( ) c o n t i n u e } r e s o l v e r r = f _ n e x t . s e l e c t _ r e s o l v e r ( ) i f ( ! s a t _ c o r e . a s s u m e ( r . ρ ) | | ! s a t _ c o r e . c h e c k ( ) ) throw u n s o l v a b l e _ e x c e p t i o n } e l s e r e t u r n / / a s o l u t i o n h a s b e e n f o u n d ! ! } }
In particular, once built the graph, the procedure enters into the main solving loop. The solve_inconsistencies() procedure solves all the inconsistencies that may arise from the types. The select_ f law procedure purges from the f laws set those flaws which are already solved and returns, if any, the most expensive flaw. If the estimated cost for such a flaw is infinite, the next() procedure either backtracks, if possible, or adds a new layer to the graph. Among the applicable flaw’s resolvers, the cheapest one is chosen by the select_resolver() procedure, it’s ρ variable is assumed as TRUEand the sat_core’s check procedure is called. Finally, in case there are no more flaws, the select_ f law procedure returns a null flaw, indicating that a solution to the timeline- based planning problem has been found.
By applying the above algorithm to the graph of Figure 5.4 the most expensive flaw, i.e., φ7, is selected and its cheapest resolver, i.e., ρ2, is chosen. The TRUEvalue
is assigned to variable ρ2and the sat_core’s check procedure is invoked guaranteeing
constraint consistency. As a consequence of constraint propagation, φ11flaw becomes
active and is added to the f laws set. The select_ f law procedure, again, selects the most expensive flaw which is either φ8or φ11(they are equally evaluated). Suppose, as
an example, that φ8is selected, its cheapest resolver, i.e., ρ10is selected and its variable
is assumed. As a consequence of the unification, the ?x and ?y variables of the atom associated to the φ8flaw, for example, would both assume the value 0 just as the values
of the parameters of the atom associated to fact φ1. Finally, resolver ρ13 would be
selected for the sole remaining active flaw φ11producing, without ever backtracking, a
solution for the original planning problem.
5.3.1
The role of pruning
It is worth noting that after the invoking of the graph building procedure many flaws might have been remained in the f law_q queue which have not yet been expanded. In case of the causal graph of Figure 5.4, for example, φ10, φ12 and φ13 are still in the
queue. Two considerations on such flaws are valid: (i) their estimated cost is necessar- ily +∞ and (ii) it is not known, giving the current graph topology and the computed estimated costs, how to solve them. There is no reason for maintaining the possibility for such flaws to be chosen by the select_ f law procedure and is, hence, possible to as- sume the value of their φ variables as negated. Similar to the one proposed in [111], this kind of pruning is quite efficient since it strongly reduces the size of the search space. In case of Figure 5.4, for example, assigning FALSEto φ12results in the impossibility
of choosing the ρ9 resolver whose ρ9 variable, as a consequence of propagating the
causal constraints, becomes FALSE. However, since the φ8variable assumes the TRUE
value, it is the case that either ρ9or ρ10must assume the TRUEvalue and, hence, since
ρ9is now FALSE, TRUEis assigned to the ρ10variable. Similarly, FALSEis assigned to
both ρ12and ρ8, resulting in the assignment of the TRUEvalue to the ρ7and ρ13vari-
ables resulting in the solution of the original planning problem without ever needing to start the search procedure.
Although this pruning procedure does not allows us to always find solutions di- rectly, it has, nonetheless, the capability of enclosing the planner’s search space within a well-defined bounding box. This allows us, among the other things, to exploit the no-good learning and the non-chronological capabilities of the underlying constraint network as described in Chapter 4. It is worth to notice, indeed, that in case of realistic domains, inconsistencies barely arise and, consequently, the conflict analysis proce- dure is rarely invoked. By enclosing the planner’s search space within precises bounds, conflicts can occur much more easily and a finer analysis can be conducted so as to reduce unfruitful parts of the search.
As already briefly mentioned, a similar pruning is performed in [111] which, how- ever, rather than on pure causality, relies on the plan’s length. Although in case of prefixed durations the pruning is the same, in case of flexible durations it might be hard to foresee the plan’s makespan at heuristic building time resulting in prunings which can be either too strict, requiring a relaxation of the pruning, or too broad, resulting in an excessive search. By intervening on the purely causal aspects while leaving aside temporal reasoning, the proposed approach is more robust on this side.
Unfortunately, it is not always the case that the graph building procedure introduces enough flaws and resolvers for finding a solution and, similar to [111], it might happen that the pruning requires a relaxation. Specifically, it is possible to expand those flaws which remained pending within the f law_q queue. However, since their φ variables assume now the FALSEvalue as a consequence of pruning, expanding the graph might result in a waste of time. Furthermore, all the no-goods learned during the resolution process, might be strictly related to the graph and, hence, to the pruning. A possible
workaround consists in introducing a new propositional variable γ, representing the validity of the graph, and linking the pruning by means of clauses to γ. By assigning TRUEto γ, the pruning would be enforced. In case of failure, however, the generated
no-goods would involve the γ variable assigning FALSEto it (in which case the graph would be recognized as incomplete/invalid and a graph expansion procedure would be called). In case of the rover domain, as an example, the constraint (¬γ, ¬φ12) would
guarantee, after assigning TRUEto γ, the negation of φ12and the smooth execution of
the search algorithm without the risk, among other things, that the heuristic becomes blindby assigning infinite values to the costs of an active flaw.