mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-04-20 01:53:06 +00:00
Targeted experiments for queuing mechanism gather series into dataframe put exp_id to the CSV path revert iterations back to num_nodes/2 add missing print and decrease msg_interval_sec change param sequence for readability use struct instead of pickle for fixed-size & faster serde include dtime series into dataframe optimize: choose optimized connection type according to latency setting add skip_sending_noise option optimize filling up the queue with noises move queue_type to the end of param set, and build CSV gradually row by row fix: consider num_senders when waiting until all messages are disseminated fix: sample senders without duplicate fix: build param combinations correctly add plot script initialize MinSizeMixQueue with noises define SessionParameterSet and add paramset for session2 improve topology connectivity check to avoid "maxmimum recursions depth exceeded" error fix: the correct parameter set constructor store individual series to separate CSV files reorganize files and draw plot automatically start series file id from 1 (not 0) add queue_type CLI argument for parallelization pretty format of elapsed time pretty format of elapsed time add merge CLI and draw multiple plots split functions do not draw plot for each session use concurrent.futures to utilize multiprocessing add from_paramset argument fix: count num of finished iterations correctly draw plots for num_sent_msgs and num_senders for specific experiments
89 lines
3.0 KiB
Python
89 lines
3.0 KiB
Python
import random
|
|
from copy import deepcopy
|
|
from unittest import TestCase
|
|
|
|
from protocol.nomssip import NomssipConfig
|
|
from protocol.temporalmix import TemporalMixConfig, TemporalMixType
|
|
from queuesim.config import Config
|
|
from queuesim.paramset import (
|
|
ExperimentID,
|
|
ParameterSet,
|
|
SessionID,
|
|
build_parameter_sets,
|
|
)
|
|
from sim.config import LatencyConfig, TopologyConfig
|
|
|
|
|
|
class TestParameterSet(TestCase):
|
|
def test_apply_to_config(self):
|
|
paramset = ParameterSet(
|
|
num_nodes=10000,
|
|
peering_degree=20000,
|
|
min_queue_size=30000,
|
|
transmission_rate=40000,
|
|
num_sent_msgs=50000,
|
|
num_senders=60000,
|
|
queue_type=TemporalMixType.NOISY_COIN_FLIPPING,
|
|
num_iterations=70000,
|
|
)
|
|
config = deepcopy(SAMPLE_CONFIG)
|
|
paramset.apply_to(config)
|
|
self.assertEqual(paramset.num_nodes, config.num_nodes)
|
|
self.assertEqual(paramset.peering_degree, config.nomssip.peering_degree)
|
|
self.assertEqual(
|
|
paramset.min_queue_size, config.nomssip.temporal_mix.min_queue_size
|
|
)
|
|
self.assertEqual(
|
|
paramset.transmission_rate, config.nomssip.transmission_rate_per_sec
|
|
)
|
|
self.assertEqual(paramset.num_sent_msgs, config.num_sent_msgs)
|
|
self.assertEqual(paramset.num_senders, config.num_senders)
|
|
self.assertEqual(paramset.queue_type, config.nomssip.temporal_mix.mix_type)
|
|
|
|
def test_build_parameter_sets(self):
|
|
cases = {
|
|
(ExperimentID.EXPERIMENT_1, SessionID.SESSION_1): pow(3, 4),
|
|
(ExperimentID.EXPERIMENT_2, SessionID.SESSION_1): pow(3, 5),
|
|
(ExperimentID.EXPERIMENT_3, SessionID.SESSION_1): pow(3, 5),
|
|
(ExperimentID.EXPERIMENT_4, SessionID.SESSION_1): pow(3, 6),
|
|
(ExperimentID.EXPERIMENT_1, SessionID.SESSION_2): pow(3, 4),
|
|
}
|
|
for queue_type in TemporalMixType:
|
|
for (exp_id, session_id), expected_cnt in cases.items():
|
|
sets = build_parameter_sets(exp_id, session_id, queue_type)
|
|
self.assertEqual(expected_cnt, len(sets), f"{exp_id}: {session_id}")
|
|
# Check if all parameter sets are unique
|
|
self.assertEqual(
|
|
len(sets),
|
|
len(set(list(map(str, sets)))),
|
|
f"{exp_id}: {session_id}",
|
|
)
|
|
|
|
|
|
SAMPLE_CONFIG = Config(
|
|
num_nodes=10,
|
|
nomssip=NomssipConfig(
|
|
peering_degree=3,
|
|
transmission_rate_per_sec=10,
|
|
msg_size=8,
|
|
temporal_mix=TemporalMixConfig(
|
|
mix_type=TemporalMixType.NONE,
|
|
min_queue_size=10,
|
|
seed_generator=random.Random(0),
|
|
),
|
|
skip_sending_noise=True,
|
|
),
|
|
topology=TopologyConfig(
|
|
seed=random.Random(0),
|
|
),
|
|
latency=LatencyConfig(
|
|
min_latency_sec=0,
|
|
max_latency_sec=0,
|
|
seed=random.Random(0),
|
|
),
|
|
num_sent_msgs=1,
|
|
msg_interval_sec=0.1,
|
|
num_senders=1,
|
|
sender_generator=random.Random(0),
|
|
)
|