Skip to content

Commit

Permalink
improve samplesize computation in pprldmany.main
Browse files Browse the repository at this point in the history
  • Loading branch information
nikohansen committed Nov 11, 2021
1 parent ca4e6e4 commit 7936880
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions code-postprocessing/cocopp/compall/pprldmany.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,24 @@ def main(dictAlg, order=None, outputdir='.', info='default',

dictDim = dictDimList[dim]
dictFunc = pp.dictAlgByFun(dictDim)

# determine a good samplesize
run_numbers = []
for dsl in dictDim.values():
run_numbers.extend([ds.nbRuns() for ds in dsl])
try: lcm = np.lcm.reduce(run_numbers) # lowest common multiplier
except: lcm = max(run_numbers) # fallback for old numpy versions
samplesize = lcm
if testbedsettings.current_testbed.instances_are_uniform:
samplesize = max(perfprofsamplesize, lcm) # maybe more bootstrapping with unsuccessful trials
for f, dictAlgperFunc in sorted(dictFunc.items()):
# print(target_values((f, dim)))
for j, t in enumerate(target_values((f, dim))):
# for j, t in enumerate(testbedsettings.current_testbed.ecdf_target_values(1e2, f)):
# funcsolved[j].add(f)

for alg in algorithms_with_data:
x = [np.inf] * perfprofsamplesize
x = [np.inf] * samplesize
runlengthunsucc = []
try:
entry = dictAlgperFunc[alg][0] # one element per fun and per dim.
Expand All @@ -649,14 +659,14 @@ def main(dictAlg, order=None, outputdir='.', info='default',
if testbedsettings.current_testbed.instances_are_uniform:
x = toolsstats.drawSP(runlengthsucc, runlengthunsucc,
percentiles=[50],
samplesize=perfprofsamplesize)[1]
samplesize=samplesize)[1]
else:
nruns = len(runlengthsucc) + len(runlengthunsucc)
if perfprofsamplesize % nruns:
if samplesize % nruns:
warnings.warn("without simulated restarts nbsamples=%d"
" should be a multiple of nbruns=%d"
% (perfprofsamplesize, nruns))
idx = toolsstats.randint_derandomized(nruns, size=perfprofsamplesize)
% (samplesize, nruns))
idx = toolsstats.randint_derandomized(nruns, size=samplesize)
x = np.hstack((runlengthsucc, len(runlengthunsucc) * [np.inf]))[idx]
except (KeyError, IndexError):
# set_trace()
Expand Down Expand Up @@ -695,9 +705,9 @@ def main(dictAlg, order=None, outputdir='.', info='default',
runlengthunsucc = refalgentry.maxevals[refalgevals[1][j]][np.isnan(evals)] / divisor
x = toolsstats.drawSP(runlengthsucc, runlengthunsucc,
percentiles=[50],
samplesize=perfprofsamplesize)[1]
samplesize=samplesize)[1]
else:
x = perfprofsamplesize * [np.inf]
x = samplesize * [np.inf]
runlengthunsucc = []
xbest.extend(x)
maxevalsbest.extend(runlengthunsucc)
Expand Down

0 comments on commit 7936880

Please sign in to comment.