TroglodyteDerivations
commited on
Commit
•
fe5d3f2
1
Parent(s):
7c78869
Updated lines 393-403 with: def Dispersion(self): """Calculate the dispersion of the swarm""" # Ensure self.gpos is a NumPy array if not isinstance(self.gpos, np.ndarray): self.gpos = np.array(self.gpos) # Now self.gpos should be a NumPy array, so we can calculate the dispersion x, y = self.gpos[:, 0], self.gpos[:, 1] dx = x.max() - x.min() dy = y.max() - y.min() return (dx + dy) / 2.0
Browse files
app.py
CHANGED
@@ -385,10 +385,22 @@ class GWO:
|
|
385 |
#dy = y.max() - y.min()
|
386 |
#return (dx + dy) / 2.0
|
387 |
|
388 |
-
def Dispersion(self):
|
389 |
# """Calculate the dispersion of the swarm"""
|
390 |
-
dispersion = np.std(self.gpos[:, 0]) + np.std(self.gpos[:, 1])
|
391 |
-
return dispersion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
def plot_dispersion(self):
|
394 |
"""Plot the dispersion over time"""
|
|
|
385 |
#dy = y.max() - y.min()
|
386 |
#return (dx + dy) / 2.0
|
387 |
|
388 |
+
#def Dispersion(self):
|
389 |
# """Calculate the dispersion of the swarm"""
|
390 |
+
#dispersion = np.std(self.gpos[:, 0]) + np.std(self.gpos[:, 1])
|
391 |
+
#return dispersion
|
392 |
+
|
393 |
+
def Dispersion(self):
|
394 |
+
"""Calculate the dispersion of the swarm"""
|
395 |
+
# Ensure self.gpos is a NumPy array
|
396 |
+
if not isinstance(self.gpos, np.ndarray):
|
397 |
+
self.gpos = np.array(self.gpos)
|
398 |
+
|
399 |
+
# Now self.gpos should be a NumPy array, so we can calculate the dispersion
|
400 |
+
x, y = self.gpos[:, 0], self.gpos[:, 1]
|
401 |
+
dx = x.max() - x.min()
|
402 |
+
dy = y.max() - y.min()
|
403 |
+
return (dx + dy) / 2.0
|
404 |
|
405 |
def plot_dispersion(self):
|
406 |
"""Plot the dispersion over time"""
|