irace feat: scripts to run baseline and plot ECDF histograms

This commit is contained in:
Johann Dreo 2021-01-23 20:55:13 +01:00
commit 1b4f9447f2
2 changed files with 74 additions and 0 deletions

View file

@ -0,0 +1,44 @@
#!/usr/bin/env python3
import os
import numpy as np
import matplotlib.pyplot as plt
for p in range(18):
print("Pb",p,end=": ")
datadir="attain_mat_{pb}".format(pb=p)
try:
os.mkdir(datadir)
except FileExistsError:
pass
for i in range(50):
cmd="./release/fastga --seed={i} \
--crossover-rate=2 --cross-selector=2 --crossover=5 --mutation-rate=2 --mut-selector=2 --mutation=1 --replacement=0 \
--problem={pb} --buckets=20 --output-mat 2>/dev/null > {dir}/output_mat_{i}.csv"\
.format(dir=datadir, i=i, pb=p)
# print(cmd)
print(i,end=" ",flush=True)
os.system(cmd)
matrices=[]
for root, dirs, files in os.walk(datadir):
for filename in files:
matrices.append( np.genfromtxt(datadir+"/"+filename,delimiter=',') )
agg = matrices[0]
for mat in matrices[1:]:
agg += mat
# print(agg)
plt.rcParams["figure.figsize"] = (3,3)
plt.gca().pcolor(agg, edgecolors='grey', cmap="Blues")
plt.gca().set_xlabel("Time budget")
plt.gca().set_ylabel("Target")
plt.savefig("aittain_map_{pb}.png".format(pb=p), bbox_inches='tight')
print(".")

View file

@ -0,0 +1,30 @@
#!/bin/bash
outdir="$(date --iso-8601=minutes)_results_baselines"
mkdir ${outdir}
algos=(
# (λ+λ)EA
"--full-log=1 --crossover-rate=0 --cross-selector=0 --crossover=0 --mutation-rate=0 --mut-selector=0 --mutation=1 --replacement=0"
# (λ+λ)fEA
"--full-log=1 --crossover-rate=0 --cross-selector=0 --crossover=0 --mutation-rate=0 --mut-selector=0 --mutation=5 --replacement=0"
# (λ+λ)xGA
"--full-log=1 --crossover-rate=2 --cross-selector=2 --crossover=2 --mutation-rate=2 --mut-selector=2 --mutation=1 --replacement=0"
# (λ+λ)1ptGA
"--full-log=1 --crossover-rate=2 --cross-selector=2 --crossover=5 --mutation-rate=2 --mut-selector=2 --mutation=1 --replacement=0"
)
i=1 # Loop counter.
for algo in "${algos[@]}" ; do
echo "${algo}"
name="$(echo "${algo}" | sed 's/--//g' | sed 's/ /_/g')"
./run_algo.sh ${outdir} ${algo} &> "expe_${name}.log"
perc=$(echo "scale=2;${i}/${#algos[@]}*100" | bc)
echo -e "${perc}%\n"
i=$((i+1))
done
echo "Done"