Attachment 'Nomystery-ENCODING.txt'
Download 1 %
2 % Nomystery for ASP 2013.
3 %
4 % Domain specification freely adapted from the plasp PDDL-to-ASP output
5 % (http://potassco.sourceforge.net/labs.html)
6 %
7 % Author (2013) GB Ianni
8 %
9
10 %
11 truck(T) :- fuel(T,_).
12 package(P) :- at(P,L), not truck(P).
13 location(L) :- fuelcost(_,L,_).
14 location(L) :- fuelcost(_,_,L).
15 locatable(O) :- at(O,L).
16 %
17 at(O,L,0) :- at(O,L).
18 fuel(T,F,0) :- fuel(T,F).
19 %
20
21 %
22 % GENERATE >>>>>
23 1 <= { unload( P,T,L,S ) :
24 package( P ) ,
25 truck( T ) ,
26 location( L );
27 load( P,T,L,S ) :
28 package( P ) ,
29 truck( T ) ,
30 location( L );
31 drive( T,L1,L2,S ) :
32 fuelcost( Fueldelta,L1,L2 ) ,
33 truck( T );
34 noop(S)
35 } <= 1 :- step(S), S > 0.
36 % <<<<< GENERATE
37
38 % unload/4, effects
39 at( P,L,S ) :- unload( P,T,L,S ).
40 del( in( P,T ),S ) :- unload( P,T,L,S ).
41
42 % load/4, effects
43 del( at( P,L ),S ) :- load( P,T,L,S ).
44 in( P,T,S ) :- load( P,T,L,S ).
45
46 % drive/4, effects
47 del( at( T,L1 ), S ) :- drive( T,L1,L2,S ).
48 at( T,L2,S ) :- drive( T,L1,L2,S).
49 del( fuel( T,Fuelpre ),S ) :- drive( T,L1,L2,S ), fuel(T, Fuelpre,S-1).
50 fuel( T,Fuelpost,S ) :- drive( T,L1,L2,S ), fuelcost(Fueldelta,L1,L2), fuel(T,Fuelpre,S-1), Fuelpost = Fuelpre - Fueldelta.
51 % <<<<< EFFECTS APPLY
52 %
53 % INERTIA >>>>>
54 at( O,L,S ) :- at( O,L,S-1 ), not del( at( O,L ),S ), step(S).
55 in( P,T,S ) :- in( P,T,S-1 ), not del( in( P,T ),S ), step(S).
56 fuel( T,Level,S ) :- fuel( T,Level,S-1 ), not del( fuel( T,Level) ,S ), truck( T ), step(S).
57 % <<<<< INERTIA
58 %
59
60 %
61 %
62 % PRECONDITIONS CHECK >>>>>
63
64 % unload/4, preconditions
65 :- unload( P,T,L,S ), not preconditions_u( P,T,L,S ).
66 preconditions_u( P,T,L,S ) :- step(S), at( T,L,S-1 ), in( P,T,S-1 ), package( P ), truck( T ).
67
68 % load/4, preconditions
69 :- load( P,T,L,S ), not preconditions_l( P,T,L,S ).
70 preconditions_l( P,T,L,S ) :- step(S), at( T,L,S-1 ), at( P,L,S-1 ).
71
72 % drive/5, preconditions
73 :- drive( T,L1,L2,S ), not preconditions_d( T,L1,L2,S ).
74 preconditions_d( T,L1,L2,S ) :- step(S), at( T,L1,S-1 ), fuel( T, Fuelpre, S-1), fuelcost(Fueldelta,L1,L2), Fuelpre - Fueldelta >= 0.
75 % <<<<< PRECONDITIONS HOLD
76 %
77
78 % GOAL CHECK
79
80 goalreached :- step(S), N = #count{ P,L,S : at(P,L,S) , goal(P,L) }, N = #count{ P,L : goal(P,L) }.
81 :- not goalreached.
82
83 % Gringo directives to show / hide particular literals
84 %#hide.
85 %#show unload/4.
86 %#show load/4.
87 %#show drive/4.
88 %#show at/2.
89 %#show at/3.
Attached Files
You are not allowed to attach a file to this page.