# create a dataframe for selection 
sel_df <- pop_df

# rank IDs by TPE mean
sel_df <- sel_df[order(-sel_df$main_effect),]

#------ Select pairs for product development ----------- 

  n_even <- floor(nrow(sel_df) / 2) * 2      # make sure pairs are even by removing lowest individual
  pairs <- data.frame(
    id1 = sel_df$id[seq(1, n_even, by = 2)],
    id2 = sel_df$id[seq(2, n_even, by = 2)]
  )

pairs <- pairs[1:(nPairsProdDev),]
mean_crossPlan <- rbind(cbind(as.character(pairs[,1]), as.character(pairs[,2])))

#---- Make PD population and record GVs in a dataframe ----

F1mean = makeCross(DH, mean_crossPlan, simParam=SP)
DHmean <- makeDH(F1mean, nDHProdDev)
df_mean <- data.frame(DHmean@gv[,-1], strat = "mean")
f1_mean <- data.frame(F1mean@gv[,-1], strat = "mean")

