#!/bin/bash # Phase 3 for IIS-Q-0003: two third-party solvers on the union-of-masks tables, with the binary # of run_all.sh. The solvers are z3 and HiGHS (scipy.optimize.milp). For each puncture set and # each budget of its kind, q3_third.py makes two tests of feasibility: the table value must be # attainable, and the next value must be impossible. A time limit is "no decision". It is not a # disagreement. The processes of z3 run first. Then the processes of HiGHS run. # PY3 must be a Python 3 that has the module z3. The HiGHS part also needs numpy and scipy in # the directory PYLIBS. To make that directory: # python3 -m pip install --no-cache-dir --target PYLIBS numpy scipy # usage (from the root of the workspace): # /bin/bash -c '. work/lean_env.sh && bash work/capset/q0003/run_third.sh [TIMEOUT]' # TIMEOUT is the limit of one call of a solver, in seconds. The default is 20. W=$(cd "$(dirname "$0")/../../.." && pwd) # the root of the workspace; this script is in work/capset/q0003 D=$W/work/capset/q0003 Q=$D/q3_check L=$D/logs PY3=/opt/homebrew/bin/python3 PYLIBS=$D/pylibs T=${1:-20} SEED=20261128 # kind : number of puncture sets : budgets KINDS="intact:1:32,35,36,39,40,43 dual:1:32,33,36,37,38,39,40,42,43 p1w:3:36,37,38,39,40,41,42 p1s:3:36,38,39,41,42 p2:3:34,35,36,37,38 p3:3:32,33,34,35,36" mkdir -p "$L" run() { # name, command... local name=$1; shift { echo "start $(date -u +%Y-%m-%dT%H:%M:%SZ)"; /usr/bin/time -p "$@"; echo "exit $?"; echo "end $(date -u +%Y-%m-%dT%H:%M:%SZ)"; } > "$L/$name.log" 2>&1 } { echo "start $(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "source sha256 $(shasum -a 256 "$D/q3_check.c" | cut -d' ' -f1)" echo "binary sha256 $(shasum -a 256 "$Q" | cut -d' ' -f1)" echo "script sha256 $(shasum -a 256 "$D/q3_third.py" | cut -d' ' -f1)" echo "time limit of one call $T s" } > "$L/q3_third_run.log" 2>&1 for SOLVER in z3 highs; do if [ "$SOLVER" = highs ] && [ ! -d "$PYLIBS/scipy" ]; then echo "HiGHS is not run: the directory $PYLIBS has no scipy" >> "$L/q3_third_run.log" continue fi for LAYER in 0 1; do for ITEM in $KINDS; do KIND=${ITEM%%:*} REST=${ITEM#*:} NS=${REST%%:*} BUDGETS=${REST#*:} if [ "$SOLVER" = z3 ]; then LIBS=-; else LIBS=$PYLIBS; fi run "q3_third_${SOLVER}_L${LAYER}_${KIND}" "$PY3" -I "$D/q3_third.py" "$Q" "$L" "$LAYER" "$SOLVER" "$SEED" "$NS" "$T" "$LIBS" "$KIND" "$BUDGETS" & done done wait echo "solver $SOLVER complete $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$L/q3_third_run.log" done python3 -I "$D/q3_third_collect.py" "$L" > "$L/q3_third_collected.log" 2>&1 { echo "collect exit $?"; echo "end $(date -u +%Y-%m-%dT%H:%M:%SZ)"; } >> "$L/q3_third_run.log"