Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoCell size default fix #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ether/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,14 @@ def materialize(self, topology: Topology, parent=None):

class GeoCell(Cell):

def __init__(self, size, density, nodes) -> None:
def __init__(self, density, nodes, size: int = 1) -> None:
"""
Initializes the GeoCell :param density: int or Randomsampler. Used to divide the nodes in the cells :param
nodes: nodes the GeoCell will contain :param size: Number of times GeoCell will iterate over the nodes when
materializing. ATTENTION: If you want to supply your own nodes that aren't themselves generators,
this must be 1, since otherwise materialize will be called n times on your nodes, depending on what size you
choose
"""
super().__init__(nodes, size)
if isinstance(density, int):
self.density = ConstantSampler(density)
Expand All @@ -176,7 +183,7 @@ def __init__(self, size, density, nodes) -> None:
raise ValueError('unknown density type %s' % type(density))

def materialize(self, topology: Topology, parent=None):
for i in range(self.size):
for _ in range(self.size):
n = self.density.sample()

for c in self.nodes:
Expand Down
2 changes: 1 addition & 1 deletion ether/scenarios/urbansensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def create_city(self) -> GeoCell:
backhaul=MobileConnection(self.internet)
)

city = GeoCell(self.num_cells, nodes=[neighborhood], density=self.cell_density)
city = GeoCell(size=self.num_cells, nodes=[neighborhood], density=self.cell_density)

return city

Expand Down
2 changes: 1 addition & 1 deletion examples/urbansensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def main():
shared_bandwidth=500,
backhaul=MobileConnection('internet_chix'))
city = GeoCell(
5, nodes=[neighborhood], density=lognorm((0.82, 2.02)))
size=5, nodes=[neighborhood], density=lognorm((0.82, 2.02)))
cloudlet = Cloudlet(
5, 2, backhaul=FiberToExchange('internet_chix'))

Expand Down
2 changes: 1 addition & 1 deletion examples/vivaldi/urban_sensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_edge_broker() -> Broker:
nodes=[[aot_node] * size, [edge_broker_factory_with_region(region)]],
backhaul=MobileConnection(region)
)
city = GeoCell(5, nodes=[neighborhood], density=lognorm((0.82, 2.02)))
city = GeoCell(size=5, nodes=[neighborhood], density=lognorm((0.82, 2.02)))
topology.add(city)

broker = Broker(f'cloud-broker_{region}', backhaul=region)
Expand Down