mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-01-15 11:33:10 +00:00
beautify
This commit is contained in:
parent
8eb8eb30d1
commit
9f95b0a29a
@ -219,10 +219,9 @@ def views(ctx: typer.Context,
|
||||
help="Set the output prefix for the plots")
|
||||
):
|
||||
|
||||
print("here 1 ")
|
||||
log.basicConfig(level=log.INFO)
|
||||
#nwsize2vfins = compute_view_times(path, oprefix)
|
||||
#write_dict(nwsize2vfins, f'{oprefix}-viewtimes.dict')
|
||||
nwsize2vfins = compute_view_times(path, oprefix)
|
||||
write_dict(nwsize2vfins, f'{oprefix}-viewtimes.dict')
|
||||
|
||||
print("reading ")
|
||||
nwsize2vfins = read_dict(f'{oprefix}-viewtimes.dict')
|
||||
|
||||
@ -8,19 +8,19 @@ from build_config import build_config
|
||||
def build_case(overlay, committees, nodes, config_name, max_view=1, network='default'):
|
||||
build_config(overlay, committees, nodes, config_name, max_view, network)
|
||||
# rename the runs with same configs
|
||||
modified_name = config_name
|
||||
if os.path.exists(f"../configs/{config_name}.json"):
|
||||
tail = random.randint(1, 10000)
|
||||
modified_name = f"{config_name}_{tail}"
|
||||
os.rename(f"{config_name}.json", f"{modified_name}.json")
|
||||
with open(f"{modified_name}.json", "r+") as f:
|
||||
data = json.load(f)
|
||||
data["stream_settings"]["path"] = f"{modified_name}.json"
|
||||
f.seek(0)
|
||||
json.dump(data, f)
|
||||
f.truncate()
|
||||
print(f"config clash: renaming {config_name} to {modified_name}")
|
||||
config_name = modified_name
|
||||
shutil.move(f"{config_name}.json", "../configs/")
|
||||
print(f"name clash: renaming {config_name}.json to {modified_name}.json")
|
||||
with open(f"{config_name}.json", "r+") as f:
|
||||
data = json.load(f)
|
||||
data["stream_settings"]["path"] = f"output/{modified_name}.csv"
|
||||
f.seek(0)
|
||||
json.dump(data, f, indent=4)
|
||||
f.truncate()
|
||||
os.rename(f"{config_name}.json", f"{modified_name}.json")
|
||||
shutil.move(f"{modified_name}.json", "../configs/")
|
||||
|
||||
def build_cases(csv_path):
|
||||
with open(csv_path, 'r') as csv_file:
|
||||
|
||||
@ -73,14 +73,12 @@ def main(ctx: typer.Context,
|
||||
failure_threshold,
|
||||
CARNOT_ADVERSARY_THRESHOLD_PER_COMMITTEE,
|
||||
CARNOT_NETWORK_ADVERSARY_THRESHOLD)
|
||||
tree_depth= int(math.log(num_comm, 2)) if num_comm > 1 else 1
|
||||
tree_depth= math.ceil(math.log(num_comm, 2)) if num_comm > 1 else 1
|
||||
num_nodes_branch= tree_depth * comm_size
|
||||
'''
|
||||
print(
|
||||
f"num_nodes={num_nodes}, "
|
||||
f"total_tree_nodes={num_comm}, comm_size={comm_size}, remainder={remainder}, computed={prob:f}(req={failure_threshold:f}), depth={tree_depth}"
|
||||
)
|
||||
'''
|
||||
tree_spec = f"tree,{num_nodes},{comm_size},"
|
||||
branch_spec = f"branch,{num_nodes_branch},{tree_depth},"
|
||||
|
||||
|
||||
@ -1,12 +1,20 @@
|
||||
|
||||
#for i in "10 100 200 300 400 500 600 700 800 900 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000"
|
||||
#for i in "10 100 200 300 400 500 600 700 800 900 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
|
||||
|
||||
prefix="compare"
|
||||
for p in 0.8 0.5 #0.1 0.01 0.001 0.0001
|
||||
|
||||
probabilities="0.8 0.01"
|
||||
network_sizes="10 50 100 250 500 750 1000"
|
||||
|
||||
#probabilities="0.8 0.5 0.1 0.01 0.001 0.0001"
|
||||
#network_sizes="10 50 100 250 500 750 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 12000 1400"
|
||||
|
||||
for p in $probabilities
|
||||
do
|
||||
dir="compare_"$p"/"
|
||||
mkdir -p $dir
|
||||
echo "overlay,nodes,committees_or_depth,description" > $dir$prefix"_"$p".csv"
|
||||
for i in 10 50 100 250 500 750 #1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 12000 1400
|
||||
for i in $network_sizes
|
||||
do
|
||||
python3 build_tests.py --num-nodes $i --failure-threshold $p >> $dir$prefix"_"$p".csv"
|
||||
echo "num-nodes = $i, failure-threshold = $p"
|
||||
@ -15,7 +23,7 @@ done
|
||||
|
||||
|
||||
|
||||
for p in 0.8 0.5 #0.1 0.01 0.001 0.0001
|
||||
for p in $probabilities
|
||||
do
|
||||
dir="compare_"$p"/"
|
||||
cd $dir
|
||||
@ -32,16 +40,21 @@ done
|
||||
|
||||
|
||||
|
||||
for p in 0.8 0.5 #0.1 0.01 0.001 0.0001
|
||||
for p in $probabilities
|
||||
do
|
||||
dir="compare_"$p"/"
|
||||
cd $dir
|
||||
pwd
|
||||
ls -l output/*.json | awk '{print $9}' > json_files
|
||||
sed -e s/\.json//g -i json_files
|
||||
for i in `cat json_files`
|
||||
do
|
||||
mv $i.json $i.csv
|
||||
done
|
||||
# renaming moved to `build_cases.py`
|
||||
if ls output/*.json 1> /dev/null 2>&1; then
|
||||
echo "json extension in output dir; need to rename"
|
||||
ls -l output/*.json | awk '{print $9}' > json_files
|
||||
sed -e s/\.json//g -i json_files
|
||||
for i in `cat json_files`
|
||||
do
|
||||
mv $i.json $i.csv
|
||||
done
|
||||
fi
|
||||
rm -rf scripts
|
||||
cd ..
|
||||
echo "renaming/cleanup ($p) done.."
|
||||
done
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user