forked from curtisbright/PhysicsCheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-cube-merge-solve-iterative-learnt.sh
executable file
·90 lines (78 loc) · 3 KB
/
3-cube-merge-solve-iterative-learnt.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
while getopts "p" opt
do
case $opt in
p) p="-p" ;;
esac
done
shift $((OPTIND-1))
n=$1 #order
f=$2 #instance file name
d=$3 #directory to store into
v=$4 #num of var to eliminate during first cubing stage
t=$5 #num of conflicts for simplification
a=$6 #amount of additional variables to remove for each cubing call
mkdir -p $d/$v/$n-solve
mkdir -p $d/$v/simp
mkdir -p $d/$v/log
mkdir -p $d/$v/$n-cubes
di="$d/$v"
if [ "$p" == "-p" ]
then
echo "cubing in parallel..."
./gen_cubes/cube.sh -p -a $n $f $v $di
fi
if [ "$p" != "-p" ]
then
echo "cubing sequentially..."
./gen_cubes/cube.sh -a $n $f $v $di
echo "cubing complete"
fi
files=$(ls $d/$v/$n-cubes/*.cubes)
highest_num=$(echo "$files" | awk -F '[./]' '{print $(NF-1)}' | sort -nr | head -n 1)
echo "currently the cubing depth is $highest_num"
cube_file=$d/$v/$n-cubes/$highest_num.cubes
cp $(echo $cube_file) .
cube_file=$(echo $cube_file | sed 's:.*/::')
new_cube=$((highest_num + 1))
numline=$(< $cube_file wc -l)
new_index=$((numline))
for i in $(seq 1 $new_index) #1-based indexing for cubes
do
command1="./gen_cubes/apply.sh $f $cube_file $i > $d/$v/simp/$cube_file$i.adj"
command2="./simplification/simplify-by-conflicts.sh $d/$v/simp/$cube_file$i.adj $n $t >> $d/$v/$n-solve/$i-solve.log"
command3="./maplesat-solve-verify.sh -l $n $d/$v/simp/$cube_file$i.adj.simp $d/$v/$n-solve/$i-solve.exhaust >> $d/$v/$n-solve/$i-solve.log"
command="$command1 && $command2 && $command3"
echo $command >> $d/$v/$n-solve/solve.commands
eval $command1
eval $command2
eval $command3
done
for i in $(seq 1 $new_index)
do
file="$d/$v/$n-solve/$i-solve.log"
if grep -q "UNSATISFIABLE" $file
then
#do something
continue
elif grep -q "SATISFIABLE" $file
then
#do something
continue
else
echo $file is not solved
child_instance="$d/$v/simp/${highest_num}.cubes${i}.adj.simp"
echo "further cube instance $child_instance"
#add learnt clauses
#./gen_cubes/concat.sh $child_instance $child_instance.noncanonical > $child_instance.temp
#./gen_cubes/concat.sh $child_instance.temp $child_instance.unit > $child_instance.temp2
#./gen_cubes/concat.sh $child_instance.temp2 $child_instance.nonembed > $child_instance.learnt
./gen_cubes/concat.sh $child_instance $child_instance.noncanonical |
./gen_cubes/concat.sh - $child_instance.unit |
./gen_cubes/concat.sh - $child_instance.nonembed > $child_instance.learnt
command="./3-cube-merge-solve-iterative-learnt.sh $n $child_instance.learnt "$d/$v-$i" $(($v + $a)) $t $a $(($highest_num+2)) $new_cube_file"
#for parallization, simply submit the command below using sbatch
echo $command >> ${n}-iterative.commands
eval $command
fi
done