Perform the crossover operation

@param probability Crossover setProbability
@param parent1     The first parent
@param parent2     The second parent
@return An array containing the two offspring
@throws org.uma.jmetal.util.JMetalException
172335
public List<BinarySolution> doCrossover(double probability,
                                          BinarySolution parent1,
                                          BinarySolution parent2) throws JMetalException {
    List<BinarySolution> offspring = new ArrayList<>();
    offspring.add((BinarySolution) parent1.copy()) ;
    offspring.add((BinarySolution) parent2.copy()) ;

    if (randomGenerator.getRandomValue() < probability) {
      for (int var = 0; var < parent1.getNumberOfVariables(); var++) {
        BinarySet p1 = parent1.getVariableValue(var) ;
        BinarySet p2 = parent2.getVariableValue(var) ;

        for (int bit = 0; bit < p1.size(); bit++) {
          if (p1.get(bit) != p2.get(bit)) {
            if  (randomGenerator.getRandomValue() < 0.5) {
              offspring.get(0).getVariableValue(var).set(bit, p2.get(bit)) ;
              offspring.get(1).getVariableValue(var).set(bit, p1.get(bit)) ;
            }
          }
        }
      }
    }

    return offspring;
  }
610591
@Override
    public void initializeInstance(PopulationModel populationModel, ChromosomeFactory chromosomeFactory) {
        super.initializeInstance(populationModel, chromosomeFactory);
        crossoverOperator.initializeInstance(populationModel);
    }
369057
def _crossover(population, crossover_chance, crossover_operator):
    """"""
    new_population = []
    for i in range(0, len(population), 2):  # For every other index
        # Take parents from every set of 2 in the population
        # Wrap index if out of range
        try:
            parents = (population[i], population[i + 1])
        except IndexError:
            parents = (population[i], population[0])

        # If crossover takes place
        if random.uniform(0.0, 1.0) <= crossover_chance:
            # Add children to the new population
            new_population.extend(crossover_operator(parents))
        else:
            new_population.extend(parents)

    return new_population
730668
public void swapTwoChildren(GroovySourceAST t) {
        // this swaps the two child nodes, see javadoc above for explanation of implementation
        GroovySourceAST a = (GroovySourceAST) t.getFirstChild();
        GroovySourceAST b = (GroovySourceAST) a.getNextSibling();

        t.setFirstChild(b);
        a.setNextSibling(null);
        b.setNextSibling(a);
    }
337754
public Operation getSimplifiedJoinOp(Mapper mapper, List parentList)
    {
        int maxSimplifiedIn = DeepRelationshipUtility.MAX_SIMPLIFIED_IN;
        boolean differentPersisterThanParent = differentPersisterIdThanParent(mapper);
        if (differentPersisterThanParent)
        {
            maxSimplifiedIn = Integer.MAX_VALUE;
        }
        return mapper.getSimplifiedJoinOp(parentList, maxSimplifiedIn, this, differentPersisterThanParent);
    }
952639
public DoublePoint Add(DoublePoint point1, DoublePoint point2) {
        DoublePoint result = new DoublePoint(point1);
        result.Add(point2);
        return result;
    }
916495
public Deque<Integer> getCrossoverPoints() {
        Collections.shuffle(parameterIndexes);
        List<Integer> crossoverPointLists =
                        parameterIndexes.subList(0, rng.nextInt(maxCrossovers - minCrossovers) + minCrossovers);
        Collections.sort(crossoverPointLists);
        Deque<Integer> crossoverPoints = new ArrayDeque<Integer>(crossoverPointLists);
        crossoverPoints.add(Integer.MAX_VALUE);

        return crossoverPoints;
    }
