Skip to content

Instantly share code, notes, and snippets.

@aletelecom
Created July 23, 2022 02:22
Show Gist options
  • Save aletelecom/79c679948ff636e2e3446c54976536b3 to your computer and use it in GitHub Desktop.
Save aletelecom/79c679948ff636e2e3446c54976536b3 to your computer and use it in GitHub Desktop.
New OLT class for viz 2
class OLT:
""" Define a class OLT that have the following attributes:
- An "int" Board quantity (slot_qty) which represent the maximun slot count that the OLT has.
- An "int" Port quantity per slot (port_per_slot) which represent the maximun port count per slot that the OLT has.
- An "int" Maximun client quantity per pon port (max_client_qty) which represent the maximun client count per port per slot that the OLT has. """
def __init__(self, slot_qty=16, port_per_slot=16):
self.slot_qty = slot_qty
self.port_per_slot = port_per_slot
# Then we define a method that will create and populate each pon port of the OLT instance with a client quantity
def create_olt_and_populate(self, max_client_qty, speeds):
# We assign the model of the OLT at random, during the creation
models = ['Model_A', 'Model_B', 'Model_C', 'Model_D']
model = choice(models)
# We define a list as population, to add to it the information as tuples (slot, port, client_qty, model)
population = []
slot_port_tuples = [(slot, port) for slot, port in product(range(1,self.slot_qty+1), range(1,self.port_per_slot+1))]
for tupla in slot_port_tuples:
clients = randint(0,max_client_qty)
speed = [(clients * choice(speeds))/15 if clients > 0 else 0]
population.append(tupla + (clients, *speed, model))
# Then we create and return a Pandas DataFrame, in which each row represents "a PON port" with its information
df = pd.DataFrame(population, columns=['slot', 'port', 'client_qty', 'ocupation_%', 'model'])
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment