/**
   * Update the personal best position of a particle.
   *
   * @param particleIndex index of the particle in the swarm
   * @param particlePosition the particle current position vector
   */
  protected void updatePersonalBestPosition(int particleIndex, double[] particlePosition) {
    // set the network weights and biases from the vector
    double score = m_calculateScore.calculateScore(m_networks[particleIndex]);

    // update the best vectors (g and i)
    if ((m_bestErrors[particleIndex] == 0) || isScoreBetter(score, m_bestErrors[particleIndex])) {
      m_bestErrors[particleIndex] = score;
      m_va.copy(m_bestVectors[particleIndex], particlePosition);
    }
  }
 /**
  * Compares two scores.
  *
  * @param score1 a score
  * @param score2 a score
  * @return true if score1 is better than score2
  */
 boolean isScoreBetter(double score1, double score2) {
   return ((m_calculateScore.shouldMinimize() && (score1 < score2))
       || ((!m_calculateScore.shouldMinimize()) && (score1 > score2)));
 }