333707
private static void linearCrossover(Program gp1, Program gp2, LGP manager, RandEngine randEngine) {
      // length(gp1) <= length(gp2)
      if (gp1.length() > gp2.length())
      {
         gp1 = gp2;
         gp2 = gp1;
      }

      // select i1 from gp1 and i2 from gp2 such that abs(i1-i2) <= max_crossover_point_distance
      // max_crossover_point_distance=min{length(gp1) - 1, m_max_distance_of_crossover_points}
      int i1 = randEngine.nextInt(gp1.length());
      int i2 = randEngine.nextInt(gp2.length());
      int cross_point_distance = (i1 > i2) ? (i1 - i2) : (i2 - i1);
      int max_crossover_point_distance = (gp1.length() - 1 > manager.getMaxDistanceOfCrossoverPoints() ? manager.getMaxDistanceOfCrossoverPoints() : gp1.length() - 1);
      while (cross_point_distance > max_crossover_point_distance)
      {
         i1 = randEngine.nextInt(gp1.length());
         i2 = randEngine.nextInt(gp2.length());
         cross_point_distance = (i1 > i2) ? (i1 - i2) : (i2 - i1);
      }

      int s1_max = (gp1.length() - i1) > manager.getMaxDifferenceOfSegmentLength() ? manager.getMaxDifferenceOfSegmentLength() : (gp1.length() - i1);
      int s2_max = (gp2.length() - i2) > manager.getMaxDifferenceOfSegmentLength() ? manager.getMaxDifferenceOfSegmentLength() : (gp2.length() - i2);

      // select s1 from gp1 (start at i1) and s2 from gp2 (start at i2)
      // such that length(s1) <= length(s2)
      // and abs(length(s1) - length(s2)) <= m_max_difference_of_segment_length)
      int ls1 = 1 + randEngine.nextInt(s1_max);
      int ls2 = 1 + randEngine.nextInt(s2_max);
      int lsd = (ls1 > ls2) ? (ls1 - ls2) : (ls2 - ls1);
      while ((ls1 > ls2) && (lsd > manager.getMaxDifferenceOfSegmentLength()))
      {
         ls1 = 1 + randEngine.nextInt(s1_max);
         ls2 = 1 + randEngine.nextInt(s2_max);
         lsd = (ls1 > ls2) ? (ls1 - ls2) : (ls2 - ls1);
      }

      if(((gp2.length() - (ls2-ls1)) < manager.getMinProgramLength() || ((gp1.length()+(ls2-ls1)) > manager.getMaxProgramLength())))
      {
         if(randEngine.uniform() < 0.5)
         {
            ls2=ls1;
         }
         else
         {
            ls1=ls2;
         }
         if((i1+ls1) > gp1.length())
         {
            ls1 = gp1.length() - i1;
         }
         if((i2 + ls2) > gp2.length()) {
            ls2 = gp2.length() - i2;
         }
      }



      List<Instruction> instructions1=gp1.getInstructions();
      List<Instruction> instructions2=gp2.getInstructions();

      List<Instruction> instructions1_1=new ArrayList<>();
      List<Instruction> instructions1_2=new ArrayList<>();
      List<Instruction> instructions1_3=new ArrayList<>();

      List<Instruction> instructions2_1=new ArrayList<>();
      List<Instruction> instructions2_2=new ArrayList<>();
      List<Instruction> instructions2_3=new ArrayList<>();

      for(int i=0; i < i1; ++i)
      {
         instructions1_1.add(instructions1.get(i));
      }
      for(int i=i1; i < i1+ls1; ++i)
      {
         instructions1_2.add(instructions1.get(i));
      }
      for(int i=i1+ls1; i < instructions1.size(); ++i)
      {
         instructions1_3.add(instructions1.get(i));
      }

      for(int i=0; i < i2; ++i)
      {
         instructions2_1.add(instructions2.get(i));
      }
      for(int i=i2; i < i2+ls2; ++i)
      {
         instructions2_2.add(instructions2.get(i));
      }
      for(int i=i2+ls2; i < instructions2.size(); ++i)
      {
         instructions2_3.add(instructions2.get(i));
      }

      instructions1.clear();
      instructions2.clear();

      for(int i=0; i < i1; ++i)
      {
         instructions1.add(instructions1_1.get(i));
      }
      for(int i=0; i < ls2; ++i)
      {
         instructions1.add(InstructionHelper.reassign2Program(instructions2_2.get(i), gp1));
      }
      for(int i=0; i < instructions1_3.size(); ++i)
      {
         instructions1.add(instructions1_3.get(i));
      }

      for(int i=0; i < i2; ++i)
      {
         instructions2.add(instructions2_1.get(i));
      }
      for(int i=0; i < ls1; ++i)
      {
         instructions2.add(InstructionHelper.reassign2Program(instructions1_2.get(i), gp2));
      }
      for(int i=0; i < instructions2_3.size(); ++i)
      {
         instructions2.add(instructions2_3.get(i));
      }

      gp1.invalidateCost();
      gp2.invalidateCost();
   }
