Skip to content

Commit fc128a1

Browse files
committed
Merge branch 'master' of https://github.com/hexhex/core
2 parents 415415d + 4a424ff commit fc128a1

15 files changed

Lines changed: 225 additions & 20 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
% define colors
2+
color(red).
3+
color(green).
4+
color(blue).
5+
6+
% graph is undirected
7+
edge(Y, X) :- edge(X, Y).
8+
9+
% extract nodes
10+
node(X) :- edge(X, Y).
11+
node(Y) :- edge(X, Y).
12+
13+
% guess all colorings
14+
coloring(N, C) : color(C) :- node(N).
15+
16+
:- coloring(N, C), coloring(M, C), edge(N, M).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invalid :- input(coloring, X, C), input(coloring, Y, C), input(edge, X, Y).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
isInvalid :- input(coloring, X, C), input(coloring, Y, C), input(edge, X, Y).
2+
isComplete(C1, C2) :- input(color, C1, C2), input(edge, X, Y), input(coloring, X, C1), input(coloring, Y, C2).
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
node(X) :- edge(X, Y).
2+
node(Y) :- edge(X, Y).
3+
4+
% define colors
5+
color(red).
6+
color(green).
7+
color(blue).
8+
9+
% graph is undirected
10+
edge(Y, X) :- edge(X, Y).
11+
12+
% guess all colorings
13+
coloring(N, C) : color(C) :- node(N).
14+
15+
% prepare input to external atom
16+
input(coloring, N, C) :- coloring(N, C).
17+
input(edge, X, Y) :- edge(X, Y).
18+
19+
% check if the guessed coloring is invalid
20+
sat :- &testCautiousQuery["checkInvalidColoring.hex", input, invalid]().
21+
22+
% if yes, then saturate
23+
coloring(N, C) :- sat, node(N), color(C).
24+
25+
% test if all guesses are invalid
26+
:- not sat.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
node(X) :- edge(X, Y).
2+
node(Y) :- edge(X, Y).
3+
4+
% define colors
5+
color(red).
6+
color(green).
7+
color(blue).
8+
9+
% graph is undirected
10+
edge(Y, X) :- edge(X, Y).
11+
12+
% guess all colorings
13+
coloring(N, C) : color(C) :- node(N).
14+
15+
% prepare input to external atom
16+
input(coloring, N, C) :- coloring(N, C).
17+
input(edge, X, Y) :- edge(X, Y).
18+
19+
% check if the guessed coloring is invalid
20+
sat :- coloring(X, C), coloring(Y, C), edge(X, Y).
21+
22+
% if yes, then saturate
23+
coloring(N, C) :- sat, node(N), color(C).
24+
25+
% test if all guesses are invalid
26+
:- not sat.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
node(X) :- edge(X, Y).
2+
node(Y) :- edge(X, Y).
3+
4+
% define colors
5+
color(red).
6+
color(green).
7+
color(blue).
8+
9+
% graph is undirected
10+
edge(Y, X) :- edge(X, Y).
11+
12+
% guess all colorings
13+
coloring(N, C) : color(C) :- node(N).
14+
15+
% prepare input to external atom
16+
input(coloring, N, C) :- coloring(N, C).
17+
input(edge, X, Y) :- edge(X, Y).
18+
input(color, C1, C2) :- color(C1), color(C2), C1 != C2.
19+
20+
% check if the guessed complete coloring is invalid
21+
sat :- &testCautiousQuery["checkInvalidCompleteColoring.hex", input, isInvalid]().
22+
sat :- color(C1), color(C2), C1 != C2, not &testCautiousQuery["checkInvalidCompleteColoring.hex", input, isComplete](C1, C2).
23+
24+
% if yes, then saturate
25+
coloring(N, C) :- sat, node(N), color(C).
26+
27+
% test if all guesses are invalid
28+
:- not sat.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
node(X) :- edge(X, Y).
2+
node(Y) :- edge(X, Y).
3+
4+
% define colors
5+
color(red).
6+
color(green).
7+
color(blue).
8+
9+
% graph is undirected
10+
edge(Y, X) :- edge(X, Y).
11+
12+
% guess all colorings
13+
coloring(N, C) : color(C) :- node(N).
14+
15+
% prepare input to external atom
16+
input(coloring, N, C) :- coloring(N, C).
17+
input(edge, X, Y) :- edge(X, Y).
18+
19+
% check if the guessed complete coloring is invalid
20+
sat :- coloring(X, C), coloring(Y, C), edge(X, Y).
21+
pairOk(C1, C2) :- color(C1), color(C2), C1 != C2, coloring(X, C1), coloring(Y, C2), edge(X, Y).
22+
sat :- color(C1), color(C2), C1 != C2, not pairOk(C1, C2).
23+
24+
% if yes, then saturate
25+
coloring(N, C) :- sat, node(N), color(C).
26+
27+
% test if all guesses are invalid
28+
:- not sat.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# $1: node count
2+
# $2: edge propability
3+
# $3: probability that for an edge (a,b) also edge (b,a) is added
4+
5+
echo "#maxint=$1."
6+
7+
prop=$((32768 * $2 / 100))
8+
backprop=$((32768 * $3 / 100))
9+
for (( i=1; i <= $1; i++ ))
10+
do
11+
for (( j = 1; j <= $1; j++ ))
12+
do
13+
if [ $RANDOM -le $prop ]; then
14+
echo "edge($i,$j)."
15+
if [ $RANDOM -le $backprop ]; then
16+
echo "edge($j,$i)."
17+
fi
18+
fi
19+
done
20+
done
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
for (( nodecount=$1; nodecount <= $2; nodecount+=$3 ))
2+
do
3+
for (( edgeprop=$4; edgeprop <= $5; edgeprop+=$6 ))
4+
do
5+
for (( backedgeprop=$7; backedgeprop <= $8; backedgeprop+=$9 ))
6+
do
7+
for (( inst=0; inst < ${10}; inst++ ))
8+
do
9+
ep=`printf "%03d" ${edgeprop}`
10+
bep=`printf "%03d" ${backedgeprop}`
11+
ac=`printf "%03d" ${nodecount}`
12+
in=`printf "%03d" ${inst}`
13+
./generate.sh $nodecount $edgeprop $backedgeprop > "instances/graphinst_nodecount_${ac}_edgeprob_${ep}_backedgeprob_${bep}_inst_${in}.graph"
14+
done
15+
done
16+
done
17+
done

