Skip to content

Instantly share code, notes, and snippets.

@setzer22
Forked from mvdan/li-results.sh
Last active August 29, 2015 14:15
Show Gist options
  • Save setzer22/d7d50a392d6bc2e716ad to your computer and use it in GitHub Desktop.
Save setzer22/d7d50a392d6bc2e716ad to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage: li-results-parallel.sh instances_path > out.txt
# Number of threads to use
N_THREADS=8
INSTANCES_PATH=$1
ls $INSTANCES_PATH/*.cnf | xargs -n 1 -P $N_THREADS sh li-results-single.sh
#!/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="picosat -v"
# File to process
f=$1
info() {
echo "$@" >&2
}
write_results() {
local name="$1"
local raw="$2"
#info "$name -v < $f" I deactivated stderr output so it doesn't get messed up in the terminal
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')
local output="## $name\nSatisfiability: $satisfiable\nTotal time: $totaltime\nTotal number of decisions: $numdecisions\nPropagations per second: $propspersec"
echo $output
}
output="\n$f\n=====================\n"$(write_results "Picosat" "$(picosat -v < $f)")"\n"$(write_results "Own SAT solver" "$($BIN < $f)")
echo $output | sed 's/\\n/\n/g'
#!/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