892897
public static <First, Second> Pair<First, Second> from(
      final First first, final Second second) {
    return new ImmutablePair<First, Second>(first, second);
  }
571397
@SuppressWarnings("unchecked")
  public void setParent(PvmExecutionImpl parent) {
    PvmExecutionImpl currentParent = getParent();

    setParentExecution(parent);

    if (currentParent != null) {
      currentParent.getExecutions().remove(this);
    }

    if (parent != null) {
      ((List<PvmExecutionImpl>) parent.getExecutions()).add(this);
    }
  }
633414
public void set( double x1, double y1, double z1,
					 double x2, double y2, double z2 ) {
		this.p1.set(x1,y1,z1);
		this.p2.set(x2,y2,z2);
	}
4410
void setParent (Context2 parent)
    {
        this.parent = parent;
        parent.child = this;        // JJK: Doubly-linked
        declarations = null;
        prefixTable = parent.prefixTable;
        uriTable = parent.uriTable;
        elementNameTable = parent.elementNameTable;
        attributeNameTable = parent.attributeNameTable;
        defaultNS = parent.defaultNS;
        tablesDirty = false;
    }
1337514
@Override
  protected List<S> reproduction(List<S> population) {
    List<S> offspring = crossoverOperator.execute(population);
    mutationOperator.execute(offspring.get(0));

    return offspring;
  }
27103
public double compare(String v1, String v2) {
    // FIXME: it should be possible here to say that, actually, we
    // didn't learn anything from comparing these two values, so that
    // probability is set to 0.5.

    if (comparator == null)
      return 0.5; // we ignore properties with no comparator

    // first, we call the comparator, to get a measure of how similar
    // these two values are. note that this is not the same as what we
    // are going to return, which is a probability.
    double sim = comparator.compare(v1, v2);

    // we have been configured with a high probability (for equal
    // values) and a low probability (for different values). given
    // sim, which is a measure of the similarity somewhere in between
    // equal and different, we now compute our estimate of the
    // probability.

    // if sim = 1.0, we return high. if sim = 0.0, we return low. for
    // values in between we need to compute a little.  the obvious
    // formula to use would be (sim * (high - low)) + low, which
    // spreads the values out equally spaced between high and low.

    // however, if the similarity is higher than 0.5 we don't want to
    // consider this negative evidence, and so there's a threshold
    // there.  also, users felt Duke was too eager to merge records,
    // and wanted probabilities to fall off faster with lower
    // probabilities, and so we square sim in order to achieve this.

    if (sim >= 0.5)
      return ((high - 0.5) * (sim * sim)) + 0.5;
    else
      return low;
  }
607086
@Override public List<S> execute(List<S> source) {
    if (null == source) {
      throw new JMetalException("Null parameter") ;
    } else if (source.size() != 2) {
      throw new JMetalException("There must be two parents instead of " + source.size()) ;
    }

    List<S> list = new ArrayList<>() ;
    list.add((S) source.get(0).copy()) ;
    list.add((S) source.get(1).copy()) ;

    return list ;
  }
1136453
@Override
  public List<IntegerSolution> execute(List<IntegerSolution> solutions) {
    if (null == solutions) {
      throw new JMetalException("Null parameter") ;
    } else if (solutions.size() != 2) {
      throw new JMetalException("There must be two parents instead of " + solutions.size()) ;
    }

    return doCrossover(crossoverProbability, solutions.get(0), solutions.get(1)) ;
  }
291627
public static Matcher<Tree> parentNode(Matcher<? extends Tree> treeMatcher) {
    @SuppressWarnings("unchecked") // Safe contravariant cast
    Matcher<Tree> matcher = (Matcher<Tree>) treeMatcher;
    return new ParentNode(matcher);
  }