TroglodyteDerivations commited on
Commit
3c2f31a
1 Parent(s): 6677a7e

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).

Browse files
Files changed (1) hide show
  1. app.py +24 -21
app.py CHANGED
@@ -481,36 +481,39 @@ class GWO:
481
 
482
 
483
  def optimize(npart, ndim, max_iter):
 
 
 
484
 
485
- best_positions, best_fitness = gwo.optimize()
486
 
487
- # Convert best_fitness and best_positions to NumPy arrays if necessary
488
- best_fitness_npy = np.array(best_fitness)
489
- best_positions_npy = np.array(best_positions)
490
 
491
- # Calculate dispersion
492
- dispersion = self.Dispersion()
493
- dispersion_text = f"Dispersion: {dispersion}"
494
 
495
- # Get the contour plot as a PIL Image
496
- contour_plot = self.plot_contour_and_wolves(best_positions)
497
 
498
- # Plot the dispersion over time
499
- dispersion_plot = self.plot_dispersion()
500
 
501
- # Plot the dispersion heatmap
502
- dispersion_heatmap_plot = self.plot_dispersion_heatmap(x_range=(-6,6), y_range=(-6,6))
503
 
504
- # Load the best fitness and positions from .npy files
505
- best_fitness_npy = np.load('best_fitness.npy')
506
- best_positions_npy = np.load('best_positions.npy')
507
 
508
- # Format the output strings
509
- best_fitness_text = f"Best Fitness: {best_fitness_npy}"
510
- best_positions_text = f"Best Positions: {best_positions_npy}"
511
 
512
- # Return the images and text
513
- return [contour_plot, dispersion_plot, dispersion_heatmap_plot], best_fitness_text, best_positions_text, dispersion_text
514
 
515
 
516
 
 
481
 
482
 
483
  def optimize(npart, ndim, max_iter):
484
+
485
+ # Initialize the GWO algorithm with the provided parameters
486
+ gwo = GWO(obj=obj, npart=npart, ndim=ndim, max_iter=max_iter, init=init, bounds=bounds)
487
 
488
+ best_positions, best_fitness = gwo.optimize()
489
 
490
+ # Convert best_fitness and best_positions to NumPy arrays if necessary
491
+ best_fitness_npy = np.array(best_fitness)
492
+ best_positions_npy = np.array(best_positions)
493
 
494
+ # Calculate dispersion
495
+ dispersion = self.Dispersion()
496
+ dispersion_text = f"Dispersion: {dispersion}"
497
 
498
+ # Get the contour plot as a PIL Image
499
+ contour_plot = self.plot_contour_and_wolves(best_positions)
500
 
501
+ # Plot the dispersion over time
502
+ dispersion_plot = self.plot_dispersion()
503
 
504
+ # Plot the dispersion heatmap
505
+ dispersion_heatmap_plot = self.plot_dispersion_heatmap(x_range=(-6,6), y_range=(-6,6))
506
 
507
+ # Load the best fitness and positions from .npy files
508
+ best_fitness_npy = np.load('best_fitness.npy')
509
+ best_positions_npy = np.load('best_positions.npy')
510
 
511
+ # Format the output strings
512
+ best_fitness_text = f"Best Fitness: {best_fitness_npy}"
513
+ best_positions_text = f"Best Positions: {best_positions_npy}"
514
 
515
+ # Return the images and text
516
+ return [contour_plot, dispersion_plot, dispersion_heatmap_plot], best_fitness_text, best_positions_text, dispersion_text
517
 
518
 
519