Commit History

Updated lines 654-669 with: LaTeX formulation vis-a-vis proper delimiters ‘$$'
1321038
verified

TroglodyteDerivations commited on

Updated lines 488 and 619 with: iterations=[0, 2, 8, 10]
27849a1
verified

TroglodyteDerivations commited on

Updated lines 488 and 619 with: iterations=[0, 25, 75, 190])
9fd13ad
verified

TroglodyteDerivations commited on

Updated lines 488 and 619 with: iterations=[0, 2, 8,13]
bc48298
verified

TroglodyteDerivations commited on

Updated lines 488 and 619 with: (iterations=[0,2,8,12])
683a4ca
verified

TroglodyteDerivations commited on

Updated indentation on line 535 with: X, Y = np.meshgrid(x_range, y_range)
61a0673
verified

TroglodyteDerivations commited on

Updated with plot_positions, plot_3d_meshgrid_contour methods, optimize function leveraging the functionality spawning from the methods, and created the gr.components.Image functionality fostering the visualizations populating
a82f0ee
verified

TroglodyteDerivations commited on

Updated with hashtag removal on lines 537, 521, and 514
2b1d24e
verified

TroglodyteDerivations commited on

Updated with removal of hashtag on line 536. And hashtag removal on line 511
d84e707
verified

TroglodyteDerivations commited on

Updated with hashtags on the dispersion_plot and dispersion_heatmap_plot. Updated lines 505 and 508 with: best_positions_array = np.load('best_positions_array.npy') , plot_contour_and_wolves = gwo.plot_contour_and_wolves(best_positions_array)
d1e7472
verified

TroglodyteDerivations commited on

Updated line 505 with: best_positions_1D = np.load('best_positions.npy’). And line 508 with: plot_contour_and_wolves = gwo.plot_contour_and_wolves(best_positions_1D)
f171125
verified

TroglodyteDerivations commited on

Updated line 521 with: return [plot_contour_and_wolves, dispersion_plot, dispersion_heatmap_plot], best_fitness_text, best_positions_text, best_fitness_npy, best_positions_npy, dispersion_text
857672c
verified

TroglodyteDerivations commited on

Updated line 521 with: return [plot_contour_and_wolves_plot, dispersion_plot, dispersion_heatmap_plot], best_fitness_text, best_positions_text, best_fitness_npy, best_positions_npy, dispersion_text
1a696e5
verified

TroglodyteDerivations commited on

Updated lines 344-346 with: best_positions_1D = np.load('best_positions.npy') wolf_positions = best_positions_1D
6e16c34
verified

TroglodyteDerivations commited on

Updated the optimize method with removal of contour_plot functionality. Updated plot_contour_and_wolves method lines 344-346 with: best_positions_loaded_array = np.load('best_positions_array.npy') wolf_positions = best_positions_loaded_array. And modified the optimize function with: # Load best_positions_loaded_array best_positions_loaded_array = np.load('best_positions_array.npy') # Plot the contour_and_wolves plot_contour_and_wolves = gwo.plot_contour_and_wolves(best_positions_loaded_array) Removed the contour_plot from gwo.optimize also only the other two variables remain
0d0f645
verified

TroglodyteDerivations commited on

Updated lines 490-515 with: def optimize(npart, ndim, max_iter): # Initialize the GWO algorithm with the provided parameters gwo = GWO(obj=obj, npart=npart, ndim=ndim, max_iter=max_iter, init=init, bounds=bounds) best_positions, best_fitness, contour_plot = gwo.optimize() # Convert best_fitness and best_positions to NumPy arrays if necessary best_fitness_npy = np.array(best_fitness) best_positions_npy = np.array(best_positions) # Calculate dispersion dispersion = gwo.Dispersion() dispersion_text = f"Dispersion: {dispersion}" # Plot the dispersion over time dispersion_plot = gwo.plot_dispersion() # Plot the dispersion heatmap dispersion_heatmap_plot = gwo.plot_dispersion_heatmap(x_range=(-6,6), y_range=(-6,6)) # Format the output strings best_fitness_text = f"Best Fitness: {best_fitness_npy}" best_positions_text = f"Best Positions: {best_positions_npy}" # Return the images and text return [contour_plot, dispersion_plot, dispersion_heatmap_plot], best_fitness_text, best_positions_text, best_fitness_npy, best_positions_npy, dispersion_text
a13d33d
verified

TroglodyteDerivations commited on

Updated line 506 with: contour_plot = gwo.plot_contour_and_wolves(best_positions_array)
daa9a67
verified

TroglodyteDerivations commited on

Updated lines 343-346 with: # Ensure wolf_positions is a 2D array wolf_positions = np.array(wolf_positions) if wolf_positions.ndim == 1: wolf_positions = wolf_positions.reshape(-1, 1)
43da5b2
verified

TroglodyteDerivations commited on

Updated lines 204-234 with: def optimize(self): """ Run a full optimization and return the best positions and fitness values. This method is designed to be used with Gradio. """ # Initialize the swarm self.Initialize() # Lists to store the best positions and fitness values at each step best_positions = [] best_fitness = [] # Main loop while not self.Done(): self.Step() # Perform an optimization step # Update best_positions and best_fitness with the current best values best_positions.append(self.gbest[-1]) best_fitness.append(self.gpos[-1]) # Convert the list of best positions to a NumPy array best_positions_array = np.array(best_positions) # Get the contour plot as a PIL Image contour_plot = self.plot_contour_and_wolves(best_positions_array) # Print the best positions and fitness found print("Best Positions:", best_positions) print("Best Fitness:", best_fitness) # Return the best positions and fitness after the optimization return best_positions, best_fitness, contour_plot
f6c3b05
verified

TroglodyteDerivations commited on

Updated lines 340-341 with: best_positions_npy = np.load(‘best_positions.npy’) [removed] and wolf_positions = best_positions_npy [removed]. Generating a PIL Image population deriving from gr.components.Image()
f6c286c
verified

TroglodyteDerivations commited on

Ignore previous notation. Updated lines 488, 495, 499, 502 and 505 with: gwo . Also, udated line 516 with: return [contour_plot, dispersion_plot, dispersion_heatmap_plot], best_fitness_text, best_positions_text, best_fitness_npy, best_positions_npy, dispersion_text
759703a
verified

TroglodyteDerivations commited on

Updated lines 488, 499, 502, 505 with: # Initialize the GWO algorithm with the provided parameters gwo = GWO(obj=obj, npart=npart, ndim=ndim, max_iter=max_iter, init=init, bounds=bounds)
5676e8a
verified

TroglodyteDerivations commited on

Updated lines 486-487 with: # Initialize the GWO algorithm with the provided parameters gwo = GWO(obj=obj, npart=npart, ndim=ndim, max_iter=max_iter, init=init, bounds=bounds).
3c2f31a
verified

TroglodyteDerivations commited on

Updated lines 483 and 485 with: def optimize(npart, ndim, max_iter): and best_positions, best_fitness = gwo.optimize()
6677a7e
verified

TroglodyteDerivations commited on

Updated lines 483-516 with: new optimize function modifications
aaddb17
verified

TroglodyteDerivations commited on

Updated lines 515-517 with: # Load the best fitness and positions from .npy files, best_fitness_npy = np.load('best_fitness.npy’), best_positions_npy = np.load('best_positions.npy')
7225605
verified

TroglodyteDerivations commited on

Updated line 517 with: removal of best_fitness_npy, best_positions_npy,
2c51a89
verified

TroglodyteDerivations commited on

Updated line 414 with: dispersion_values = np.array([self.Dispersion() for _ in positions]) [plot_dispersion_heatmap] method
06a4769
verified

TroglodyteDerivations commited on

Updated line 4 with: from matplotlib.colors import LogNorm Updated lines 453-479 with: def plot_dispersion_heatmap(self, x_range, y_range, resolution=100): # Create a grid of points within the specified range x = np.linspace(*x_range, resolution) y = np.linspace(*y_range, resolution) X, Y = np.meshgrid(x, y) positions = np.vstack([X.ravel(), Y.ravel()]).T # Calculate the dispersion for each position in the grid dispersion_values = np.array([self.Dispersion(pos) for pos in positions]) Z = dispersion_values.reshape(X.shape) # Plot the dispersion heatmap plt.figure(figsize=(10, 8)) plt.pcolormesh(X, Y, Z, cmap='viridis', norm=LogNorm()) plt.colorbar(label='Dispersion') # Set plot title and labels plt.title('Dispersion Heatmap') plt.xlabel('x') plt.ylabel('y') # Convert the plot to a PIL Image and return it buf = BytesIO() plt.savefig(buf, format='png') buf.seek(0) plt.close() # Close the figure to free up memory return Image.open(buf)
ae445de
verified

TroglodyteDerivations commited on

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
fe5d3f2
verified

TroglodyteDerivations commited on

Updated lines 388-392 with: def Dispersion(self): # """Calculate the dispersion of the swarm""" dispersion = np.std(self.gpos[:, 0]) + np.std(self.gpos[:, 1]) return dispersion
7c78869
verified

TroglodyteDerivations commited on

Updated line 340 with: best_positions_npy = np.load('best_positions.npy’). Updated line 358 with: contour = plt.contour(X, Y, Z, levels=20, cmap='magma’). Updated line 455 with: contour_plot = gwo.plot_contour_and_wolves(best_positions)
70cbdc1
verified

TroglodyteDerivations commited on