/** {@inheritDoc} */ @Override public <T extends Entity> T create(T targetEntity, T current, Topology<T> topology) { T bestEntity = Topologies.getBestEntity(topology); List<T> participants = Selection.copyOf(topology) .exclude(targetEntity, bestEntity, current) .orderBy(new RandomArrangement()) .select(Samples.first((int) numberOfDifferenceVectors.getParameter()).unique()); Vector differenceVector = determineDistanceVector(participants); Vector targetVector = ((Vector) targetEntity.getCandidateSolution()) .multiply(1 - greedynessParameter.getParameter()); Vector bestVector = ((Vector) bestEntity.getCandidateSolution()).multiply(greedynessParameter.getParameter()); Vector trialVector = bestVector.plus( targetVector.plus(differenceVector.multiply(scaleParameter.getParameter()))); T trialEntity = (T) current.getClone(); trialEntity.setCandidateSolution(trialVector); return trialEntity; }
/** {@inheritDoc} */ @Override public <T extends Entity> T create(T targetEntity, T current, fj.data.List<T> topology) { int number = Double.valueOf(this.numberOfDifferenceVectors.getParameter()).intValue(); List<T> participants = Selection.copyOf(topology) .exclude(targetEntity, current) .orderBy(new RandomArrangement()) .select(Samples.first(number).unique()); Vector differenceVector = determineDistanceVector(participants); Vector targetVector = (Vector) targetEntity.getCandidateSolution(); Vector trialVector = targetVector.plus( differenceVector.multiply( new P1<Number>() { @Override public Number _1() { return scaleParameter.getParameter(); } })); T trialEntity = (T) current.getClone(); trialEntity.setCandidateSolution(trialVector); return trialEntity; }