Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hvapprox/1p16d.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
3.06...e-05
Monte Carlo estimate within tolerance
3.05...e-05
3.03...e-05
4 changes: 3 additions & 1 deletion hvapprox/1p16d.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
${PROGRAM} -r "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" --method=1 --nsamples 100000 --seed=42 < ./${TESTNAME}.inp
set -o pipefail
# The exact hypervolume is 0.5^15; allow for Monte Carlo sampling error.
${PROGRAM} -r "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" --method=1 --nsamples 100000 --seed=42 < ./${TESTNAME}.inp | python3 check_mc.py 0.000030517578125 0.015 || echo "Monte Carlo pipeline failed"
${PROGRAM} -r "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" --method=2 --nsamples 100000 < ./${TESTNAME}.inp
${PROGRAM} -r "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" --method=3 --nsamples 100000 < ./${TESTNAME}.inp
2 changes: 1 addition & 1 deletion hvapprox/DTLZLinearShape.8d.front.60pts.10.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0.99341123409...
Monte Carlo estimate within tolerance
0.98996193911...
0.99032079022...
4 changes: 3 additions & 1 deletion hvapprox/DTLZLinearShape.8d.front.60pts.10.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
${PROGRAM} -r "1 1 1 1 1 1 1 1" --method=1 --nsamples 100000 --seed=42 --union < ../data/${TESTNAME}
set -o pipefail
# Compare the stochastic method against the low-discrepancy estimate.
${PROGRAM} -r "1 1 1 1 1 1 1 1" --method=1 --nsamples 100000 --seed=42 --union < ../data/${TESTNAME} | python3 check_mc.py 0.99032079022485 0.015 || echo "Monte Carlo pipeline failed"
${PROGRAM} -r "1 1 1 1 1 1 1 1" --method=2 --nsamples 100000 --union < ../data/${TESTNAME}
${PROGRAM} -r "1 1 1 1 1 1 1 1" --method=3 --nsamples 100000 --union < ../data/${TESTNAME}
2 changes: 1 addition & 1 deletion hvapprox/DTLZLinearShape.9d.front.60pts.10.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0.99131734089...
Monte Carlo estimate within tolerance
0.99348088822...
0.98924472303...
4 changes: 3 additions & 1 deletion hvapprox/DTLZLinearShape.9d.front.60pts.10.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
${PROGRAM} -r "1 1 1 1 1 1 1 1 1" --method=1 --nsamples 100000 --seed=42 --union < ../data/${TESTNAME}
set -o pipefail
# Compare the stochastic method against the low-discrepancy estimate.
${PROGRAM} -r "1 1 1 1 1 1 1 1 1" --method=1 --nsamples 100000 --seed=42 --union < ../data/${TESTNAME} | python3 check_mc.py 0.989244723035221 0.015 || echo "Monte Carlo pipeline failed"
${PROGRAM} -r "1 1 1 1 1 1 1 1 1" --method=2 --nsamples 100000 --union < ../data/${TESTNAME}
${PROGRAM} -r "1 1 1 1 1 1 1 1 1" --method=3 --nsamples 100000 --union < ../data/${TESTNAME}
5 changes: 5 additions & 0 deletions hvapprox/check_mc.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Monte Carlo estimate within tolerance
Monte Carlo estimate within tolerance
invalid estimate rejected
invalid estimate rejected
invalid estimate rejected
15 changes: 15 additions & 0 deletions hvapprox/check_mc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import math
import sys

reference = float(sys.argv[1])
tolerance = float(sys.argv[2])
estimate = float(sys.stdin.read())

if not math.isfinite(estimate) or abs(estimate - reference) > tolerance * abs(
reference
):
sys.exit(
f"Monte Carlo estimate {estimate} is not within {tolerance:.1%} of {reference}"
)

print("Monte Carlo estimate within tolerance")
10 changes: 10 additions & 0 deletions hvapprox/check_mc.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set -o pipefail
printf '100\n' | python3 check_mc.py 100 0.015
printf '101.5\n' | python3 check_mc.py 100 0.015
for estimate in 101.51 98.49 nan; do
if printf '%s\n' "$estimate" | python3 check_mc.py 100 0.015 > /dev/null 2>&1; then
echo "invalid estimate accepted: $estimate"
else
echo "invalid estimate rejected"
fi
done
2 changes: 1 addition & 1 deletion hvapprox/ran.10pts.9d.10.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
116387804.47...
Monte Carlo estimate within tolerance
116701329.23...
116309924.78...
4 changes: 3 additions & 1 deletion hvapprox/ran.10pts.9d.10.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
${PROGRAM} -r "10 10 10 10 10 10 10 10 10" --method=1 --nsamples 100000 --seed=42 --union < ../data/${TESTNAME}
set -o pipefail
# Compare the stochastic method against the low-discrepancy estimate.
${PROGRAM} -r "10 10 10 10 10 10 10 10 10" --method=1 --nsamples 100000 --seed=42 --union < ../data/${TESTNAME} | python3 check_mc.py 116309924.781825 0.015 || echo "Monte Carlo pipeline failed"
${PROGRAM} -r "10 10 10 10 10 10 10 10 10" --method=2 --nsamples 100000 --union < ../data/${TESTNAME}
${PROGRAM} -r "10 10 10 10 10 10 10 10 10" --method=3 --nsamples 100000 --union < ../data/${TESTNAME}
Loading