Skip to content
Snippets Groups Projects
Commit 1dd05b6b authored by Olivier Bertrand's avatar Olivier Bertrand
Browse files

Add compute from partial velocity

parent ec54e78b
No related branches found
No related tags found
No related merge requests found
...@@ -366,6 +366,15 @@ the agent motion, or ...@@ -366,6 +366,15 @@ the agent motion, or
self._graph.add_node(row_id, self._graph.add_node(row_id,
posorient=posor) posorient=posor)
self.mode_of_motion = mode_of_motion self.mode_of_motion = mode_of_motion
# Create a dataframe to store the velocities
convention = self._brain.renderer.rotation_convention
tuples_posvel = posorient_columns(convention)
tuples_posvel.extend(velocities_columns(convention))
index_posvel = pd.MultiIndex.from_tuples(tuples_posvel,
names=['position',
'orientation'])
self.velocities = pd.DataFrame(columns=index_posvel,
index=list(self._graph.nodes()))
@property @property
def graph(self): def graph(self):
...@@ -383,26 +392,16 @@ the agent motion, or ...@@ -383,26 +392,16 @@ the agent motion, or
timeout=1, timeout=1,
filename=None, filename=None,
blocksize=100): blocksize=100):
# Create a dataframe to store the velocities nodes_tocompute = self.velocities.isna().any(axis=1)
convention = self._brain.renderer.rotation_convention nodes_tocompute = nodes_tocompute[nodes_tocompute].index
tuples_posvel = posorient_columns(convention)
tuples_posvel.extend(velocities_columns(convention))
index_posvel = pd.MultiIndex.from_tuples(tuples_posvel,
names=['position',
'orientation'])
self.velocities = pd.DataFrame(columns=index_posvel,
index=list(self._graph.nodes()))
# Build a list of nodes # Build a list of nodes
posorients_queue = JoinableQueue() posorients_queue = JoinableQueue()
results_queue = Queue() results_queue = Queue()
if version < 2: for node in nodes_tocompute:
graph_nodes = list(self._graph.nodes())
else:
graph_nodes = list(self._graph.nodes)
for node in graph_nodes:
posorients_queue.put(self._graph.nodes[node]['posorient']) posorients_queue.put(self._graph.nodes[node]['posorient'])
# Start ndatabase loader # Start ndatabase loader
convention = self._brain.renderer.rotation_convention
num_agents = ncpu num_agents = ncpu
agents = [CyberBeeAgent(copy.copy(self._brain), agents = [CyberBeeAgent(copy.copy(self._brain),
convention=convention, convention=convention,
...@@ -421,7 +420,7 @@ the agent motion, or ...@@ -421,7 +420,7 @@ the agent motion, or
nline = 0 nline = 0
prev_nline = nline prev_nline = nline
t_start = time.time() t_start = time.time()
nbnodes = nx.number_of_nodes(self._graph) nbnodes = nodes_tocompute.shape[0]
for _ in range(nbnodes): for _ in range(nbnodes):
res = results_queue.get(timeout=timeout) res = results_queue.get(timeout=timeout)
self.velocities.loc[res.name, res.index] = res self.velocities.loc[res.name, res.index] = res
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment