Skip to content

Instantly share code, notes, and snippets.

@mvdan
Last active August 29, 2015 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mvdan/fe359bfadde791980f4b to your computer and use it in GitHub Desktop.
Save mvdan/fe359bfadde791980f4b to your computer and use it in GitHub Desktop.
#!/bin/sh
# Small script to gather data from picosat and your own SAT solver
# Useful for LI prac 01
#
# Example usage:
# ./li-results.sh > out.txt
# Your solver
BIN=./solver
info() {
echo "$@" >&2
}
write_results() {
local name="$1"
local raw="$2"
satisfiable=$(echo "$raw" | sed -n '/^s /s/s \([^ ]\+\).*/\1/p')
totaltime=$(echo "$raw" | sed -n 's/^c \(.*\) total run time$/\1/p')
numdecisions=$(echo "$raw" | sed -n 's/^c \(.*\) decisions$/\1/p')
propspersec=$(echo "$raw" | sed -n 's/^c \(.*props.*\)$/\1/p')
echo "## $name"
echo "Satisfiability: $satisfiable"
echo "Total time: $totaltime"
echo "Total number of decisions: $numdecisions"
echo "Propagations per second: $propspersec"
echo
}
for f in $(find . -type f -name '*.cnf'); do
echo "$f"
echo "========================"
echo
info "picosat -v < $f"
write_results "Picosat" "$(picosat -v < $f)"
info "$BIN < $f"
write_results "Own SAT solver" "$($BIN < $f)"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment