com.bnd.math.business.evo.EvoArrayChromManipulatorBO Maven / Gradle / Ivy
The newest version!
package com.bnd.math.business.evo;
import java.util.ArrayList;
import java.util.List;
import com.bnd.core.domain.ValueBound;
import com.bnd.core.reflection.ReflectionProvider;
import com.bnd.core.reflection.ReflectionUtil;
import com.bnd.math.domain.evo.ArrayChromosome;
import com.bnd.math.domain.evo.BitMutationType;
public class EvoArrayChromManipulatorBO extends EvoCompositeChromManipulatorBO, E[], E>{
private final Class topLevelClass;
public EvoArrayChromManipulatorBO(
ReflectionProvider> chromosomeRF,
Class topLevelClass,
BitMutationType bitMutationType,
Double pertrubMutationStrength,
List> codeElementValueBounds
) {
this(chromosomeRF, topLevelClass, bitMutationType, pertrubMutationStrength, collectElementClasses(codeElementValueBounds).toArray(new Class[0]), codeElementValueBounds.toArray(new ValueBound[0]));
}
private static List> collectElementClasses(
List> codeElementValueBounds
) {
List> classes = new ArrayList>();
for (ValueBound extends E> bound : codeElementValueBounds) {
classes.add((Class) bound.getFrom().getClass());
}
return classes;
}
public EvoArrayChromManipulatorBO(
ReflectionProvider> chromosomeRF,
Class toplevelClass,
BitMutationType bitMutationType,
Double pertrubMutationStrength,
Class[] elementClasses,
ValueBound[] codeElementValueBounds
) {
super(chromosomeRF, elementClasses.length, bitMutationType, pertrubMutationStrength, elementClasses, codeElementValueBounds);
this.topLevelClass = toplevelClass;
}
public EvoArrayChromManipulatorBO(
ReflectionProvider> chromosomeRF,
int codeSize,
BitMutationType bitMutationType,
Double pertrubMutationStrength,
Class elementClass
) {
super(chromosomeRF, codeSize, bitMutationType, pertrubMutationStrength, elementClass);
this.topLevelClass = elementClass;
}
public EvoArrayChromManipulatorBO(
ReflectionProvider> chromosomeRF,
BitMutationType bitMutationType,
Double pertrubMutationStrength,
Class elementClass,
ValueBound[] codeElementValueBounds
) {
super(chromosomeRF, codeElementValueBounds.length, bitMutationType, pertrubMutationStrength, elementClass, codeElementValueBounds);
this.topLevelClass = elementClass;
}
public EvoArrayChromManipulatorBO(
ReflectionProvider> chromosomeRF,
int codeSize,
BitMutationType bitMutationType,
Double pertrubMutationStrength,
Class elementClass,
ValueBound sharedCodeElementValueBound
) {
super(chromosomeRF, codeSize, bitMutationType, pertrubMutationStrength, elementClass, sharedCodeElementValueBound);
this.topLevelClass = elementClass;
}
@Override
protected E[] createBlankCode() {
return (E[]) ReflectionUtil.createNewArray(topLevelClass, codeSize);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy