... | @@ -112,7 +112,7 @@ This extension adds three additional constructs: |
... | @@ -112,7 +112,7 @@ This extension adds three additional constructs: |
|
* `top(+Type:type, -Arg:Type)` - gets the last added element of `Type` from the stack, but doesn't remove it from 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
|
|
* `while(pop(+Type:type, -Arg:Type), Query:query)` - new loop that loops while the stack contains value of a type `Type`. It can be used to simulate recursion, there is no guarantee it finishes.
|
|
* `while(pop(+Type:type, -Arg:Type), Query:query)` - new loop that loops while the stack contains value of a type `Type`. It can be used to simulate recursion, there is no guarantee it finishes.
|
|
|
|
|
|
## Semantics
|
|
### Semantics
|
|
|
|
|
|
Motivation: user can define constraint and auxiliary variables semantics in the model. Exploiting semantic part of the model often simplifies the operator.
|
|
Motivation: user can define constraint and auxiliary variables semantics in the model. Exploiting semantic part of the model often simplifies the operator.
|
|
This extension adds additional constructs:
|
|
This extension adds additional constructs:
|
... | @@ -121,19 +121,30 @@ This extension adds additional constructs: |
... | @@ -121,19 +121,30 @@ This extension adds additional constructs: |
|
* `is_satisfied(+Name:name, +Arg1:arg1(Name), +Arg2:arg2(Name))` - succeeds if the constraint named `Name` is satisfied for arguments `Arg1` and `Arg2`
|
|
* `is_satisfied(+Name:name, +Arg1:arg1(Name), +Arg2:arg2(Name))` - succeeds if the constraint named `Name` is satisfied for arguments `Arg1` and `Arg2`
|
|
* `is_violated(+Name:name, +Arg1:arg1(Name), +Arg2:arg2(Name))` - succeeds if the constraint named `Name` is not satisfied for arguments `Arg1` and `Arg2`
|
|
* `is_violated(+Name:name, +Arg1:arg1(Name), +Arg2:arg2(Name))` - succeeds if the constraint named `Name` is not satisfied for arguments `Arg1` and `Arg2`
|
|
|
|
|
|
## Generative semantics
|
|
### Generative semantics
|
|
|
|
|
|
Motivation: the common strategy when implementing a neighborhood operator is to make a move and then fix constraints that got violated by the move.
|
|
Motivation: the common strategy when implementing a neighborhood operator is to make a move and then fix constraints that got violated by the move.
|
|
|
|
|
|
The biggest difference between the **normal** and *generative* semantics is that in the latter case one can query the violated constraints in a generative manner.
|
|
The biggest difference between the **normal** and *generative* semantics is that in the latter case one can query the violated constraints in a generative manner.
|
|
This extension adds additional constructs:
|
|
This extension adds additional constructs:
|
|
|
|
|
|
* all from the weak semantics
|
|
* all from the normal semantics
|
|
* `violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)) is nondet` - finds a violated constraint named `Name` if there is any. Otherwise it fails.
|
|
* `violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)) is nondet` - finds a violated constraint named `Name` if there is any. Otherwise it fails.
|
|
* loop `for_each(violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)), +Query:query)`
|
|
* loop `for_each(violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)), +Query:query)`
|
|
* loop `while(violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)), +Query:query)` - a common patter used in the neighborhood operators.
|
|
* loop `while(violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)), +Query:query)` - a common patter used in the neighborhood operators.
|
|
|
|
|
|
**Warning** using generative semantics adds an overhead to all operations modifying the solution.
|
|
**Warning** using generative semantics adds an overhead to all operations modifying the solution.
|
|
|
|
|
|
|
|
### Custom predicates
|
|
|
|
|
|
|
|
Motivation: it's often desirable to group common query parts into named predicates.
|
|
|
|
This extension allows to define custom (possibly recursive) predicates that can be used later in the query.
|
|
|
|
Every predicate has to have defined name, arity and types of its' arguments, i.e. `predicate/2 : [arg1type, arg2type]`.
|
|
|
|
Using this extension it is possible to replace all control structure (loops, conditional, stacks, memory) with recursion, making it a plain logic program suitable for logical induction approaches.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|