Added introductory example to output format documentation.
This commit is contained in:
parent
c391a1f566
commit
197cec923e
@ -2,7 +2,49 @@
|
|||||||
|
|
||||||
`plasp` 3 translates SAS and PDDL files into the same ASP fact format.
|
`plasp` 3 translates SAS and PDDL files into the same ASP fact format.
|
||||||
|
|
||||||
`plasp` structures the translated ASP facts into the multiple sections, which are explained in the following.
|
## In a Nutshell
|
||||||
|
|
||||||
|
The following illustrates `plasp`’s output format for the problem of turning switches on and off.
|
||||||
|
|
||||||
|
```prolog
|
||||||
|
% declares the type "type(switch)"
|
||||||
|
type(type(switch)).
|
||||||
|
|
||||||
|
% introduces a switch "constant(a)"
|
||||||
|
constant(constant(a)).
|
||||||
|
has(constant(a), type(switch)).
|
||||||
|
|
||||||
|
% introduces another switch "constant(a)"
|
||||||
|
constant(constant(b)).
|
||||||
|
has(constant(b), type(switch)).
|
||||||
|
|
||||||
|
% declares a variable "variable(on(X))" for each switch X
|
||||||
|
variable(variable(on(X))) :- has(X, type(switch)).
|
||||||
|
|
||||||
|
% the variable may be true or false
|
||||||
|
contains(variable(on(X)), value(on(X)), true)) :- has(X, type(switch)).
|
||||||
|
contains(variable(on(X)), value(on(X)), false)) :- has(X, type(switch)).
|
||||||
|
|
||||||
|
% declares the action "action(turnOn(X))", which requires switch X to be off and then turns it on
|
||||||
|
action(action(turnOn(X))) :- has(X, type(switch)).
|
||||||
|
precondition(action(turnOn(X)), variable(on(X)), value(on(X), false)) :- has(X, type(switch)).
|
||||||
|
postcondition(action(turnOn(X)), effect(0), variable(on(X)), value(on(X), true)) :- has(X, type(switch)).
|
||||||
|
|
||||||
|
% declares the action "action(turnOff(X))", which requires switch X to be on and then turns it off
|
||||||
|
action(action(turnOff(X))) :- has(X, type(switch)).
|
||||||
|
precondition(action(turnOff(X)), variable(on(X)), value(on(X), true)) :- has(X, type(switch)).
|
||||||
|
postcondition(action(turnOff(X)), effect(0), variable(on(X)), value(on(X), false)) :- has(X, type(switch)).
|
||||||
|
|
||||||
|
% initially, switch a is off and switch b is on
|
||||||
|
initialState(variable(on(constant(a))), value(on(constant(a)), false)).
|
||||||
|
initialState(variable(on(constant(b))), value(on(constant(b)), true)).
|
||||||
|
|
||||||
|
% in the end, switch a should be on and switch b should be off
|
||||||
|
goal(variable(on(constant(a))), value(on(constant(a)), true)).
|
||||||
|
goal(variable(on(constant(b))), value(on(constant(b)), false)).
|
||||||
|
```
|
||||||
|
|
||||||
|
When translating SAS or PDDL problems, `plasp` structures the translated ASP facts into multiple sections, which are explained in the following.
|
||||||
|
|
||||||
## Feature Requirements
|
## Feature Requirements
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user