... | ... | @@ -87,6 +87,7 @@ There are several extensions to the NDL query, that can be used in order to incr |
|
|
|
|
|
### Stochastic mode
|
|
|
|
|
|
Motivation: many meta-heuristics sample only a random subset of neighbohood.
|
|
|
NDL Queries can be compiled as stochastic operator. The stochastic mode impacts ordering of the `variable/(2..6)`, `constraint/3`, `range_element/2` results, effectively returning them in a random fashion. It does **not** impact `for_each` generator.
|
|
|
|
|
|
**Warning:** stochastic ndl query always backtracks.
|
... | ... | @@ -99,4 +100,15 @@ Motivation: often one would like to mark a variable as already moved, so the que |
|
|
* `in_memory(+Arg)` - checks if the argument has ben remembered
|
|
|
* `\+ in_memory(+Arg)` - succeeds if the argument hasn't been remembered
|
|
|
|
|
|
### Stack
|
|
|
|
|
|
Motivation: stack is a useful data structure, allowing to simulate primitive recursion.
|
|
|
Comparing to the **Memory** extension, stacks are ordered (LIFO) and can be queried.
|
|
|
This extension adds three additional constructs:
|
|
|
|
|
|
* `push(+Type:type, +Arg:Type)` - pushes value of `Type` on the stack
|
|
|
* 'pop(+Type:type, -Arg:Type)` - pops value of `Type` from the stack, fails if there is no value of this type on the stack
|
|
|
* `top(+Type:type, -Arg:Type)` - gets the last added element of `Type` from the stack, but doesn't remove it from the stack
|
|
|
* new loop `while(pop(+Type:type, -Arg:Type), Query:query)` - that loops while the stack contains value of a type `Type`
|
|
|
|
|
|
|