4.3 Search.object

## 4.3 `Search.object`

The object `Search.object` implements a demand driven search engine which supports recomputation, single, all, and best solution search and different kinds of output in the same way as the search engines in the previous section.

`script`

  > > `script(``+ScriptP``
  > > ` `+OrderP``<= _
  > > rcd:``+RcdI``<= 1)`

  Initializes the object for the script `+Script` (a unary procedure). If the optional argument `+OrderP` (a binary procedure) is given, the object uses a branch and bound strategy for best solution search.

  `+RcdI` is the recomputation distance (see Section 4.2).

`next`

  > `next(``?Xs``)`

`nextS`

  > `nextS(``?Spaces``)`

`nextP`

  > `nextP(``?Ps``)`

  returns a singleton list which contains the next solution. If no further solution exists, `nil` is returned. If the search is stopped by a message `stop`, `stopped` is returned.

  The object releases its state immediately.

`last`

  > `last(``?Xs``)`

`lastS`

  > `lastS(``?Spaces``)`

`lastP`

  > `lastP(``?Ps``)`

  returns a singleton list which contains the last solution. If no further solution exists, `nil` is returned. If the search is stopped by a message `stop`, `stopped` is returned.

  The object releases its state immediately. If the object has been initialized for best solution search, the last solution is the best solution.

`stop`

  > > `stop`

  stops the search engine. The search engine can be restarted by `next`, `nextS`, `nextP`, `last`, `lastS`, and `lastP`.