-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathproblemSolver.sh
More file actions
executable file
·57 lines (42 loc) · 1.9 KB
/
problemSolver.sh
File metadata and controls
executable file
·57 lines (42 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# author: Pascal Bercher (pascal.bercher@anu.edu.au)
# improved by Lijia Yuan and Pascal again; both with GPT 4.0
# the program requires two input files: domain first, then problem.
# the timeout has to be set directly in the script.
# Timeout in minutes (here, two)
TIMEOUT_SECONDS=$((2 * 60)) # this could also be made an argument of the script; but most likely it's static anyway.
handle_timeout() {
echo "Timeout reached!"
kill 0 # Kills the current process group
}
trap handle_timeout ALRM
function process_problem() {
# input 1: domain file name
# input 2: problem file name
local domain="$1"
local problem="$2"
# this is added to every generated file to have a unique identifier
# it just uses the two inputs, but you could also use another logic, for
# example use a third argument, in which case UniqueName="${3}"
local unique_name="--${domain}--${problem}" #could be improved by removing .hddl parts
# Parsing
./pandaPIparser "$domain" "$problem" "problem${unique_name}.parsed" > "problem${unique_name}.parsed.log"
if [[ ! -f "problem${unique_name}.parsed" ]]; then
echo "problem${unique_name}.parsed was not generated. Exiting."
return 1
fi
# Grounding
./pandaPIgrounder "problem${unique_name}.parsed" "problem${unique_name}.sas" 2> "problem${unique_name}.stderr.statistics" > "problem${unique_name}.stdout.statistics"
if [[ ! -f "problem${unique_name}.sas" ]]; then
echo "problem${unique_name}.sas was not generated. Exiting."
return 1
fi
# Planner (adapt parameters as required or put them into an additional argument)
./pandaPIengine "problem${unique_name}.sas" -H "rc2(h=add)" -g none > "problem${unique_name}.solution"
}
(
# Run the function in the background
process_problem "$1" "$2"
) &
# Wait for the function or the timeout
sleep "${TIMEOUT_SECONDS}" && kill -ALRM $$