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
self._graph.add_node(row_id,
posorient=posor)
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
def graph(self):
......@@ -383,26 +392,16 @@ the agent motion, or
timeout=1,
filename=None,
blocksize=100):
# 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()))
nodes_tocompute = self.velocities.isna().any(axis=1)
nodes_tocompute = nodes_tocompute[nodes_tocompute].index
# Build a list of nodes
posorients_queue = JoinableQueue()
results_queue = Queue()
if version < 2:
graph_nodes = list(self._graph.nodes())
else:
graph_nodes = list(self._graph.nodes)
for node in graph_nodes:
for node in nodes_tocompute:
posorients_queue.put(self._graph.nodes[node]['posorient'])
# Start ndatabase loader
convention = self._brain.renderer.rotation_convention
num_agents = ncpu
agents = [CyberBeeAgent(copy.copy(self._brain),
convention=convention,
......@@ -421,7 +420,7 @@ the agent motion, or
nline = 0
prev_nline = nline
t_start = time.time()
nbnodes = nx.number_of_nodes(self._graph)
nbnodes = nodes_tocompute.shape[0]
for _ in range(nbnodes):
res = results_queue.get(timeout=timeout)
self.velocities.loc[res.name, res.index] = res
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment