Skip to content

energy model - #5

Open
grimmfl wants to merge 2 commits into
gh0st42:masterfrom
grimmfl:feature/energy
Open

grimmfl wants to merge 2 commits into
gh0st42:masterfrom
grimmfl:feature/energy

Conversation

@grimmfl

@grimmfl grimmfl commented Oct 22, 2023

Copy link
Copy Markdown
Contributor

No description provided.

@gh0st42 gh0st42 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work!
I left some remarks..
maybe you can also add some central logging to indicate when a node goes out of power (once)

Comment thread pons/energy.py
def __repr__(self) -> str:
return str(self)

def on_receive(self):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function name should match the one in node.py from where it is called, e.g., on_recv

Comment thread pons/energy.py
"""handling message receive"""
self.energy -= self._receive

def on_forward(self):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function name should match the one in node.py from where it is called, e.g., on_send
forwarding is something from the routing side, on the lower levels its just a transmission that consumes energy

Comment thread pons/energy.py

def on_receive(self):
"""handling message receive"""
self.energy -= self._receive

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the transmission time? sending costs a specific amount of energy per time. so a large chunk of data might need several minutes and thus should consume more power

Comment thread pons/energy.py

def on_forward(self):
"""handling message forward"""
self.energy -= self._forward

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the transmission time? sending costs a specific amount of energy per time. so a large chunk of data might need several minutes and thus should consume more power

Comment thread pons/energy.py
self.max_energy: float = max_energy
self._idle: float = idle
self._receive: float = receive
self._forward: float = forward

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be sending or tx

Comment thread pons/node.py
net = []
if energy_model is None:
energy_model = pons.DefaultEnergyModel()
if isinstance(energy_model, pons.EnergyModel):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe some errorhandling here would be nice with user feedback

self.store_add(msg)
if msg.dst == self.my_id:
# self.log("msg arrived", self.my_id)
# print("msg arrived", self.my_id)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you replace the central logging with a print statement?

Comment thread pons/routing/router.py
def scan(self):
while True:
node = self.netsim.nodes[self.my_id]
while node.energy_model.energy > 0:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have this check here? isn't it enough to have an energy check in the send and receive functions of node.py so the router or any other upper layers are not relevant any more? ofc the scan loop can also contain the check to avoid some CPU cycles but deactivating the node functions is the safe bet to ensure that no further communication happens

Comment thread pons/routing/router.py
yield self.env.timeout(self.scan_interval)

def on_scan_received(self, msg: pons.Message, remote_id: int):
if self.netsim.nodes[self.my_id].energy_model.energy <= 0:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have this check here? isn't it enough to have an energy check in the send and receive functions of node.py so the router or any other upper layers are not relevant any more? ofc the scan loop can also contain the check to avoid some CPU cycles but deactivating the node functions is the safe bet to ensure that no further communication happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants