{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Ideal time and message cost analysis for Mega-Merger: comparing theoretical results with empirical simulations" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "from pydistsim.demo_algorithms.santoro2007.mega_merger.algorithm import MegaMergerAlgorithm, ExampleParameters\n", "from pydistsim.benchmark import AlgorithmBenchmark\n", "from pydistsim.network.behavior import NetworkBehaviorModel" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Benchmarking: ideal communications\n", "\n", "For this part, we will run a battery of simulations with the help of the benchmark module.\n", "\n", "The parameters we will use are:\n", "\n", "#. The algorithm to test.\n", "\n", "#. The sizes of the networks to test.\n", "\n", "#. The number of simulations to run for each network configuration (1 for now).\n", "\n", "#. The network behavior (ideal communications obviously)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from collections import defaultdict\n", "\n", "\n", "benchmark_ideal = AlgorithmBenchmark(\n", " ((MegaMergerAlgorithm, ExampleParameters.numerical_parameters),),\n", " network_behavior=NetworkBehaviorModel.IdealCommunication,\n", " network_sizes=list(range(1, 30)) + list(range(30, 100, 10)) + list(range(100, 501, 50)),\n", " network_repeat_count=defaultdict(lambda: 1), # 1 run for every network configurations\n", ")\n", "\n", "benchmark_ideal.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "After the benchmark terminates, we can plot the results. But first, lets take a look at the raw data so we can understand\n", "what we may achieve." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Net. node count | \n", "Network type | \n", "Net. edge count | \n", "Qty. of messages sent | \n", "Qty. of messages delivered | \n", "Qty. of status changes | \n", "Qty. of steps | \n", "
|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "complete | \n", "0 | \n", "0.0 | \n", "1.0 | \n", "4.0 | \n", "3.0 | \n", "
| 1 | \n", "1 | \n", "homogeneous | \n", "0 | \n", "0.0 | \n", "1.0 | \n", "4.0 | \n", "3.0 | \n", "
| 2 | \n", "1 | \n", "hypercube | \n", "0 | \n", "0.0 | \n", "1.0 | \n", "4.0 | \n", "3.0 | \n", "
| 3 | \n", "1 | \n", "rectangular mesh | \n", "0 | \n", "0.0 | \n", "1.0 | \n", "4.0 | \n", "3.0 | \n", "
| 4 | \n", "1 | \n", "rectangular torus | \n", "1 | \n", "1.0 | \n", "2.0 | \n", "7.0 | \n", "5.0 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 260 | \n", "483 | \n", "rectangular mesh | \n", "802 | \n", "8964.0 | \n", "9146.0 | \n", "10833.0 | \n", "1215.0 | \n", "
| 261 | \n", "500 | \n", "complete | \n", "124750 | \n", "256830.0 | \n", "257033.0 | \n", "339751.0 | \n", "1423.0 | \n", "
| 262 | \n", "500 | \n", "homogeneous | \n", "10422 | \n", "28268.0 | \n", "28472.0 | \n", "32991.0 | \n", "447.0 | \n", "
| 263 | \n", "500 | \n", "ring | \n", "500 | \n", "9337.0 | \n", "9536.0 | \n", "10145.0 | \n", "2634.0 | \n", "
| 264 | \n", "500 | \n", "star | \n", "499 | \n", "3112.0 | \n", "3304.0 | \n", "4805.0 | \n", "4260.0 | \n", "
265 rows × 7 columns
\n", "