Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefandinno committed Oct 6, 2023
1 parent 758af69 commit 0e337a5
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 88 deletions.
43 changes: 43 additions & 0 deletions bomb_problems/bt.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% arguments %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% input: input_length(L).
max_length(L) :- input_length(L).
num_packages(L) :- input_length(L).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% initial states %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

package(1..NP) :- num_packages(NP).

{ holds(armed(P),0) } :- package(P).
:- not 1 { holds(armed(P),0) : package(P) } 1.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% problem description %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%% fluents %%%%%%%%%%%%%%%%%%

fluent(armed(P)) :- package(P).
inertial(armed(P)) :- package(P).
fluent(dunked(P)) :- package(P).
inertial(dunked(P)) :- package(P).

fluent(unsafe).

%%%%%%% actions %%%%%%%%
action(dunk(P)) :- package(P).

%%%%%% executable %%%%%%%
executable(dunk(P), T) :- action(dunk(P)), step(T), not holds(dunked(P),T).

%%%%% direct effects %%%%%%%
-holds(armed(P), T+1) :- occurs(dunk(P), T), step(T).
holds(dunked(P), T+1) :- occurs(dunk(P), T), step(T).

%%%%% indirect effects %%%%%%%
holds(unsafe, T) :- holds(armed(P), T), step(T).
-holds(unsafe, T) :- not holds(unsafe, T), step(T).
28 changes: 28 additions & 0 deletions bomb_problems/bt_base.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% arguments %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% input: input_length(L).
% input: num_packages(NPL).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% problem description %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

step(0..L) :- max_length(L).
stepless(0..L-1) :- max_length(L).

%%%%% occurs %%%%%%%
occurs(A,S) :- action(A), stepless(S), not &k{ ~ occurs(A,S) }.
bot :- occurs(A,S), not executable(A,S).
:- { occurs(A,S) } > 1, stepless(S).

%%%%% goal %%%%%%%
goal :- -holds(unsafe, LEN), not bot, max_length(LEN).

:- not &k{ goal }.

%%%%% defaults and inertia %%%%%%%
-holds(F,0) :- not holds(F,0), fluent(F).
holds(F,S+1) :- fluent(F), inertial(F), stepless(S), holds(F,S), not -holds(F,S+1).
-holds(F,S+1) :- fluent(F), inertial(F), stepless(S), -holds(F,S), not holds(F,S+1).
62 changes: 0 additions & 62 deletions bomb_problems/bt_conf.lp

This file was deleted.

43 changes: 17 additions & 26 deletions bomb_problems/btc_conf.lp → bomb_problems/btc.lp
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%initial states%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% arguments %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% #program initial.
% #external _heuristic.
package(1..np).
% input: input_length(L).
num_packages(L/2) :- input_length(L).
max_length(L-1) :- input_length(L).

1 { holds(armed(P),0) : package(P) } 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% initial states %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%problem description%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% #program problem.
package(1..NP) :- num_packages(NP).

step(0..length).
max(length).
stepless(0..L-1) :- max(L).
{ holds(armed(P),0) } :- package(P).
:- not 1 { holds(armed(P),0) : package(P) } 1.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% problem description %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%% fluents %%%%%%%%%
%%%%%%% fluents %%%%%%%%%%%%%%%%%%

fluent(armed(P)) :- package(P).
inertial(armed(P)) :- package(P).
Expand All @@ -43,20 +44,10 @@ executable(flush,T) :- action(flush), step(T).
%%%%% direct effects %%%%%%%
-holds(armed(P), T+1) :- occurs(dunk(P), T), step(T).
holds(dunked(P), T+1) :- occurs(dunk(P), T), step(T).
holds(clogged, T+1) :- occurs(dunk(P), T), step(T).

-holds(clogged, T+1) :- occurs(flush, T), step(T).

%%%%% indirect effects %%%%%%%
holds(unsafe, T) :- holds(armed(P), T), step(T).
-holds(unsafe, T) :- not holds(unsafe, T), step(T).


%%%%% occurs %%%%%%%
occurs(A,S) :- action(A), stepless(S), not &k{ ~ occurs(A,S) }.
bot :- occurs(A,S), not executable(A,S).
:- occurs(A1,S), occurs(A2,S), A1 < A2, stepless(S).

%%%%% goal %%%%%%%
goal :- -holds(unsafe, LEN), not bot, max(LEN).

:- not &k{ goal }.
53 changes: 53 additions & 0 deletions bomb_problems/btuc.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% arguments %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% input: input_length(L).
num_packages(L/2) :- input_length(L).
max_length(L-1) :- input_length(L).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% initial states %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

package(1..NP) :- num_packages(NP).

{ holds(armed(P),0) } :- package(P).
:- not 1 { holds(armed(P),0) : package(P) } 1.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% problem description %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%% fluents %%%%%%%%%%%%%%%%%%

fluent(armed(P)) :- package(P).
inertial(armed(P)) :- package(P).

fluent(dunked(P)) :- package(P).
inertial(dunked(P)) :- package(P).

fluent(clogged).
inertial(clogged).

fluent(unsafe).

%%%%%%% actions %%%%%%%%
action(dunk(P)) :- package(P).
action(flush).

%%%%%% executable %%%%%%%
executable(dunk(P), T) :- action(dunk(P)), -holds(clogged,T), step(T), not holds(dunked(P),T).

executable(flush,T) :- action(flush), step(T).

%%%%% direct effects %%%%%%%
-holds(armed(P), T+1) :- occurs(dunk(P), T), step(T).
holds(dunked(P), T+1) :- occurs(dunk(P), T), step(T).
1{ -holds(clogged, T+1) ; holds(clogged, T+1)}1 :- occurs(dunk(P), T), step(T).

-holds(clogged, T+1) :- occurs(flush, T), step(T).

%%%%% indirect effects %%%%%%%
holds(unsafe, T) :- holds(armed(P), T), step(T).
-holds(unsafe, T) :- not holds(unsafe, T), step(T).

0 comments on commit 0e337a5

Please sign in to comment.