/** * Returns a representation of of the population in the form of a table, where each row represents * one individual, one parameter per column, and the last column containing the objective value. * * @returns a table represeting the population. */ public Table getTable() { Table vt; int rowCount = solutions.length; int colCount = ranges.length + 1; Column[] cols = new Column[colCount]; // make a column for each range for (int i = 0; i < ranges.length; i++) { Column c; if (ranges[i] instanceof DoubleRange) { c = new DoubleColumn(rowCount); for (int j = 0; j < rowCount; j++) { double d = solutions[j].getDoubleParameter(i); ((DoubleColumn) c).setDouble(d, j); } } else if (ranges[i] instanceof IntRange) { c = new IntColumn(rowCount); for (int j = 0; j < rowCount; j++) { int in = (int) solutions[j].getDoubleParameter(i); ((IntColumn) c).setInt(in, j); } } else if (ranges[i] instanceof BinaryRange) { c = new BooleanColumn(rowCount); for (int j = 0; j < rowCount; j++) { boolean b = (solutions[j].getDoubleParameter(i) > 0); ((BooleanColumn) c).setBoolean(b, j); } } else { // i guess default to a double column c = new DoubleColumn(rowCount); for (int j = 0; j < rowCount; j++) { double d = solutions[j].getDoubleParameter(i); ((DoubleColumn) c).setDouble(d, j); } } c.setLabel(ranges[i].getName()); cols[i] = c; } // now the objective DoubleColumn objC = new DoubleColumn(rowCount); objC.setLabel(objConstraints.getName()); for (int j = 0; j < rowCount; j++) { objC.setDouble(solutions[j].getObjective(), j); } cols[colCount - 1] = objC; vt = new MutableTableImpl(cols); return vt; }