Here you can find the source of joinParetos(double[][] pareto1, double[][] pareto2)
public static double[][] joinParetos(double[][] pareto1, double[][] pareto2) throws Exception
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.List; public class Main { public static double[][] joinParetos(double[][] pareto1, double[][] pareto2) throws Exception { if (pareto1 == null) { if (pareto2 != null) return pareto2; } else if (pareto2 == null) { if (pareto1 != null) return pareto1; }//from w w w.java 2s . c om if (pareto1[0].length != pareto2[0].length) { throw new Exception( "Cannot merge pareto fronts with different number of objetives"); } else { int numObjs = pareto2[0].length; int par1size = pareto1.length; int par2size = pareto2.length; ArrayList<double[]> newPareto = new ArrayList<double[]>( par1size + par2size); for (int i = 0; i < pareto1.length; i++) { if (!solutionIsInFront(pareto1[i], newPareto)) newPareto.add(pareto1[i]); } for (int i = 0; i < pareto2.length; i++) { if (!solutionIsInFront(pareto2[i], newPareto)) newPareto.add(pareto2[i]); } double[][] newParetoArray = new double[newPareto.size()][numObjs]; newParetoArray = newPareto.toArray(newParetoArray); return newParetoArray; } } public static boolean solutionIsInFront(double[] sol, List<double[]> front) { boolean isIn = false; for (double[] compSol : front) { if (solutionIsEqual(sol, compSol)) { isIn = true; break; } } return isIn; } public static boolean solutionIsEqual(double[] sol1, double[] sol2) { boolean allEqual = true; for (int i = 0; i < sol1.length; i++) { if (sol1[i] != sol2[i]) { allEqual = false; break; } } return allEqual; } }