Commit 443f0066 authored by Julien Lin's avatar Julien Lin
Browse files

last fixes

parent 3bf032b3
......@@ -43,19 +43,17 @@ def main(eaf_args=None):
if the.not_parallel:
results = []
for i in range(the.nb_run):
# print(f"{i}th run")
results.append(run(args))
else:
def f(i):
# print(f"{i}th run")
return run(args)
results = Parallel(n_jobs=num_cores - 1)(
delayed(f)(i) for i in range(the.nb_run)
)
lens =[len(result[-1]) for result in results]
lens = [len(result[-1]) for result in results]
histories = [
np.array([val for val, _ in history] + [1] * (the.iters - len(history)))
for _, _, _, _, _, history in results
......@@ -64,26 +62,37 @@ def main(eaf_args=None):
histories = np.array([np.maximum.accumulate(history) for history in histories])
masks = []
for idx, _ in enumerate(histories):
masks.append(np.concatenate((np.zeros(lens[idx],),np.ones(the.iters - lens[idx],))))
masks.append(
np.concatenate(
(
np.zeros(
lens[idx],
),
np.ones(
the.iters - lens[idx],
),
)
)
)
histories = np.ma.array(histories, mask=masks).T
buff = np.empty((1, the.iters))
for quality_threshold in the.quality_threshold:
curr_quality = histories >= quality_threshold
curr_quality = curr_quality.mean(axis=-1)
curr_quality = np.sum(curr_quality, axis=1) / the.nb_run
curr_quality = np.maximum.accumulate(curr_quality)
curr_quality = np.expand_dims(curr_quality, axis=0)
buff = np.concatenate((buff, curr_quality))
_, coef, initial, _, _, _ = results[0]
t = [i * coef for i in range(histories.shape[0])]
t[0] = initial
t = [i * coef + initial for i in range(histories.shape[0])]
plt.figure()
plt.title(f"{the.solver}, threshold {the.quality_threshold}")
for i in range(1, buff.shape[0]):
plt.step(t, buff[i,~buff[i].mask][0])
plt.step(t, buff[i, ~buff[i].mask][0])
plt.legend(
[
......@@ -91,6 +100,10 @@ def main(eaf_args=None):
for i in range(len(the.quality_threshold))
]
)
plt.xlabel("Number of calls to objective function")
plt.ylabel("Frequency of reaching")
plt.show()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment