Commit 07fe17ec authored by Illia Kolesnik's avatar Illia Kolesnik
Browse files

Translate to czech

parent a17f9005
Loading
Loading
Loading
Loading
+50 −47
Original line number Diff line number Diff line
%% Cell type:code id: tags:

``` python
import pandas as pd
import matplotlib.pyplot as plt

RESULT_DIR = 'pdfs'
```

%% Cell type:code id: tags:

``` python
def get_grouped_df(filename):
    result = pd.read_csv(filename, sep=';').drop(columns=['SIZE'])
    grouped_result = result.groupby(['DISTRIBUTION', 'OPERATION', 'REFINES']).agg({'LINEAR': ['mean', 'std', 'min', 'max'], 'CLASSIC': ['mean', 'std', 'min', 'max']}).reset_index()
    grouped_result.columns = ['DISTRIBUTION', 'OPERATION', 'REFINES', 'LINEAR_MEAN', 'LINEAR_STD', 'LINEAR_MIN', 'LINEAR_MAX', 'CLASSIC_MEAN', 'CLASSIC_STD', 'CLASSIC_MIN', 'CLASSIC_MAX']
    # Calculate the speedup
    grouped_result['SPEEDUP_MEAN'] = grouped_result['LINEAR_MEAN'] / grouped_result['CLASSIC_MEAN']

    return grouped_result

result_std = get_grouped_df('result_std.csv')
result_cuckoo = get_grouped_df('result_cuckoo.csv')
result_hopscotch = get_grouped_df('result_hopscotch.csv')
```

%% Cell type:code id: tags:

