mirror of
https://github.com/logos-storage/das-research.git
synced 2026-01-11 01:23:08 +00:00
Visualize all 4 types of gossipSub distribution
This commit is contained in:
parent
b079fcbedb
commit
aff7215c08
28
collage.sh
Executable file
28
collage.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: collage.sh
|
||||
#
|
||||
# USAGE: ./collage.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
#
|
||||
# OPTIONS: ---
|
||||
# REQUIREMENTS: ---
|
||||
# BUGS: ---
|
||||
# NOTES: ---
|
||||
# AUTHOR: (),
|
||||
# COMPANY:
|
||||
# VERSION: 1.0
|
||||
# CREATED: 06/11/23 16:53:46 CET
|
||||
# REVISION: ---
|
||||
#===============================================================================
|
||||
|
||||
for i in {1..50..1}
|
||||
do
|
||||
ffmpeg -pattern_type glob -i "frames/*Cust$i.png" -filter_complex "scale=900:900,tile=4x1" frames/output$i.png
|
||||
done
|
||||
|
||||
cp frames/output1.png frames/output.png
|
||||
|
||||
ffmpeg -i frames/output%d.png -frames 49 -loop 2 frames/output.gif
|
||||
128
sfcDAS.py
128
sfcDAS.py
@ -6,24 +6,24 @@ from random import *
|
||||
dimension = 2
|
||||
|
||||
def plotMatrix(matrix, fileName):
|
||||
fig = px.imshow(matrix)
|
||||
fig = px.imshow(matrix, color_continuous_scale="hot")
|
||||
fig.update_xaxes(side="top")
|
||||
fig.update_layout(height=700, width=700)
|
||||
fig.write_image(fileName)
|
||||
|
||||
|
||||
def expandMatrix(matrix, expandIndex):
|
||||
def expandMatrix(newMatrix, matrix, expandIndex):
|
||||
xlen = len(matrix)
|
||||
ylen = len(matrix[0])
|
||||
#print(f'x = {xlen} y = {ylen}')
|
||||
newMatrix = np.zeros((xlen * expandIndex, ylen * expandIndex))
|
||||
for i in range(xlen * expandIndex):
|
||||
for j in range(ylen * expandIndex):
|
||||
newMatrix[i][j] = matrix[int(i/expandIndex)][int(j/expandIndex)]
|
||||
if matrix[int(i/expandIndex)][int(j/expandIndex)] > 0:
|
||||
newMatrix[i][j] = matrix[int(i/expandIndex)][int(j/expandIndex)]
|
||||
return newMatrix
|
||||
|
||||
|
||||
def doHilbert(depth, custSize, DASsize):
|
||||
def doHilbert(hilbMatrix, depth, custSize, DASsize, nbVal):
|
||||
|
||||
# Compute Hilbert curve
|
||||
HdistMatrix = np.zeros((2**depth, 2**depth))
|
||||
@ -33,80 +33,96 @@ def doHilbert(depth, custSize, DASsize):
|
||||
points = Hcurve.points_from_distances(distances)
|
||||
|
||||
# Compute custody tiles
|
||||
custList = []
|
||||
startPosition = randint(0, 2**(depth*2))
|
||||
for i in range(custSize):
|
||||
custList.append((startPosition+i)%(2**(depth*2)))
|
||||
print(f'Start position = {startPosition}')
|
||||
for point, dist in zip(points, distances):
|
||||
j, i = point
|
||||
HdistMatrix[i][j] = dist
|
||||
if dist in custList:
|
||||
HcustMatrix[i][j] = 1
|
||||
for v in range(nbVal):
|
||||
custList = []
|
||||
startPosition = randint(0, (2**(depth*2))-1)
|
||||
for i in range(custSize):
|
||||
custList.append((startPosition+i)%(2**(depth*2)))
|
||||
#print(f'Start position = {startPosition}')
|
||||
for point, dist in zip(points, distances):
|
||||
j, i = point
|
||||
HdistMatrix[i][j] = dist
|
||||
if dist in custList:
|
||||
HcustMatrix[i][j] = v+1
|
||||
#print(HdistMatrix)
|
||||
#print(HcustMatrix)
|
||||
|
||||
# From Hilbert curve depth to DAS size
|
||||
HcustMatrix = expandMatrix(HcustMatrix, int(DASsize/(2**depth)))
|
||||
HcustMatrix = expandMatrix(hilbMatrix, HcustMatrix, int(DASsize/(2**depth)))
|
||||
|
||||
return(HcustMatrix)
|
||||
return(hilbMatrix)
|
||||
|
||||
|
||||
def doTile(depth, custSize, DASsize):
|
||||
tileMatrix = np.zeros((2**depth, 2**depth))
|
||||
for i in range(custSize):
|
||||
tileMatrix[randint(0, 2**depth)][randint(0, 2**depth)] = 1
|
||||
tileMatrix = expandMatrix(tileMatrix, int(DASsize/(2**depth)))
|
||||
def doTile(tileMatrix, depth, custSize, DASsize, nbVal):
|
||||
ttMatrix = np.zeros((2**depth, 2**depth))
|
||||
for v in range(nbVal):
|
||||
for i in range(custSize):
|
||||
ttMatrix[randint(0, (2**depth)-1)][randint(0, (2**depth)-1)] = v+1
|
||||
tileMatrix = expandMatrix(tileMatrix, ttMatrix, int(DASsize/(2**depth)))
|
||||
return(tileMatrix)
|
||||
|
||||
|
||||
def doRowCol(custSize, DASsize):
|
||||
custList = []
|
||||
for x in range(custSize):
|
||||
custList.append(randint(0, DASsize))
|
||||
half = int(custSize/2)
|
||||
rows = custList[:half]
|
||||
cols = custList[half:]
|
||||
matrix = np.zeros((DASsize, DASsize))
|
||||
for r in rows:
|
||||
for x in range(DASsize):
|
||||
matrix[r][x] = 1
|
||||
for c in cols:
|
||||
for x in range(DASsize):
|
||||
matrix[x][c] = 1
|
||||
def doRowCol(matrix, custSize, DASsize, nbVal):
|
||||
for v in range(nbVal):
|
||||
custList = []
|
||||
for x in range(custSize):
|
||||
custList.append(randint(0, DASsize-1))
|
||||
half = int(custSize/2)
|
||||
rows = custList[:half]
|
||||
cols = custList[half:]
|
||||
for r in rows:
|
||||
for x in range(DASsize):
|
||||
matrix[r][x] = v+1
|
||||
for c in cols:
|
||||
for x in range(DASsize):
|
||||
matrix[x][c] = v+1
|
||||
return(matrix)
|
||||
|
||||
|
||||
def doDiagonal(custSize, DASsize):
|
||||
custList = []
|
||||
for x in range(custSize):
|
||||
custList.append(randint(0, DASsize))
|
||||
matrix = np.zeros((DASsize, DASsize))
|
||||
for c in custList:
|
||||
cc = c
|
||||
for x in range(DASsize):
|
||||
matrix[x][cc] = 1
|
||||
cc = (cc + 1) % DASsize
|
||||
def doDiagonal(matrix, custSize, DASsize, nbVal):
|
||||
for v in range(nbVal):
|
||||
custList = []
|
||||
for x in range(custSize):
|
||||
custList.append(randint(0, DASsize-1))
|
||||
for c in custList:
|
||||
cc = c
|
||||
for x in range(DASsize):
|
||||
matrix[x][cc] = v+1
|
||||
cc = (cc + 1) % DASsize
|
||||
return(matrix)
|
||||
|
||||
|
||||
|
||||
|
||||
custStart = 4
|
||||
custStop = 39
|
||||
custStep = 4
|
||||
cs = 4
|
||||
nbVal = 10
|
||||
depth = 5
|
||||
custSize = 4
|
||||
DASsize = 512
|
||||
totalVal = 0
|
||||
|
||||
HilbertMatrix = doHilbert(depth, custSize, DASsize)
|
||||
plotMatrix(HilbertMatrix, "hilbertCust.png")
|
||||
diagMatrix = np.zeros((DASsize, DASsize))
|
||||
rocoMatrix = np.zeros((DASsize, DASsize))
|
||||
tileMatrix = np.zeros((DASsize, DASsize))
|
||||
hilbMatrix = np.zeros((DASsize, DASsize))
|
||||
|
||||
rowColMatrix = doRowCol(custSize, DASsize)
|
||||
plotMatrix(rowColMatrix, "rowColCust.png")
|
||||
for i in range(50):
|
||||
nbVal = 5
|
||||
totalVal += nbVal
|
||||
print(f'Number of validators: {totalVal}')
|
||||
|
||||
diagonalMatrix = doDiagonal(custSize, DASsize)
|
||||
plotMatrix(diagonalMatrix, "diagonalCust.png")
|
||||
HilbertMatrix = doHilbert(hilbMatrix, depth, cs, DASsize, nbVal)
|
||||
plotMatrix(HilbertMatrix, "frames/4hilbertCust"+str(i)+".png")
|
||||
|
||||
tileMatrix = doTile(depth, custSize, DASsize)
|
||||
plotMatrix(tileMatrix, "tileCust.png")
|
||||
rowColMatrix = doRowCol(rocoMatrix, cs, DASsize, nbVal)
|
||||
plotMatrix(rowColMatrix, "frames/1rowColCust"+str(i)+".png")
|
||||
|
||||
diagonalMatrix = doDiagonal(diagMatrix, cs, DASsize, nbVal )
|
||||
plotMatrix(diagonalMatrix, "frames/2diagonalCust"+str(i)+".png")
|
||||
|
||||
tileMatrix = doTile(tileMatrix, depth, cs, DASsize, nbVal)
|
||||
plotMatrix(tileMatrix, "frames/3tileCust"+str(i)+".png")
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user