-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregression
More file actions
executable file
·103 lines (92 loc) · 4 KB
/
Copy pathregression
File metadata and controls
executable file
·103 lines (92 loc) · 4 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# regression : a narrow, fast regression suite for FrankWolfeSolver.
#
# Covers the main code paths on small MCFBlock instances (static and with
# dynamic arcs): the cross-check against a :MILPSolver for the DQuad/Quad
# father (vanilla / Away-step / BPCG, bounded active set, parallel LMO), the
# two-block bracket check for the Polyhedral father, and the feasible-region
# Modification handling (cost/cap/fix rounds via FWS_mcf_test). Meant to be
# EXPANDED as the solver evolves.
#
# usage: ./regression [ <exe> [ <mcf-exe> ] ]
# ( defaults ./FWS_test ./FWS_mcf_test )
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set -u
EXE=${1:-./FWS_test}
# the MCF-specific tester (feasible-region Modification rounds); if the first
# arg is given (CMake passes the FWS_test binary path), default the mcf exe to
# its sibling FWS_mcf_test in the same directory
MCFEXE=${2:-${EXE%/*}/FWS_mcf_test}
[ "$MCFEXE" = "$EXE" ] && MCFEXE=./FWS_mcf_test
DATA=../../MCFClassSolver/test/data
CFG=FWCfg.txt
# FWCfg.txt is edited in place to vary the algorithm/active-set/threads; save it
# and restore on exit
SAVE=$( cat "$CFG" )
trap '[ -n "$SAVE" ] && printf "%s\n" "$SAVE" > "$CFG"' EXIT
setpar() { sed -i.bak "s/^$1 *[0-9-][0-9]*/$1 $2/" "$CFG" && rm -f "$CFG.bak"; }
algo() { setpar intAlgorithm "$1"; CUR_ALGO=$1; }
atoms() { setpar intMaxAtoms "$1"; CUR_ATOMS=$1; }
threads() { setpar intMaxThread "$1"; CUR_THREADS=$1; }
CUR_ALGO=0 ; CUR_ATOMS=0 ; CUR_THREADS=1
pass=0 ; fail=0
run() { # $1 = description ; rest = tester arguments
local desc=$1 ; shift
# exact command line to reproduce this run; for the FWS_test runs also the
# in-place FWCfg.txt overrides (the mcf runs use FWCfg-warm.txt, not mutated)
printf " [%s %s]\n" "${RUNEXE:-$EXE}" "$*"
[ -z "${RUNEXE:-}" ] && \
printf " [FWCfg.txt: intAlgorithm=%s intMaxAtoms=%s intMaxThread=%s]\n" \
"$CUR_ALGO" "$CUR_ATOMS" "$CUR_THREADS"
local out ; out=$( "${RUNEXE:-$EXE}" "$@" 2>&1 )
if printf "%s" "$out" | grep -q "passed" ; then
pass=$(( pass + 1 )) ; printf " OK %s\n" "$desc"
else
fail=$(( fail + 1 )) ; printf " FAIL %s\n" "$desc"
printf "%s\n" "$out" | tail -3 | sed 's/^/ /'
fi
}
echo "== DQuad / Quad father, cross-check vs :MILPSolver =="
algo 0 ; atoms 0 ; threads 1
for inst in N3-5-0-0-0 N3-5-5-2-2 ; do
for o in 0 1 ; do
run "$inst obj=$o vanilla" -S BSPar.txt -o $o -k 2 -e 1 $DATA/$inst.nc4
done
done
echo "== Away-step (1) and BPCG (2) =="
for a in 1 2 ; do
algo $a
run "N3-5-0-0-0 obj=1 algo=$a" -S BSPar.txt -o 1 -k 3 -e 1 $DATA/N3-5-0-0-0.nc4
done
echo "== bounded active set (aggregation, intMaxAtoms=8) =="
algo 1 ; atoms 8
run "N3-5-0-0-0 obj=1 away maxAtoms=8" -S BSPar.txt -o 1 -k 3 -e 1 $DATA/N3-5-0-0-0.nc4
atoms 0
echo "== parallel LMO (intMaxThread=4) =="
algo 0 ; threads 4
run "N3-5-5-2-2 obj=1 vanilla threads=4" -S BSPar.txt -o 1 -k 3 -e 1 $DATA/N3-5-5-2-2.nc4
threads 1
echo "== Polyhedral father, two-block bracket vs :MILPSolver =="
algo 0
for inst in N3-5-0-0-0 N3-5-5-2-2 ; do
run "$inst poly k=2" -S BSPar-fw.txt -R BSPar-milp.txt -o 2 -k 2 -e 1 $DATA/$inst.nc4
done
echo "== MCF feasible-region Modification (cost/cap/fix), warm eModFine =="
# FWS_mcf_test cross-checks FrankWolfeSolver vs a :MILPSolver while changing arc
# costs (objective), capacities (region) and arc fixing (close/reopen) of a
# sub-Block; exercises feasibility_check / atom-drop / infeasibility propagation
if [ -x "$MCFEXE" ] ; then
RUNEXE=$MCFEXE
for inst in N3-5-0-0-0 N3-5-5-2-2 ; do
for seed in 1 2 ; do
run "$inst mcf-mods seed=$seed" -S BSPar-warm.txt -k 2 -e $seed -M 8 $DATA/$inst.nc4
done
done
unset RUNEXE
else
printf " SKIP MCF Modification rounds (no FWS_mcf_test at %s)\n" "$MCFEXE"
fi
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
printf "REGRESSION: %d passed, %d failed\n" "$pass" "$fail"
[ "$fail" -eq 0 ]