``` python
def plot_compare(df: pd.DataFrame, title, filename):
    fig, ax = plt.subplots()
    ax.errorbar(df['REFINES'], df['LINEAR_MEAN'], yerr=df['LINEAR_STD'], label='Linear')
    ax.errorbar(df['REFINES'], df['CLASSIC_MEAN'], yerr=df['CLASSIC_STD'], label='Classic')
    ax.errorbar(df['REFINES'], df['LINEAR_MEAN'], yerr=df['LINEAR_STD'], label='Lineární')
    ax.errorbar(df['REFINES'], df['CLASSIC_MEAN'], yerr=df['CLASSIC_STD'], label='Klasic')
    ax.set_xscale('log')
    ax.set_xlabel('Refines')
    ax.set_ylabel('Time (s)')
    ax.set_xlabel('Počet zjemnění')
    ax.set_ylabel('Čas (s)')
    ax.set_title(title)
    ax.legend()
    plt.savefig(f'{RESULT_DIR}/{filename}.pdf')
    df.to_csv(f'{RESULT_DIR}/{filename}.csv', sep=';', index=False)
    plt.show()

def process_table_impl(df: pd.DataFrame, impl: str):
    plot_compare(df[(df['DISTRIBUTION'] == 'normal') & (df['OPERATION'] == 'search')], 'Search in basic directions, normal distribution', f'{impl}_search_normal')
    plot_compare(df[(df['DISTRIBUTION'] == 'unif') & (df['OPERATION'] == 'search')], 'Search in basic directions, uniform distribution', f'{impl}_search_unif')
    plot_compare(df[(df['DISTRIBUTION'] == 'exp') & (df['OPERATION'] == 'search')], 'Search in basic directions, uniform distribution', f'{impl}_search_exp')

    plot_compare(df[(df['DISTRIBUTION'] == 'normal') & (df['OPERATION'] == 'search_all')], 'Search in all directions, normal distribution', f'{impl}_search_all_normal')
    plot_compare(df[(df['DISTRIBUTION'] == 'unif') & (df['OPERATION'] == 'search_all')], 'Search in all directions, uniform distribution', f'{impl}_search_all_unif')
    plot_compare(df[(df['DISTRIBUTION'] == 'exp') & (df['OPERATION'] == 'search_all')], 'Search in all directions, uniform distribution', f'{impl}_search_all_exp')

    plot_compare(df[(df['DISTRIBUTION'] == 'normal') & (df['OPERATION'] == 'refinement')], 'Refinement speed, normal distribution', f'{impl}_refine_normal')
    plot_compare(df[(df['DISTRIBUTION'] == 'unif') & (df['OPERATION'] == 'refinement')], 'Refinement speed, uniform distribution', f'{impl}_refine_unif')
    plot_compare(df[(df['DISTRIBUTION'] == 'exp') & (df['OPERATION'] == 'refinement')], 'Refinement speed, uniform distribution', f'{impl}_refine_exp')
    plot_compare(df[(df['DISTRIBUTION'] == 'normal') & (df['OPERATION'] == 'search')], 'Hledání v základních směrech, normální rozdělení', f'{impl}_search_normal')
    plot_compare(df[(df['DISTRIBUTION'] == 'unif') & (df['OPERATION'] == 'search')], 'Hledání v základních směrech, rovnoměrné rozdělení', f'{impl}_search_unif')
    plot_compare(df[(df['DISTRIBUTION'] == 'exp') & (df['OPERATION'] == 'search')], 'Hledání v základních směrech, exponenciální rozdělení', f'{impl}_search_exp')

    plot_compare(df[(df['DISTRIBUTION'] == 'normal') & (df['OPERATION'] == 'search_all')], 'Hledání ve všech směrech, normální rozdělení', f'{impl}_search_all_normal')
    plot_compare(df[(df['DISTRIBUTION'] == 'unif') & (df['OPERATION'] == 'search_all')], 'Hledání ve všech směrech, rovnoměrné rozdělení', f'{impl}_search_all_unif')
    plot_compare(df[(df['DISTRIBUTION'] == 'exp') & (df['OPERATION'] == 'search_all')], 'Hledání ve všech směrech, exponenciální rozdělení', f'{impl}_search_all_exp')

    plot_compare(df[(df['DISTRIBUTION'] == 'normal') & (df['OPERATION'] == 'refinement')], 'Rychlost zjemnění, normální rozdělení', f'{impl}_refine_normal')
    plot_compare(df[(df['DISTRIBUTION'] == 'unif') & (df['OPERATION'] == 'refinement')], 'Rychlost zjemnění, rovnoměrné rozdělení', f'{impl}_refine_unif')
    plot_compare(df[(df['DISTRIBUTION'] == 'exp') & (df['OPERATION'] == 'refinement')], 'Rychlost zjemnění, exponenciální rozdělení', f'{impl}_refine_exp')

# process_table_impl(result_std, 'std')
# process_table_impl(result_cuckoo, 'cuckoo')
process_table_impl(result_std, 'std')
process_table_impl(result_cuckoo, 'cuckoo')
process_table_impl(result_hopscotch, 'hopscotch')
```

%% Cell type:code id: tags:

