public int produce(
      final int min,
      final int max,
      final int start,
      final int subpopulation,
      final Individual[] inds,
      final EvolutionState state,
      final int thread) {

    // how many individuals should we make?
    int n = typicalIndsProduced();
    if (n < min) n = min;
    if (n > max) n = max;

    // should we bother?
    if (!state.random[thread].nextBoolean(likelihood))
      return reproduce(
          n,
          start,
          subpopulation,
          inds,
          state,
          thread,
          true); // DO produce children from source -- we've not done so already

    // random select one tree from treelib
    // int treeIndex = (new Random()).nextInt(state.maxTreelibSize);

    // GPNode TR = state.treelib[treeIndex];
    // create tree: 1 - TR
    GPNode OneSubTR = (GPNode) (((GPNode[]) fs.nodesByName.get("-"))[0]).lightClone();
    OneSubTR.children = new GPNode[2];

    RegERC oneNode = new RegERC();
    oneNode.constraints = 6;
    oneNode.children = new GPNode[0];
    oneNode.value = 1;

    OneSubTR.children[0] = oneNode;

    GPInitializer initializer = ((GPInitializer) state.initializer);

    for (int q = start; q < n + start; /* no increment */ ) // keep on going until we're filled up
    {
      // grab two individuals from our sources
      if (sources[0] == sources[1]) // grab from the same source
      sources[0].produce(2, 2, 0, subpopulation, parents, state, thread);
      else // grab from different sources
      {
        sources[0].produce(1, 1, 0, subpopulation, parents, state, thread);
        sources[1].produce(1, 1, 1, subpopulation, parents, state, thread);
      }

      // at this point, parents[] contains our two selected individuals

      // random select one tree from treelib
      int treeIndex = (new Random()).nextInt(state.maxTreelibSize);
      GPNode TR = state.treelib[treeIndex];

      OneSubTR.children[1] = (GPNode) TR.clone();

      double[] randomSemanticTraining = state.semanticTreelibTraining[treeIndex];
      double[] randomSemanticTesting = state.semanticTreelibTesting[treeIndex];

      // are our tree values valid?
      if (tree1 != TREE_UNFIXED && (tree1 < 0 || tree1 >= parents[0].trees.length))
        // uh oh
        state.output.fatal(
            "GP Crossover Pipeline attempted to fix tree.0 to a value which was out of bounds of the array of the individual's trees.  Check the pipeline's fixed tree values -- they may be negative or greater than the number of trees in an individual");
      if (tree2 != TREE_UNFIXED && (tree2 < 0 || tree2 >= parents[1].trees.length))
        // uh oh
        state.output.fatal(
            "GP Crossover Pipeline attempted to fix tree.1 to a value which was out of bounds of the array of the individual's trees.  Check the pipeline's fixed tree values -- they may be negative or greater than the number of trees in an individual");

      int t1 = 0;
      int t2 = 0;
      if (tree1 == TREE_UNFIXED || tree2 == TREE_UNFIXED) {
        do
        // pick random trees  -- their GPTreeConstraints must be the same
        {
          if (tree1 == TREE_UNFIXED)
            if (parents[0].trees.length > 1)
              t1 = state.random[thread].nextInt(parents[0].trees.length);
            else t1 = 0;
          else t1 = tree1;

          if (tree2 == TREE_UNFIXED)
            if (parents[1].trees.length > 1)
              t2 = state.random[thread].nextInt(parents[1].trees.length);
            else t2 = 0;
          else t2 = tree2;
        } while (parents[0].trees[t1].constraints(initializer)
            != parents[1].trees[t2].constraints(initializer));
      } else {
        t1 = tree1;
        t2 = tree2;
        // make sure the constraints are okay
        if (parents[0].trees[t1].constraints(initializer)
            != parents[1].trees[t2].constraints(initializer)) // uh oh
        state.output.fatal(
              "GP Crossover Pipeline's two tree choices are both specified by the user -- but their GPTreeConstraints are not the same");
      }

      // number of crossover
      state.numOfSGX[state.generation][0] += 1;

      GPIndividual child1 = (GPIndividual) (parents[0].lightClone());
      child1.trees[0].semanticTraining = new double[randomSemanticTraining.length];
      child1.trees[0].semanticTesting = new double[randomSemanticTesting.length];

      GPIndividual child2 = null;
      if (n - (q - start) >= 2 && !tossSecondParent) {
        child2 = (GPIndividual) (parents[1].lightClone());
        child2.trees[0].semanticTraining = new double[randomSemanticTraining.length];
        child2.trees[0].semanticTesting = new double[randomSemanticTesting.length];
      }

      // geometric semantic crossover on training set
      for (int i = 0; i < parents[0].trees[0].semanticTraining.length; i++) {
        child1.trees[0].semanticTraining[i] =
            randomSemanticTraining[i] * parents[0].trees[0].semanticTraining[i]
                + (1 - randomSemanticTraining[i]) * parents[1].trees[0].semanticTraining[i];
        child1.evaluated = false;

        if (child2 != null) {
          child2.trees[0].semanticTraining[i] =
              (1 - randomSemanticTraining[i]) * parents[0].trees[0].semanticTraining[i]
                  + randomSemanticTraining[i] * parents[1].trees[0].semanticTraining[i];
          child2.evaluated = false;
        }
      }

      // geometric semantic crossover on testing set
      for (int i = 0; i < parents[0].trees[0].semanticTesting.length; i++) {
        child1.trees[0].semanticTesting[i] =
            randomSemanticTesting[i] * parents[0].trees[0].semanticTesting[i]
                + (1 - randomSemanticTesting[i]) * parents[1].trees[0].semanticTesting[i];

        if (child2 != null) {
          child2.trees[0].semanticTesting[i] =
              (1 - randomSemanticTesting[i]) * parents[0].trees[0].semanticTesting[i]
                  + randomSemanticTesting[i] * parents[1].trees[0].semanticTesting[i];
        }
      }

      // add the individuals to the population
      inds[q] = child1;
      q++;
      if (q < n + start && !tossSecondParent) {
        inds[q] = child2;
        q++;
      }
    }
    return n;
  }