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

"Merge" buffer implementation and seriously consider introducing it into the generic SensorAgent's interface #40

Closed
BjoernLudwigPTB opened this issue Dec 18, 2019 · 11 comments
Assignees

Comments

@BjoernLudwigPTB
Copy link
Member

Max has got some implementation ready using a Python's deque und we got some in the examples. We should merge these into one residing in the master.

@BjoernLudwigPTB
Copy link
Member Author

I did some research on efficient implementations and the most straight-forward approach seems to me using Python's built-in collections.deque as @mgrub already proposed and implemented. Although, as I had in the back of my mind, a deque is not the right datatype in general, because it allows to append and to pop elements on both sides, which we actually do not want, as we discussed today, it is in this case most efficiently implemented to do these operations in almost O(1) as they state themselves, whatever this means in detail.

@mgrub well done, to come up with the proposal!

One last remark is on this before we discuss on Friday how tot tackle this issue is taken from the linked page as well:

the name is pronounced “deck” and is short for “double-ended queue"

@BjoernLudwigPTB
Copy link
Member Author

... although on second glace we might be better off for the agents with a queue.Queue which includes locking mechanisms in case several data sources are delivering measurement values at the (almost) same time (to the same buffering/queueing SensorAgent). If we can exclude this possibility in all use cases, we might stick to collections.deque but aiming for higher samping rates, we should consider this and choose carefully.

@bangxiangyong bangxiangyong added this to Sprint backlog in agentMET4FOF's progress via automation Dec 20, 2019
@BjoernLudwigPTB
Copy link
Member Author

BjoernLudwigPTB commented Dec 20, 2019

As discussed on Wednesday and on Friday this ideally includes a test implementation with a two node setup, one sender, one receiver, to visualize when frequencies get higher than processing capabilities. That means the receiver has to do some easy processing task as well. The idea is to monitor, when a buffer overflow is probable.

@bangxiangyong
Copy link
Member

bangxiangyong commented Dec 20, 2019

A suggested processing task is to compute the mean which acts as a filter

@BjoernLudwigPTB BjoernLudwigPTB removed this from Sprint backlog in agentMET4FOF's progress Jan 8, 2020
@bangxiangyong bangxiangyong added this to Sprint backlog in agentMET4FOF's progress via automation Feb 14, 2020
@bangxiangyong bangxiangyong moved this from Sprint backlog to In progress in agentMET4FOF's progress Mar 5, 2020
@BjoernLudwigPTB
Copy link
Member Author

For the implementation of the interface, especially against the background of the high-speed requirement, we should be aware that we do not necessarily have to process at 10 kHz, but could also use an aliasing agent and low-pass filter to work at lower speeds.

@BjoernLudwigPTB
Copy link
Member Author

BjoernLudwigPTB commented Mar 20, 2020

In the meantime @mgrub provided a Buffer class in PyDynamic.

@BjoernLudwigPTB BjoernLudwigPTB moved this from In progress to Review in progress in agentMET4FOF's progress Apr 3, 2020
@BjoernLudwigPTB BjoernLudwigPTB moved this from Review in progress to In progress in agentMET4FOF's progress Apr 3, 2020
@BjoernLudwigPTB BjoernLudwigPTB moved this from In progress to Review in progress in agentMET4FOF's progress Apr 3, 2020
@BjoernLudwigPTB BjoernLudwigPTB moved this from Review in progress to In progress in agentMET4FOF's progress Apr 3, 2020
@BjoernLudwigPTB BjoernLudwigPTB moved this from In progress to Review in progress in agentMET4FOF's progress Apr 3, 2020
@BjoernLudwigPTB BjoernLudwigPTB moved this from Review in progress to In progress in agentMET4FOF's progress Apr 7, 2020
@BjoernLudwigPTB BjoernLudwigPTB moved this from In progress to Review in progress in agentMET4FOF's progress Apr 7, 2020
@bangxiangyong
Copy link
Member

There are two implementations here : deque and dict to be compared -
https://github.com/bangxiangyong/agentMET4FOF/blob/develop/agentMET4FOF/develop/buffer_deque.py

@bangxiangyong bangxiangyong moved this from Review in progress to In progress in agentMET4FOF's progress Apr 24, 2020
@bangxiangyong
Copy link
Member

bangxiangyong commented Apr 24, 2020

We can abstract the buffer implementation further -
e.g
self.update_data_memory({'from':self.name,'data':sine_data})
into :
self.update_data_memory(agent_name,sine_data)

and a check for buffer filled instead of :
if len(self.memory[self.name][next(iter(self.memory[self.name]))]) >= self.buffer_size:

we can have -
self.buffer_filled()
preferably, a better way would be using decorator-

@property
def buffer_filled(self):
     ...

@bangxiangyong
Copy link
Member

bangxiangyong commented May 28, 2020

Updated the implementation for self.update_data_memory and self.buffer_filled here:

185927d

@bangxiangyong bangxiangyong moved this from In progress to Review in progress in agentMET4FOF's progress May 29, 2020
@BjoernLudwigPTB BjoernLudwigPTB moved this from Review in progress to In progress in agentMET4FOF's progress Jun 2, 2020
@bangxiangyong
Copy link
Member

Need to resolve these two tasks-

  1. Remove the buffer_deque.py from the develop folder
  2. Provide a parameter switch for the underlying mechanism : e.g "deque" , "dict"

@BjoernLudwigPTB BjoernLudwigPTB removed this from In progress in agentMET4FOF's progress Jun 2, 2020
@BjoernLudwigPTB
Copy link
Member Author

This is already resolved and thus can be closed. We introduced a neat buffer class AgentBuffer and will continue using and extending it if needed.

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

No branches or pull requests

2 participants