benchmarks/non3col-inlining/run.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
runheader=$(which run_header.sh)
4+
if [[ $runheader == "" ]] || [ $(cat $runheader | grep "run_header.sh Version 1." | wc -l) == 0 ]; then
5+
echo "Could not find run_header.sh (version 1.x); make sure that the benchmark scripts directory is in your PATH"
6+
exit 1
7+
fi
8+
source $runheader
9+
10+
# run instances
11+
if [[ $all -eq 1 ]]; then
12+
# run all instances using the benchmark script run insts
13+
$bmscripts/runinsts.sh "instances/*.graph" "$mydir/run.sh" "$mydir" "$to" "" "" "$req"
14+
else
15+
# run single instance
16+
confstr="checkNon3Colorability.hex;checkNon3Colorability.hex --supportsets;checkNon3Colorability.hex --extinlining;checkNon3ColorabilityPlain.hex;checkNon3CompleteColorability.hex;checkNon3CompleteColorability.hex --supportsets;checkNon3CompleteColorability.hex --extinlining;checkNon3CompleteColorabilityPlain.hex"
17+
18+
$bmscripts/runconfigs.sh "dlvhex2 --plugindir=../../testsuite --verbose=8 CONF INST" "$confstr" "$instance" "$to"
19+
fi
20+

0 commit comments

Comments
 (0)