``` python
# Compare different distributions
def compare_distributions(df: pd.DataFrame, title, filename):
    normal = df[(df['DISTRIBUTION'] == 'normal')]
    unif = df[(df['DISTRIBUTION'] == 'unif')]
    exp = df[(df['DISTRIBUTION'] == 'exp')]
    fig, ax = plt.subplots()
    ax.errorbar(normal['REFINES'], normal['MEAN'], yerr=normal['STD'], label='Normal')
    ax.errorbar(unif['REFINES'], unif['MEAN'], yerr=unif['STD'], label='Uniform')
    ax.errorbar(exp['REFINES'], exp['MEAN'], yerr=exp['STD'], label='Exponential')
    ax.errorbar(normal['REFINES'], normal['MEAN'], yerr=normal['STD'], label='Normální')
    ax.errorbar(unif['REFINES'], unif['MEAN'], yerr=unif['STD'], label='Rovnoměrné')
    ax.errorbar(exp['REFINES'], exp['MEAN'], yerr=exp['STD'], label='Exponenciální')
    ax.set_xscale('log')
    ax.set_xlabel('Refines')
    ax.set_ylabel('Time (s)')
    ax.set_xlabel('Počet zjemnění')
    ax.set_ylabel('Čas (s)')
    ax.set_title(title)
    ax.legend()
    plt.savefig(f'{RESULT_DIR}/{filename}.pdf')
    df.to_csv(f'{RESULT_DIR}/{filename}.csv', sep=';', index=False)
    plt.show()

def compare_distributions_impl(df: pd.DataFrame, impl: str):
    search_classic = df.rename(columns={'CLASSIC_MEAN': 'MEAN', 'CLASSIC_STD': 'STD'})[(df['OPERATION'] == 'search')]
    search_linear = df.rename(columns={'LINEAR_MEAN': 'MEAN', 'LINEAR_STD': 'STD'})[(df['OPERATION'] == 'search')]
    search_all_classic = df.rename(columns={'CLASSIC_MEAN': 'MEAN', 'CLASSIC_STD': 'STD'})[(df['OPERATION'] == 'search_all')]
    search_all_linear = df.rename(columns={'LINEAR_MEAN': 'MEAN', 'LINEAR_STD': 'STD'})[(df['OPERATION'] == 'search_all')]
    refine_classic = df.rename(columns={'CLASSIC_MEAN': 'MEAN', 'CLASSIC_STD': 'STD'})[(df['OPERATION'] == 'refinement')]
    refine_linear = df.rename(columns={'LINEAR_MEAN': 'MEAN', 'LINEAR_STD': 'STD'})[(df['OPERATION'] == 'refinement')]

    # compare_distributions(search_classic, f'Search in basic directions, classic octree', f'{impl}_search_classic')
    # compare_distributions(search_all_classic, f'Search in all directions, classic octree', f'{impl}_search_all_classic')
    # compare_distributions(refine_classic, f'Refinement speed, classic octree', f'{impl}_refine_classic')

    # compare_distributions(search_linear, f'Search in basic directions, linear octree', f'{impl}_search_linear')
    # compare_distributions(search_all_linear, f'Search in all directions, linear octree', f'{impl}_search_all_linear')
    # compare_distributions(refine_linear, f'Refinement speed, linear octree', f'{impl}_refine_linear')

# compare_distributions_impl(result_std, 'std')
# compare_distributions_impl(result_cuckoo, 'cuckoo')
# compare_distributions_impl(result_hopscotch, 'hopscotch')
    compare_distributions(search_classic, f'Hledání sousedních buněk v základních směrech, klasic octree', f'{impl}_search_classic')
    compare_distributions(search_all_classic, f'Hledání ve všech směrech, klasic octree', f'{impl}_search_all_classic')
    compare_distributions(refine_classic, f'Rychlost zjemnění, klasic octree', f'{impl}_refine_classic')

    compare_distributions(search_linear, f'Hledání sousedních buněk v základních směrech, lineární octree', f'{impl}_search_linear')
    compare_distributions(search_all_linear, f'Hledání ve všech směrech, lineární octree', f'{impl}_search_all_linear')
    compare_distributions(refine_linear, f'Rychlost zjemnění, lineární octree', f'{impl}_refine_linear')

compare_distributions_impl(result_std, 'std')
compare_distributions_impl(result_cuckoo, 'cuckoo')
compare_distributions_impl(result_hopscotch, 'hopscotch')
```

%% Cell type:code id: tags:

