code: public void run() throws Exception {
          if (ranges == null) {
              throw new ModelsIllegalargumentException("No ranges have been defined for the parameter space.", this);
          }
  
          createSwarm();
          double[] previous = null;
          while( iterationStep <= maxIterations ) {
              updateSwarm();
  
              if (printStep()) {
                  System.out.println(prefix + " - ITER: " + iterationStep + " global best: " + globalBest + " - for positions: "
                          + Arrays.toString(globalBestLocations));
              }
  
              if (function.hasConverged(globalBest, globalBestLocations, previous)) {
                  break;
              }
              previous = globalBestLocations.clone();
          }
      }
docs: Run the particle swarm engine.
  @throws Exception