Commit 4989e241 authored by LIN Julien's avatar LIN Julien
Browse files

Merge branch 'eaf' into 'master'

Eaf

See merge request !2
parents 8e14bcd5 c9163230
......@@ -4,41 +4,70 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: eaf",
"type": "python",
"request": "launch",
"module": "eaf",
"args": ["--nb-run","20","--quality-threshold","660","--solver","num_greedy"]
},
{
"name": "Python: num_evolutionary",
"type": "python",
"request": "launch",
"module": "snp",
"args": ["--solver","num_evolutionary", "--nb-population","100", "--nb-offspring", "100", "--nb-selected", "10"]
"args": [
"--solver",
"num_evolutionary",
"--nb-population",
"100",
"--nb-offspring",
"100",
"--nb-selected",
"10"
]
},
{
"name": "Python: num_random",
"type": "python",
"request": "launch",
"module": "snp",
"args": ["--solver","num_random", "--iters", "2000", "--steady-delta", "500"]
"args": [
"--solver",
"num_random",
"--iters",
"2000",
"--steady-delta",
"500"
]
},
{
"name": "Python: num_sim_anneal",
"type": "python",
"request": "launch",
"module": "snp",
"args": ["--solver","num_sim_anneal", "--iters", "2000", "--steady-delta", "500"]
"args": [
"--solver",
"num_sim_anneal",
"--iters",
"2000",
"--steady-delta",
"500"
]
},
{
"name": "Python: bit_sim_anneal",
"type": "python",
"request": "launch",
"module": "snp",
"args": ["--solver","bit_sim_anneal"]
"name": "Python: bit_sim_anneal",
"type": "python",
"request": "launch",
"module": "snp",
"args": ["--solver", "bit_sim_anneal"]
},
{
"name": "Python: greedy",
"type": "python",
"request": "launch",
"module": "snp",
}
"name": "Python: greedy",
"type": "python",
"request": "launch",
"module": "snp"
}
]
}
import argparse
from matplotlib import pyplot as plt
import numpy as np
from snp import main as run
import multiprocessing
from joblib import Parallel, delayed
num_cores = multiprocessing.cpu_count()
def get_args_parse():
can = argparse.ArgumentParser()
can.add_argument("--nb-run", type=int, default=10, help="number of runs")
can.add_argument(
"--quality-threshold", type=float, default=660, nargs="+", help="Quality threshold"
)
can.add_argument(
"--not-parallel", type=bool, default=False, help="launch runs sequentialy"
)
can.add_argument("--solver", type=str, default="num_random", help="Solver to use.")
return can
def main(eaf_args=None):
can = get_args_parse()
the = can.parse_args(eaf_args)
args = ["--solver", the.solver, "--iters", "2000", "--steady-delta", "500"]
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)(delayed(f)(i) for i in range(the.nb_run))
values = [(val, iter) for val, iter, _, _ in results]
values = sorted(values, key=lambda el: el[1])
t = [iter for _, iter in values]
values = np.array([val for val, _ in values])
buff = np.empty((1,the.nb_run))
for quality_threshold in the.quality_threshold:
curr_qualities = np.cumsum(values >= quality_threshold) / len(values)
curr_qualities = np.expand_dims(curr_qualities, axis=0)
buff = np.concatenate((buff,curr_qualities))
fig = plt.figure()
plt.title(f"{the.solver}, threshold {the.quality_threshold}")
for i in range(1, buff.shape[0]):
plt.step(t, buff[i])
# ax4 = fig.add_subplot(122, projection="3d")
# plt.title(f"{the.solver}, thresholds : {the.quality_threshold}")
# ax4.plot_surface(t, values, the.quality_threshold )
plt.legend([f'threshold : {the.quality_threshold[i]}' for i in range(len(the.quality_threshold))])
plt.show()
if __name__ == "__main__":
main()
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="345.6pt" version="1.1" viewBox="0 0 460.8 345.6" width="460.8pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<metadata>
<rdf:RDF xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<cc:Work>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:date>2021-10-11T18:59:42.329144</dc:date>
<dc:format>image/svg+xml</dc:format>
<dc:creator>
<cc:Agent>
<dc:title>Matplotlib v3.4.3, https://matplotlib.org/</dc:title>
</cc:Agent>
</dc:creator>
</cc:Work>
</rdf:RDF>
</metadata>
<defs>
<style type="text/css">*{stroke-linecap:butt;stroke-linejoin:round;}</style>
</defs>
<g id="figure_1">
<g id="patch_1">
<path d="M 0 345.6
L 460.8 345.6
L 460.8 0
L 0 0
z
" style="fill:#ffffff;"/>
</g>
<g id="axes_1">
<g id="patch_2">
<path d="M 57.6 307.584
L 414.72 307.584
L 414.72 41.472
L 57.6 41.472
z
" style="fill:#ffffff;"/>
</g>
<g id="matplotlib.axis_1">
<g id="xtick_1">
<g id="line2d_1">
<defs>
<path d="M 0 0
L 0 3.5
" id="me41067ab0f" style="stroke:#000000;stroke-width:0.8;"/>
</defs>
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="103.346777" xlink:href="#me41067ab0f" y="307.584"/>
</g>
</g>
<g id="text_1">
<!-- 600 -->
<g transform="translate(93.803027 322.182437)scale(0.1 -0.1)">
<defs>
<path d="M 2113 2584
Q 1688 2584 1439 2293
Q 1191 2003 1191 1497
Q 1191 994 1439 701
Q 1688 409 2113 409
Q 2538 409 2786 701
Q 3034 994 3034 1497
Q 3034 2003 2786 2293
Q 2538 2584 2113 2584
z
M 3366 4563
L 3366 3988
Q 3128 4100 2886 4159
Q 2644 4219 2406 4219
Q 1781 4219 1451 3797
Q 1122 3375 1075 2522
Q 1259 2794 1537 2939
Q 1816 3084 2150 3084
Q 2853 3084 3261 2657
Q 3669 2231 3669 1497
Q 3669 778 3244 343
Q 2819 -91 2113 -91
Q 1303 -91 875 529
Q 447 1150 447 2328
Q 447 3434 972 4092
Q 1497 4750 2381 4750
Q 2619 4750 2861 4703
Q 3103 4656 3366 4563
z
" id="DejaVuSans-36" transform="scale(0.015625)"/>
<path d="M 2034 4250
Q 1547 4250 1301 3770
Q 1056 3291 1056 2328
Q 1056 1369 1301 889
Q 1547 409 2034 409
Q 2525 409 2770 889
Q 3016 1369 3016 2328
Q 3016 3291 2770 3770
Q 2525 4250 2034 4250
z
M 2034 4750
Q 2819 4750 3233 4129
Q 3647 3509 3647 2328
Q 3647 1150 3233 529
Q 2819 -91 2034 -91
Q 1250 -91 836 529
Q 422 1150 422 2328
Q 422 3509 836 4129
Q 1250 4750 2034 4750
z
" id="DejaVuSans-30" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-36"/>
<use x="63.623047" xlink:href="#DejaVuSans-30"/>
<use x="127.246094" xlink:href="#DejaVuSans-30"/>
</g>
</g>
</g>
<g id="xtick_2">
<g id="line2d_2">
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="171.984101" xlink:href="#me41067ab0f" y="307.584"/>
</g>
</g>
<g id="text_2">
<!-- 800 -->
<g transform="translate(162.440351 322.182437)scale(0.1 -0.1)">
<defs>
<path d="M 2034 2216
Q 1584 2216 1326 1975
Q 1069 1734 1069 1313
Q 1069 891 1326 650
Q 1584 409 2034 409
Q 2484 409 2743 651
Q 3003 894 3003 1313
Q 3003 1734 2745 1975
Q 2488 2216 2034 2216
z
M 1403 2484
Q 997 2584 770 2862
Q 544 3141 544 3541
Q 544 4100 942 4425
Q 1341 4750 2034 4750
Q 2731 4750 3128 4425
Q 3525 4100 3525 3541
Q 3525 3141 3298 2862
Q 3072 2584 2669 2484
Q 3125 2378 3379 2068
Q 3634 1759 3634 1313
Q 3634 634 3220 271
Q 2806 -91 2034 -91
Q 1263 -91 848 271
Q 434 634 434 1313
Q 434 1759 690 2068
Q 947 2378 1403 2484
z
M 1172 3481
Q 1172 3119 1398 2916
Q 1625 2713 2034 2713
Q 2441 2713 2670 2916
Q 2900 3119 2900 3481
Q 2900 3844 2670 4047
Q 2441 4250 2034 4250
Q 1625 4250 1398 4047
Q 1172 3844 1172 3481
z
" id="DejaVuSans-38" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-38"/>
<use x="63.623047" xlink:href="#DejaVuSans-30"/>
<use x="127.246094" xlink:href="#DejaVuSans-30"/>
</g>
</g>
</g>
<g id="xtick_3">
<g id="line2d_3">
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="240.621426" xlink:href="#me41067ab0f" y="307.584"/>
</g>
</g>
<g id="text_3">
<!-- 1000 -->
<g transform="translate(227.896426 322.182437)scale(0.1 -0.1)">
<defs>
<path d="M 794 531
L 1825 531
L 1825 4091
L 703 3866
L 703 4441
L 1819 4666
L 2450 4666
L 2450 531
L 3481 531
L 3481 0
L 794 0
L 794 531
z
" id="DejaVuSans-31" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-31"/>
<use x="63.623047" xlink:href="#DejaVuSans-30"/>
<use x="127.246094" xlink:href="#DejaVuSans-30"/>
<use x="190.869141" xlink:href="#DejaVuSans-30"/>
</g>
</g>
</g>
<g id="xtick_4">
<g id="line2d_4">
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="309.258751" xlink:href="#me41067ab0f" y="307.584"/>
</g>
</g>
<g id="text_4">
<!-- 1200 -->
<g transform="translate(296.533751 322.182437)scale(0.1 -0.1)">
<defs>
<path d="M 1228 531
L 3431 531
L 3431 0
L 469 0
L 469 531
Q 828 903 1448 1529
Q 2069 2156 2228 2338
Q 2531 2678 2651 2914
Q 2772 3150 2772 3378
Q 2772 3750 2511 3984
Q 2250 4219 1831 4219
Q 1534 4219 1204 4116
Q 875 4013 500 3803
L 500 4441
Q 881 4594 1212 4672
Q 1544 4750 1819 4750
Q 2544 4750 2975 4387
Q 3406 4025 3406 3419
Q 3406 3131 3298 2873
Q 3191 2616 2906 2266
Q 2828 2175 2409 1742
Q 1991 1309 1228 531
z
" id="DejaVuSans-32" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-31"/>
<use x="63.623047" xlink:href="#DejaVuSans-32"/>
<use x="127.246094" xlink:href="#DejaVuSans-30"/>
<use x="190.869141" xlink:href="#DejaVuSans-30"/>
</g>
</g>
</g>
<g id="xtick_5">
<g id="line2d_5">
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="377.896075" xlink:href="#me41067ab0f" y="307.584"/>
</g>
</g>
<g id="text_5">
<!-- 1400 -->
<g transform="translate(365.171075 322.182437)scale(0.1 -0.1)">
<defs>
<path d="M 2419 4116
L 825 1625
L 2419 1625
L 2419 4116
z
M 2253 4666
L 3047 4666
L 3047 1625
L 3713 1625
L 3713 1100
L 3047 1100
L 3047 0
L 2419 0
L 2419 1100
L 313 1100
L 313 1709
L 2253 4666
z
" id="DejaVuSans-34" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-31"/>
<use x="63.623047" xlink:href="#DejaVuSans-34"/>
<use x="127.246094" xlink:href="#DejaVuSans-30"/>
<use x="190.869141" xlink:href="#DejaVuSans-30"/>
</g>
</g>
</g>
</g>
<g id="matplotlib.axis_2">
<g id="ytick_1">
<g id="line2d_6">
<defs>
<path d="M 0 0
L -3.5 0
" id="m0fbdb4ab58" style="stroke:#000000;stroke-width:0.8;"/>
</defs>
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m0fbdb4ab58" y="255.168"/>
</g>
</g>
<g id="text_6">
<!-- 0.2 -->
<g transform="translate(34.696875 258.967219)scale(0.1 -0.1)">
<defs>
<path d="M 684 794
L 1344 794
L 1344 0
L 684 0
L 684 794
z
" id="DejaVuSans-2e" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-30"/>
<use x="63.623047" xlink:href="#DejaVuSans-2e"/>
<use x="95.410156" xlink:href="#DejaVuSans-32"/>
</g>
</g>
</g>
<g id="ytick_2">
<g id="line2d_7">
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m0fbdb4ab58" y="201.408"/>
</g>
</g>
<g id="text_7">
<!-- 0.4 -->
<g transform="translate(34.696875 205.207219)scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use x="63.623047" xlink:href="#DejaVuSans-2e"/>
<use x="95.410156" xlink:href="#DejaVuSans-34"/>
</g>
</g>
</g>
<g id="ytick_3">
<g id="line2d_8">
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m0fbdb4ab58" y="147.648"/>
</g>
</g>
<g id="text_8">
<!-- 0.6 -->
<g transform="translate(34.696875 151.447219)scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use x="63.623047" xlink:href="#DejaVuSans-2e"/>
<use x="95.410156" xlink:href="#DejaVuSans-36"/>
</g>
</g>
</g>
<g id="ytick_4">
<g id="line2d_9">
<g>
<use style="stroke:#000000;stroke-width:0.8;" x="57.6" xlink:href="#m0fbdb4ab58" y="93.888"/>
</g>
</g>
<g id="text_9">
<!-- 0.8 -->
<g transform="translate(34.696875 97.687219)scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use x="63.623047" xlink:href="#DejaVuSans-2e"/>
<use x="95.410156" xlink:href="#DejaVuSans-38"/>
</g>
</g>
</g>
</g>
<g id="line2d_10">
<path clip-path="url(#p2196036e50)" d="M 73.832727 295.488
L 73.832727 282.048
L 87.903379 282.048
L 87.903379 268.608
L 105.06271 268.608
L 105.06271 255.168
L 106.778643 255.168
L 106.778643 255.168
L 110.896883 255.168
L 110.896883 241.728
L 116.044682 241.728
L 116.044682 228.288
L 117.074242 228.288
L 117.074242 214.848
L 136.979066 214.848
L 136.979066 201.408
L 172.670475 201.408
L 172.670475 187.968
L 185.36838 187.968
L 185.36838 174.528
L 221.059789 174.528
L 221.059789 161.088
L 239.24868 161.088
L 239.24868 147.648
L 283.176567 147.648
L 283.176567 134.208
L 292.442606 134.208
L 292.442606 120.768
L 301.022272 120.768
L 301.022272 107.328
L 330.193135 107.328
L 330.193135 93.888
L 359.363998 93.888
L 359.363998 80.448
L 364.511797 80.448
L 364.511797 67.008
L 393.68266 67.008
L 393.68266 53.568
L 398.487273 53.568
" style="fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;"/>
</g>
<g id="patch_3">
<path d="M 57.6 307.584
L 57.6 41.472
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/>
</g>
<g id="patch_4">
<path d="M 414.72 307.584
L 414.72 41.472
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/>
</g>
<g id="patch_5">
<path d="M 57.6 307.584
L 414.72 307.584
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/>
</g>
<g id="patch_6">
<path d="M 57.6 41.472
L 414.72 41.472
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;"/>
</g>
<g id="text_10">
<!-- num_sim_anneal, threshold 660.0 -->
<g transform="translate(134.605312 35.472)scale(0.12 -0.12)">
<defs>
<path d="M 3513 2113
L 3513 0
L 2938 0
L 2938 2094
Q 2938 2591 2744 2837
Q 2550 3084 2163 3084
Q 1697 3084 1428 2787
Q 1159 2491 1159 1978
L 1159 0
L 581 0
L 581 3500
L 1159 3500
L 1159 2956
Q 1366 3272 1645 3428
Q 1925 3584 2291 3584
Q 2894 3584 3203 3211
Q 3513 2838 3513 2113
z
" id="DejaVuSans-6e" transform="scale(0.015625)"/>
<path d="M 544 1381
L 544 3500
L 1119 3500
L 1119 1403
Q 1119 906 1312 657
Q 1506 409 1894 409
Q 2359 409 2629 706
Q 2900 1003 2900 1516
L 2900 3500
L 3475 3500
L 3475 0
L 2900 0
L 2900 538
Q 2691 219 2414 64
Q 2138 -91 1772 -91
Q 1169 -91 856 284
Q 544 659 544 1381