``` python
# Compare different implementations
def compare_implementations(std: pd.DataFrame, cuckoo: pd.DataFrame, hopscotch: pd.DataFrame, title, filename):
    fig, ax = plt.subplots()
    ax.errorbar(std['REFINES'], std['LINEAR_MEAN'], yerr=std['LINEAR_STD'], label='Standard')
    ax.errorbar(std['REFINES'], std['LINEAR_MEAN'], yerr=std['LINEAR_STD'], label='C++ STL')
    ax.errorbar(cuckoo['REFINES'], cuckoo['LINEAR_MEAN'], yerr=cuckoo['LINEAR_STD'], label='Cuckoo')
    ax.errorbar(hopscotch['REFINES'], hopscotch['LINEAR_MEAN'], yerr=hopscotch['LINEAR_STD'], label='Hopscotch')
    ax.set_xscale('log')
    ax.set_xlabel('Refines')
    ax.set_ylabel('Time (s)')
    ax.set_xlabel('Počet zjemnění')
    ax.set_ylabel('Čas (s)')
    ax.set_title(title)
    ax.legend()
    plt.savefig(f'{RESULT_DIR}/{filename}.pdf')
    plt.show()

normal_std = result_std[(result_std['DISTRIBUTION'] == 'normal')]
unif_std = result_std[(result_std['DISTRIBUTION'] == 'unif')]
exp_std = result_std[(result_std['DISTRIBUTION'] == 'exp')]
normal_std_search = normal_std[(normal_std['OPERATION'] == 'search')]

unif_std_search = unif_std[(unif_std['OPERATION'] == 'search')]
exp_std_search = exp_std[(exp_std['OPERATION'] == 'search')]
normal_std_search_all = normal_std[(normal_std['OPERATION'] == 'search_all')]
unif_std_search_all = unif_std[(unif_std['OPERATION'] == 'search_all')]
exp_std_search_all = exp_std[(exp_std['OPERATION'] == 'search_all')]
normal_std_refine = normal_std[(normal_std['OPERATION'] == 'refinement')]
unif_std_refine = unif_std[(unif_std['OPERATION'] == 'refinement')]
exp_std_refine = exp_std[(exp_std['OPERATION'] == 'refinement')]


normal_cuckoo = result_cuckoo[(result_cuckoo['DISTRIBUTION'] == 'normal')]
unif_cuckoo = result_cuckoo[(result_cuckoo['DISTRIBUTION'] == 'unif')]
exp_cuckoo = result_cuckoo[(result_cuckoo['DISTRIBUTION'] == 'exp')]

normal_cuckoo_search = normal_cuckoo[(normal_cuckoo['OPERATION'] == 'search')]
unif_cuckoo_search = unif_cuckoo[(unif_cuckoo['OPERATION'] == 'search')]
exp_cuckoo_search = exp_cuckoo[(exp_cuckoo['OPERATION'] == 'search')]
normal_cuckoo_search_all = normal_cuckoo[(normal_cuckoo['OPERATION'] == 'search_all')]
unif_cuckoo_search_all = unif_cuckoo[(unif_cuckoo['OPERATION'] == 'search_all')]
exp_cuckoo_search_all = exp_cuckoo[(exp_cuckoo['OPERATION'] == 'search_all')]
normal_cuckoo_refine = normal_cuckoo[(normal_cuckoo['OPERATION'] == 'refinement')]
unif_cuckoo_refine = unif_cuckoo[(unif_cuckoo['OPERATION'] == 'refinement')]
exp_cuckoo_refine = exp_cuckoo[(exp_cuckoo['OPERATION'] == 'refinement')]

normal_hopscotch = result_hopscotch[(result_hopscotch['DISTRIBUTION'] == 'normal')]
unif_hopscotch = result_hopscotch[(result_hopscotch['DISTRIBUTION'] == 'unif')]
exp_hopscotch = result_hopscotch[(result_hopscotch['DISTRIBUTION'] == 'exp')]

normal_hopscotch_search = normal_hopscotch[(normal_hopscotch['OPERATION'] == 'search')]
unif_hopscotch_search = unif_hopscotch[(unif_hopscotch['OPERATION'] == 'search')]
exp_hopscotch_search = exp_hopscotch[(exp_hopscotch['OPERATION'] == 'search')]
normal_hopscotch_search_all = normal_hopscotch[(normal_hopscotch['OPERATION'] == 'search_all')]
unif_hopscotch_search_all = unif_hopscotch[(unif_hopscotch['OPERATION'] == 'search_all')]
exp_hopscotch_search_all = exp_hopscotch[(exp_hopscotch['OPERATION'] == 'search_all')]
normal_hopscotch_refine = normal_hopscotch[(normal_hopscotch['OPERATION'] == 'refinement')]
unif_hopscotch_refine = unif_hopscotch[(unif_hopscotch['OPERATION'] == 'refinement')]
exp_hopscotch_refine = exp_hopscotch[(exp_hopscotch['OPERATION'] == 'refinement')]
# TODO: pridat klasicky
# compare_implementations(normal_std_search, normal_cuckoo_search, normal_hopscotch_search, 'Search in basic directions, normal distribution', 'compare_search_normal')
# compare_implementations(unif_std_search, unif_cuckoo_search, unif_hopscotch_search, 'Search in basic directions, uniform distribution', 'compare_search_unif')
# compare_implementations(exp_std_search, exp_cuckoo_search, exp_hopscotch_search, 'Search in basic directions, exponential distribution', 'compare_search_exp')

# compare_implementations(normal_std_search_all, normal_cuckoo_search_all, normal_hopscotch_search_all, 'Search in all directions, normal distribution', 'compare_search_all_normal')
# compare_implementations(unif_std_search_all, unif_cuckoo_search_all, unif_hopscotch_search_all, 'Search in all directions, uniform distribution', 'compare_search_all_unif')
# compare_implementations(exp_std_search_all, exp_cuckoo_search_all, exp_hopscotch_search_all, 'Search in all directions, exponential distribution', 'compare_search_all_exp')

# compare_implementations(normal_std_refine, normal_cuckoo_refine, normal_hopscotch_refine, 'Refinement speed, normal distribution', 'compare_refine_normal')
# compare_implementations(unif_std_refine, unif_cuckoo_refine, unif_hopscotch_refine, 'Refinement speed, uniform distribution', 'compare_refine_unif')
# compare_implementations(exp_std_refine, exp_cuckoo_refine, exp_hopscotch_refine, 'Refinement speed, exponential distribution', 'compare_refine_exp')
compare_implementations(normal_std_search, normal_cuckoo_search, normal_hopscotch_search, 'Hledání sousedních buněk v základních směrech, normální rozdělení', 'compare_search_normal')
compare_implementations(unif_std_search, unif_cuckoo_search, unif_hopscotch_search, 'Hledání sousedních buněk v základních směrech, rovnoměrné rozdělení', 'compare_search_unif')
compare_implementations(exp_std_search, exp_cuckoo_search, exp_hopscotch_search, 'Hledání sousedních buněk v základních směrech, exponenciální rozdělení', 'compare_search_exp')

compare_implementations(normal_std_search_all, normal_cuckoo_search_all, normal_hopscotch_search_all, 'Hledání ve všech směrech, normální rozdělení', 'compare_search_all_normal')
compare_implementations(unif_std_search_all, unif_cuckoo_search_all, unif_hopscotch_search_all, 'Hledání ve všech směrech, rovnoměrné rozdělení', 'compare_search_all_unif')
compare_implementations(exp_std_search_all, exp_cuckoo_search_all, exp_hopscotch_search_all, 'Hledání ve všech směrech, exponenciální rozdělení', 'compare_search_all_exp')

compare_implementations(normal_std_refine, normal_cuckoo_refine, normal_hopscotch_refine, 'Rychlost zjemnění, normální rozdělení', 'compare_refine_normal')
compare_implementations(unif_std_refine, unif_cuckoo_refine, unif_hopscotch_refine, 'Rychlost zjemnění, rovnoměrné rozdělení', 'compare_refine_unif')
compare_implementations(exp_std_refine, exp_cuckoo_refine, exp_hopscotch_refine, 'Rychlost zjemnění, exponenciální rozdělení', 'compare_refine_exp')
```