forked from potassco/eclingo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e337a5
commit 100ae55
Showing
3 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%%%%%%%% arguments %%%%%%%%%%%%%%%%%% | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
% input: input_length(L). | ||
% input: input_toilet(T). | ||
num_packages(L/2) :- input_length(L). | ||
max_length(L-1) :- input_length(L). | ||
toilet(1..T) :- input_toilets(T). | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%%%%%%%% 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,L)) :- package(P), toilet(L). | ||
action(flush(L)) :- toilet(L). | ||
|
||
%%%%%% executable %%%%%%% | ||
executable(dunk(P,L), S) :- action(dunk(P,L)), toilet(L), not holds(clogged(L),S), step(S). | ||
|
||
executable(flush(L), S) :- action(flush(L)), toilet(L), step(S). | ||
|
||
%%%%% direct effects %%%%%%% | ||
-holds(armed(P), T+1) :- occurs(dunk(P,L), T), step(T). | ||
holds(dunked(P), T+1) :- occurs(dunk(P,L), T), step(T). | ||
1{ -holds(clogged, T+1) ; holds(clogged, T+1)}1 :- occurs(dunk(P,L), T), toilet(L), step(T). | ||
|
||
-holds(clogged(L), T+1) :- occurs(flush(L), T), toilet(L), step(T). | ||
|
||
%%%%% indirect effects %%%%%%% | ||
holds(unsafe, T) :- holds(armed(P), T), step(T). | ||
-holds(unsafe, T) :- not holds(unsafe, T), step(T). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%%%%%%%% arguments %%%%%%%%%%%%%%%%%% | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
% input: input_length(L). | ||
% input: input_toilet(T). | ||
num_packages(L/2) :- input_length(L). | ||
max_length(L-1) :- input_length(L). | ||
toilet(1..T) :- input_toilets(T). | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%%%%%%%% 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,L)) :- package(P), toilet(L). | ||
action(flush(L)) :- toilet(L). | ||
|
||
%%%%%% executable %%%%%%% | ||
executable(dunk(P,L), S) :- action(dunk(P,L)), toilet(L), not holds(clogged(L),S), step(S). | ||
|
||
executable(flush(L), S) :- action(flush(L)), toilet(L), step(S). | ||
|
||
%%%%% direct effects %%%%%%% | ||
-holds(armed(P), T+1) :- occurs(dunk(P,L), T), step(T). | ||
holds(dunked(P), T+1) :- occurs(dunk(P,L), T), step(T). | ||
holds(clogged(L), T+1) :- occurs(dunk(P,L), T), toilet(L), step(T). | ||
|
||
-holds(clogged(L), T+1) :- occurs(flush(L), T), toilet(L), step(T). | ||
|
||
%%%%% indirect effects %%%%%%% | ||
holds(unsafe, T) :- holds(armed(P), T), step(T). | ||
-holds(unsafe, T) :- not holds(unsafe, T), step(T). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
import sys | ||
|
||
script_directory = os.path.dirname(os.path.abspath(sys.argv[0])) | ||
instances_directory = os.path.join(script_directory, "instances") | ||
|
||
os.makedirs(instances_directory, exist_ok=True) | ||
|
||
for i in range(10, 160, 10): | ||
print(f"Creating instance {i:04d}") | ||
instance_path = os.path.join(instances_directory, f"bomb_{i:04d}.lp") | ||
with open(instance_path, "w") as f: | ||
f.write(f"input_length({i}).\n") | ||
|
||
instances_directory = os.path.join(script_directory, "instances_many") | ||
|
||
os.makedirs(instances_directory, exist_ok=True) | ||
|
||
for i in range(10, 160, 10): | ||
for t in range(1, 5): | ||
print(f"Creating instance {i:04d}_{t:02d}") | ||
instance_path = os.path.join(instances_directory, f"bomb_{i:04d}_{t:02d}.lp") | ||
with open(instance_path, "w") as f: | ||
f.write(f"input_length({i}).\n") | ||
f.write(f"input_toilets({t}).\n") |