Performance improvements. Cleanup.

This commit is contained in:
Fabian Becker 2014-10-19 16:28:56 +02:00
parent 7d6a9faf66
commit c79d2e893f
159 changed files with 424 additions and 670 deletions

View File

@ -1018,7 +1018,7 @@ public class OptimizerFactory {
public static List<BitSet> postProcessBinVec(OptimizerRunnable runnable, public static List<BitSet> postProcessBinVec(OptimizerRunnable runnable,
InterfacePostProcessParams ppp) { InterfacePostProcessParams ppp) {
Population resPop = postProcess(runnable, ppp); Population resPop = postProcess(runnable, ppp);
List<BitSet> ret = new ArrayList<BitSet>(resPop.size()); List<BitSet> ret = new ArrayList<>(resPop.size());
for (Object o : resPop) { for (Object o : resPop) {
if (o instanceof InterfaceDataTypeBinary) { if (o instanceof InterfaceDataTypeBinary) {
InterfaceDataTypeBinary indy = (InterfaceDataTypeBinary) o; InterfaceDataTypeBinary indy = (InterfaceDataTypeBinary) o;
@ -1058,7 +1058,7 @@ public class OptimizerFactory {
public static List<double[]> postProcessDblVec( public static List<double[]> postProcessDblVec(
OptimizerRunnable runnable, InterfacePostProcessParams ppp) { OptimizerRunnable runnable, InterfacePostProcessParams ppp) {
Population resPop = postProcess(runnable, ppp); Population resPop = postProcess(runnable, ppp);
List<double[]> ret = new ArrayList<double[]>(resPop.size()); List<double[]> ret = new ArrayList<>(resPop.size());
for (Object o : resPop) { for (Object o : resPop) {
if (o instanceof InterfaceDataTypeDouble) { if (o instanceof InterfaceDataTypeDouble) {
InterfaceDataTypeDouble indy = (InterfaceDataTypeDouble) o; InterfaceDataTypeDouble indy = (InterfaceDataTypeDouble) o;
@ -1098,7 +1098,7 @@ public class OptimizerFactory {
public static List<AbstractEAIndividual> postProcessIndVec( public static List<AbstractEAIndividual> postProcessIndVec(
OptimizerRunnable runnable, InterfacePostProcessParams ppp) { OptimizerRunnable runnable, InterfacePostProcessParams ppp) {
Population resPop = postProcess(runnable, ppp); Population resPop = postProcess(runnable, ppp);
List<AbstractEAIndividual> ret = new ArrayList<AbstractEAIndividual>( List<AbstractEAIndividual> ret = new ArrayList<>(
resPop.size()); resPop.size());
for (Object o : resPop) { for (Object o : resPop) {
if (o instanceof AbstractEAIndividual) { if (o instanceof AbstractEAIndividual) {

View File

@ -156,7 +156,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
} }
public static Map<String, Class<? extends InterfaceOptimizer>> createOptimizerList() { public static Map<String, Class<? extends InterfaceOptimizer>> createOptimizerList() {
Map<String, Class<? extends InterfaceOptimizer>> optimizerList = new TreeMap<String, Class<? extends InterfaceOptimizer>>(); Map<String, Class<? extends InterfaceOptimizer>> optimizerList = new TreeMap<>();
Reflections reflections = new Reflections("eva2.optimization.strategies"); Reflections reflections = new Reflections("eva2.optimization.strategies");
Set<Class<? extends InterfaceOptimizer>> optimizers = reflections.getSubTypesOf(InterfaceOptimizer.class); Set<Class<? extends InterfaceOptimizer>> optimizers = reflections.getSubTypesOf(InterfaceOptimizer.class);
@ -171,7 +171,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
} }
public static Map<String, Class<? extends AbstractProblemDoubleOffset>> createProblemList() { public static Map<String, Class<? extends AbstractProblemDoubleOffset>> createProblemList() {
Map<String, Class<? extends AbstractProblemDoubleOffset>> problemList = new TreeMap<String, Class<? extends AbstractProblemDoubleOffset>>(); Map<String, Class<? extends AbstractProblemDoubleOffset>> problemList = new TreeMap<>();
Reflections reflections = new Reflections("eva2.problems"); Reflections reflections = new Reflections("eva2.problems");
Set<Class<? extends AbstractProblemDoubleOffset>> problems = reflections.getSubTypesOf(AbstractProblemDoubleOffset.class); Set<Class<? extends AbstractProblemDoubleOffset>> problems = reflections.getSubTypesOf(AbstractProblemDoubleOffset.class);
for (Class<? extends AbstractProblemDoubleOffset> problem : problems) { for (Class<? extends AbstractProblemDoubleOffset> problem : problems) {
@ -185,7 +185,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
} }
public static Map<String, Class<? extends InterfaceMutation>> createMutatorList() { public static Map<String, Class<? extends InterfaceMutation>> createMutatorList() {
Map<String, Class<? extends InterfaceMutation>> mutationList = new TreeMap<String, Class<? extends InterfaceMutation>>(); Map<String, Class<? extends InterfaceMutation>> mutationList = new TreeMap<>();
Reflections reflections = new Reflections("eva2.optimization.operator.mutation"); Reflections reflections = new Reflections("eva2.optimization.operator.mutation");
Set<Class<? extends InterfaceMutation>> mutators = reflections.getSubTypesOf(InterfaceMutation.class); Set<Class<? extends InterfaceMutation>> mutators = reflections.getSubTypesOf(InterfaceMutation.class);
for (Class<? extends InterfaceMutation> mutator : mutators) { for (Class<? extends InterfaceMutation> mutator : mutators) {
@ -199,7 +199,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
} }
public static Map<String, Class<? extends InterfaceCrossover>> createCrossoverList() { public static Map<String, Class<? extends InterfaceCrossover>> createCrossoverList() {
Map<String, Class<? extends InterfaceCrossover>> crossoverList = new TreeMap<String, Class<? extends InterfaceCrossover>>(); Map<String, Class<? extends InterfaceCrossover>> crossoverList = new TreeMap<>();
Reflections reflections = new Reflections("eva2.optimization.operator.crossover"); Reflections reflections = new Reflections("eva2.optimization.operator.crossover");
Set<Class<? extends InterfaceCrossover>> crossovers = reflections.getSubTypesOf(InterfaceCrossover.class); Set<Class<? extends InterfaceCrossover>> crossovers = reflections.getSubTypesOf(InterfaceCrossover.class);
for (Class<? extends InterfaceCrossover> crossover : crossovers) { for (Class<? extends InterfaceCrossover> crossover : crossovers) {
@ -213,7 +213,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
} }
public static Map<String, Class<? extends InterfaceSelection>> createSelectionList() { public static Map<String, Class<? extends InterfaceSelection>> createSelectionList() {
Map<String, Class<? extends InterfaceSelection>> selectionList = new TreeMap<String, Class<? extends InterfaceSelection>>(); Map<String, Class<? extends InterfaceSelection>> selectionList = new TreeMap<>();
Reflections reflections = new Reflections("eva2.optimization.operator.selection"); Reflections reflections = new Reflections("eva2.optimization.operator.selection");
Set<Class<? extends InterfaceSelection>> selections = reflections.getSubTypesOf(InterfaceSelection.class); Set<Class<? extends InterfaceSelection>> selections = reflections.getSubTypesOf(InterfaceSelection.class);
for (Class<? extends InterfaceSelection> selection : selections) { for (Class<? extends InterfaceSelection> selection : selections) {

View File

@ -16,7 +16,7 @@ import java.awt.event.ActionListener;
/** /**
* @author becker * @author becker
*/ */
public class AboutDialog extends JDialog { class AboutDialog extends JDialog {
private JLabel imageLabel; private JLabel imageLabel;
private JEditorPane infoEditorPane; private JEditorPane infoEditorPane;
private JTextArea aboutTextArea; private JTextArea aboutTextArea;

View File

@ -157,7 +157,7 @@ public class BeanInspector {
Class<?> type = obj.getClass(); Class<?> type = obj.getClass();
if (type.isArray()) { // handle the array case if (type.isArray()) { // handle the array case
StringBuffer sbuf = new StringBuffer(); StringBuilder sbuf = new StringBuilder();
sbuf.append("["); sbuf.append("[");
if (!tight) { if (!tight) {
sbuf.append(" "); sbuf.append(" ");
@ -270,7 +270,7 @@ public class BeanInspector {
if (indentDepth < 1) { if (indentDepth < 1) {
return ""; return "";
} else { } else {
StringBuffer sbuf = new StringBuffer(indentStr); StringBuilder sbuf = new StringBuilder(indentStr);
for (int i = 2; i <= indentDepth; i++) { for (int i = 2; i <= indentDepth; i++) {
sbuf.append(indentStr); sbuf.append(indentStr);
} }
@ -346,7 +346,7 @@ public class BeanInspector {
System.err.println("BeanTest ERROR +" + e.getMessage()); System.err.println("BeanTest ERROR +" + e.getMessage());
} }
} }
Pair<String[], Object[]> nameVals = new Pair<String[], Object[]>(nameArray, valArray); Pair<String[], Object[]> nameVals = new Pair<>(nameArray, valArray);
return nameVals; return nameVals;
} }
@ -597,7 +597,7 @@ public class BeanInspector {
* @return an info string about class and members of the given object * @return an info string about class and members of the given object
*/ */
public static String getDescription(Object obj, boolean withValues) { public static String getDescription(Object obj, boolean withValues) {
StringBuffer sbuf = new StringBuffer(getClassDescription(obj)); StringBuilder sbuf = new StringBuilder(getClassDescription(obj));
sbuf.append("\n"); sbuf.append("\n");
String[] mems = getMemberDescriptions(obj, withValues); String[] mems = getMemberDescriptions(obj, withValues);
for (String str : mems) { for (String str : mems) {
@ -614,7 +614,7 @@ public class BeanInspector {
* @return String information about the object's class * @return String information about the object's class
*/ */
public static String getClassDescription(Object obj) { public static String getClassDescription(Object obj) {
StringBuffer infoBf = new StringBuffer("Type: "); StringBuilder infoBf = new StringBuilder("Type: ");
infoBf.append(obj.getClass().getName()); infoBf.append(obj.getClass().getName());
infoBf.append("\t"); infoBf.append("\t");
@ -659,7 +659,7 @@ public class BeanInspector {
return null; return null;
} }
PropertyDescriptor[] propertyDescriptors = bi.getPropertyDescriptors(); PropertyDescriptor[] propertyDescriptors = bi.getPropertyDescriptors();
ArrayList<String> memberInfoList = new ArrayList<String>(); ArrayList<String> memberInfoList = new ArrayList<>();
for (int i = 0; i < propertyDescriptors.length; i++) { for (int i = 0; i < propertyDescriptors.length; i++) {
if (propertyDescriptors[i].isExpert()) { if (propertyDescriptors[i].isExpert()) {
@ -689,7 +689,7 @@ public class BeanInspector {
continue; continue;
} }
StringBuffer memberInfoBf = new StringBuffer(40); StringBuilder memberInfoBf = new StringBuilder(40);
memberInfoBf.append("Member:\t"); memberInfoBf.append("Member:\t");
memberInfoBf.append(name); memberInfoBf.append(name);

View File

@ -30,7 +30,7 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
public void addPanelMaker(PanelMaker pm) { public void addPanelMaker(PanelMaker pm) {
if (pmContainer == null) { if (pmContainer == null) {
pmContainer = new ArrayList<PanelMaker>(2); pmContainer = new ArrayList<>(2);
} }
pmContainer.add(pm); pmContainer.add(pm);
} }

View File

@ -29,7 +29,7 @@ public final class JEFrameRegister {
private JDesktopPane desktopPane; private JDesktopPane desktopPane;
private JEFrameRegister() { private JEFrameRegister() {
this.frameList = new ArrayList<JEFrame>(); this.frameList = new ArrayList<>();
} }
public static JEFrameRegister getInstance() { public static JEFrameRegister getInstance() {
@ -81,8 +81,8 @@ public final class JEFrameRegister {
* @return List of prefixes * @return List of prefixes
*/ */
public String[] getCommonPrefixes(final int prefLen) { public String[] getCommonPrefixes(final int prefLen) {
List<String> prefixes = new ArrayList<String>(); List<String> prefixes = new ArrayList<>();
List<Integer> count = new ArrayList<Integer>(); List<Integer> count = new ArrayList<>();
for (int i = 0; i < frameList.size(); i++) { for (int i = 0; i < frameList.size(); i++) {
String title = frameList.get(i).getTitle(); String title = frameList.get(i).getTitle();
String titPref = title.substring(0, Math.min(prefLen, title.length())); String titPref = title.substring(0, Math.min(prefLen, title.length()));

View File

@ -37,7 +37,7 @@ public class JExtToolBar extends JToolBar {
} }
private String getKeyText(KeyStroke k) { private String getKeyText(KeyStroke k) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
if (k != null) { if (k != null) {
int modifiers = k.getModifiers(); int modifiers = k.getModifiers();

View File

@ -79,7 +79,7 @@ public class Main extends JFrame implements OptimizationStateListener {
public void addOptimizationStateListener(OptimizationStateListener l) { public void addOptimizationStateListener(OptimizationStateListener l) {
if (superListenerList == null) { if (superListenerList == null) {
superListenerList = new ArrayList<OptimizationStateListener>(); superListenerList = new ArrayList<>();
} }
superListenerList.add(l); superListenerList.add(l);
} }

View File

@ -27,7 +27,7 @@ class Mnemonic {
* *
*/ */
public void setString(String s) { public void setString(String s) {
StringBuffer buf = new StringBuffer(s); StringBuilder buf = new StringBuilder(s);
for (int i = 0; i < buf.length(); i++) { for (int i = 0; i < buf.length(); i++) {
if (buf.charAt(i) == '&') { if (buf.charAt(i) == '&') {
buf.deleteCharAt(i); buf.deleteCharAt(i);

View File

@ -311,15 +311,15 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
*/ */
public void updateClassType() { public void updateClassType() {
List<String> classesLongNames; List<String> classesLongNames;
ArrayList<Class<?>> instances = new ArrayList<Class<?>>(5); ArrayList<Class<?>> instances = new ArrayList<>(5);
classesLongNames = GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances); classesLongNames = GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances);
LOGGER.finest("Selected type for OptimizationEditorPanel: " + genericObjectEditor.getClassType().getName()); LOGGER.finest("Selected type for OptimizationEditorPanel: " + genericObjectEditor.getClassType().getName());
if (classesLongNames.size() > 1) { if (classesLongNames.size() > 1) {
classNameMap = new HashMap<String, String>(); classNameMap = new HashMap<>();
for (String className : classesLongNames) { for (String className : classesLongNames) {
classNameMap.put(EVAHELP.cutClassName(className), className); classNameMap.put(EVAHELP.cutClassName(className), className);
} }
Vector<String> classesList = new Vector<String>(classesLongNames); Vector<String> classesList = new Vector<>(classesLongNames);
objectChooser.setModel(new DefaultComboBoxModel(classesList)); objectChooser.setModel(new DefaultComboBoxModel(classesList));
if (withComboBoxToolTips) { if (withComboBoxToolTips) {
objectChooser.setRenderer(new ToolTipComboBoxRenderer(collectComboToolTips(instances, tipMaxLen))); objectChooser.setRenderer(new ToolTipComboBoxRenderer(collectComboToolTips(instances, tipMaxLen)));

View File

@ -144,9 +144,7 @@ public class PropertyDoubleArray implements java.io.Serializable {
if (i == k) { if (i == k) {
inc = 1; inc = 1;
} }
for (int j = 0; j < getNumCols(); j++) { System.arraycopy(doubleArray[i + inc], 0, newDD[i], 0, getNumCols());
newDD[i][j] = doubleArray[i + inc][j];
}
} }
setDoubleArray(newDD); setDoubleArray(newDD);
} }
@ -164,14 +162,10 @@ public class PropertyDoubleArray implements java.io.Serializable {
double[][] newDD = new double[getNumRows() + 1][getNumCols()]; double[][] newDD = new double[getNumRows() + 1][getNumCols()];
for (int i = 0; i < getNumRows(); i++) { for (int i = 0; i < getNumRows(); i++) {
for (int j = 0; j < getNumCols(); j++) { System.arraycopy(doubleArray[i], 0, newDD[i], 0, getNumCols());
newDD[i][j] = doubleArray[i][j];
}
} }
if (k >= 0) { if (k >= 0) {
for (int j = 0; j < getNumCols(); j++) { System.arraycopy(newDD[k], 0, newDD[newDD.length - 1], 0, getNumCols());
newDD[newDD.length - 1][j] = newDD[k][j];
}
} else { } else {
for (int j = 0; j < getNumCols(); j++) { for (int j = 0; j < getNumCols(); j++) {
newDD[newDD.length - 1][j] = 1.; newDD[newDD.length - 1][j] = 1.;

View File

@ -85,9 +85,7 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
*/ */
public void addTarget(InterfaceOptimizationObjective optTarget) { public void addTarget(InterfaceOptimizationObjective optTarget) {
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.selectedObjectives.length + 1]; InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.selectedObjectives.length + 1];
for (int i = 0; i < this.selectedObjectives.length; i++) { System.arraycopy(this.selectedObjectives, 0, newList, 0, this.selectedObjectives.length);
newList[i] = this.selectedObjectives[i];
}
newList[this.selectedObjectives.length] = optTarget; newList[this.selectedObjectives.length] = optTarget;
this.selectedObjectives = newList; this.selectedObjectives = newList;
} }

View File

@ -64,15 +64,11 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
if (d.length > this.weights.length) { if (d.length > this.weights.length) {
double[] newWeights = new double[d.length]; double[] newWeights = new double[d.length];
for (int i = 0; i < this.weights.length; i++) { System.arraycopy(this.weights, 0, newWeights, 0, this.weights.length);
newWeights[i] = this.weights[i];
}
this.weights = newWeights; this.weights = newWeights;
} else { } else {
double[] newWeights = new double[d.length]; double[] newWeights = new double[d.length];
for (int i = 0; i < d.length; i++) { System.arraycopy(this.weights, 0, newWeights, 0, d.length);
newWeights[i] = this.weights[i];
}
this.weights = newWeights; this.weights = newWeights;
} }
} }

View File

@ -36,7 +36,7 @@ public class PropertySelectableList<T> implements java.io.Serializable {
@Override @Override
public Object clone() { public Object clone() {
return new PropertySelectableList<T>(this); return new PropertySelectableList<>(this);
} }
public void setObjects(T[] o) { public void setObjects(T[] o) {

View File

@ -92,4 +92,4 @@ public class EnumEditor extends PropertyEditorSupport {
} }
} }
enum TestEnum {asdf, sdf, asdfa}; enum TestEnum {asdf, sdf, asdfa}

View File

@ -57,13 +57,13 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
/** /**
* list of additional buttons above the list * list of additional buttons above the list
*/ */
private List<JButton> upperButtonList = new LinkedList<JButton>(); private List<JButton> upperButtonList = new LinkedList<>();
/** /**
* list of additional buttons below the list * list of additional buttons below the list
*/ */
private List<JButton> lowerButtonList = new LinkedList<JButton>(); private List<JButton> lowerButtonList = new LinkedList<>();
private JComponent additionalCenterComp = null; private JComponent additionalCenterComp = null;
private List<JMenuItem> popupItemList = new LinkedList<JMenuItem>(); private List<JMenuItem> popupItemList = new LinkedList<>();
private JButton addButton = new JButton("Add"); private JButton addButton = new JButton("Add");
private JButton setButton = new JButton("Set"); private JButton setButton = new JButton("Set");
private JButton setAllButton = new JButton("Set all"); private JButton setAllButton = new JButton("Set all");
@ -272,11 +272,11 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
/** /**
* Creates a cell rendering component. * Creates a cell rendering component.
* *
* @param JList the list that will be rendered in * @param list the list that will be rendered in
* @param Object the cell value * @param value the cell value
* @param int which element of the list to render * @param index which element of the list to render
* @param boolean true if the cell is selected * @param isSelected true if the cell is selected
* @param boolean true if the cell has the focus * @param cellHasFocus true if the cell has the focus
* @return the rendering component * @return the rendering component
*/ */
@Override @Override
@ -417,6 +417,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
JPanel combiUpperPanel = new JPanel(getButtonLayout(1, upperButtonList)); JPanel combiUpperPanel = new JPanel(getButtonLayout(1, upperButtonList));
// ToDo Figure out how to now show this on Job Pane // ToDo Figure out how to now show this on Job Pane
combiUpperPanel.add(view); combiUpperPanel.add(view);
view.setVisible(withAddButton);
for (JButton but : upperButtonList) { for (JButton but : upperButtonList) {
combiUpperPanel.add(but); combiUpperPanel.add(but);
@ -760,6 +761,10 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
public void setWithAddButton(boolean withAddButton) { public void setWithAddButton(boolean withAddButton) {
this.withAddButton = withAddButton; this.withAddButton = withAddButton;
// Hide/Show view based on whether we show the add button
if (this.view != null) {
this.view.setVisible(withAddButton);
}
} }
public boolean isWithSetButton() { public boolean isWithSetButton() {

View File

@ -177,7 +177,7 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
for (int j = 0; j < tmpDD[0].length; j++) { for (int j = 0; j < tmpDD[0].length; j++) {
try { try {
double d = 0; double d = 0;
d = new Double(inputTextFields[i][j].getText()).doubleValue(); d = Double.parseDouble(inputTextFields[i][j].getText());
tmpDD[i][j] = d; tmpDD[i][j] = d;
} catch (Exception e) { } catch (Exception e) {
} }

View File

@ -117,7 +117,7 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
try { try {
double d = 0; double d = 0;
d = new Double(targetTextField[i].getText()).doubleValue(); d = Double.parseDouble(targetTextField[i].getText());
tmpT[i] = d; tmpT[i] = d;
} catch (Exception e) { } catch (Exception e) {

View File

@ -114,14 +114,14 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
try { try {
double d = 0; double d = 0;
d = new Double(targetTextField[i].getText()).doubleValue(); d = Double.parseDouble(targetTextField[i].getText());
tmpT[i] = d; tmpT[i] = d;
} catch (Exception e) { } catch (Exception e) {
} }
try { try {
double d = 0; double d = 0;
d = new Double(punishTextField[i].getText()).doubleValue(); d = Double.parseDouble(punishTextField[i].getText());
tmpP[i] = d; tmpP[i] = d;
} catch (Exception e) { } catch (Exception e) {

View File

@ -93,7 +93,7 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
for (int i = 0; i < tmpD.length; i++) { for (int i = 0; i < tmpD.length; i++) {
try { try {
int d = 0; int d = 0;
d = new Integer(inputTextField[i].getText()).intValue(); d = Integer.parseInt(inputTextField[i].getText());
tmpD[i] = d; tmpD[i] = d;
} catch (Exception e) { } catch (Exception e) {

View File

@ -38,7 +38,7 @@ public class GenericObjectEditor implements PropertyEditor {
return getClassesFromClassPath(className, instances); return getClassesFromClassPath(className, instances);
} else { } else {
StringTokenizer st = new StringTokenizer(typeOptions, ", "); StringTokenizer st = new StringTokenizer(typeOptions, ", ");
ArrayList<String> classes = new ArrayList<String>(); ArrayList<String> classes = new ArrayList<>();
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
String current = st.nextToken().trim(); String current = st.nextToken().trim();
try { try {
@ -67,7 +67,7 @@ public class GenericObjectEditor implements PropertyEditor {
* @see ReflectPackage.getAssignableClassesInPackage * @see ReflectPackage.getAssignableClassesInPackage
*/ */
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) { public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
ArrayList<String> classes = new ArrayList<String>(); ArrayList<String> classes = new ArrayList<>();
Class<?>[] classArray; Class<?>[] classArray;
classArray = ReflectPackage.getAssignableClasses(className, true, true); classArray = ReflectPackage.getAssignableClasses(className, true, true);
if (classArray == null) { if (classArray == null) {
@ -271,7 +271,7 @@ public class GenericObjectEditor implements PropertyEditor {
} }
Vector<String> v = null; Vector<String> v = null;
v = new Vector<String>(getClassesFromProperties(classType.getName(), null)); v = new Vector<>(getClassesFromProperties(classType.getName(), null));
try { try {
if (v.size() > 0) { if (v.size() > 0) {

View File

@ -205,9 +205,7 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
optimizationObjectives.addTarget((InterfaceOptimizationObjective) optimizationObjectives.getAvailableTargets()[0].clone()); optimizationObjectives.addTarget((InterfaceOptimizationObjective) optimizationObjectives.getAvailableTargets()[0].clone());
int l = optimizationObjectives.getSelectedTargets().length; int l = optimizationObjectives.getSelectedTargets().length;
GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l]; GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l];
for (int i = 0; i < editors.length; i++) { System.arraycopy(editors, 0, newEdit, 0, editors.length);
newEdit[i] = editors[i];
}
InterfaceOptimizationObjective[] list = optimizationObjectives.getSelectedTargets(); InterfaceOptimizationObjective[] list = optimizationObjectives.getSelectedTargets();
l--; l--;
newEdit[l] = new GeneralOptimizationEditorProperty(); newEdit[l] = new GeneralOptimizationEditorProperty();

View File

@ -228,9 +228,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
optimizationObjectivesWithWeights.addTarget((InterfaceOptimizationObjective) optimizationObjectivesWithWeights.getAvailableTargets()[0].clone()); optimizationObjectivesWithWeights.addTarget((InterfaceOptimizationObjective) optimizationObjectivesWithWeights.getAvailableTargets()[0].clone());
int l = optimizationObjectivesWithWeights.getSelectedTargets().length; int l = optimizationObjectivesWithWeights.getSelectedTargets().length;
GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l]; GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l];
for (int i = 0; i < editors.length; i++) { System.arraycopy(editors, 0, newEdit, 0, editors.length);
newEdit[i] = editors[i];
}
InterfaceOptimizationObjective[] list = optimizationObjectivesWithWeights.getSelectedTargets(); InterfaceOptimizationObjective[] list = optimizationObjectivesWithWeights.getSelectedTargets();
l--; l--;
newEdit[l] = new GeneralOptimizationEditorProperty(); newEdit[l] = new GeneralOptimizationEditorProperty();
@ -319,7 +317,7 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
for (int i = 0; i < newW.length; i++) { for (int i = 0; i < newW.length; i++) {
try { try {
double d = 0; double d = 0;
d = new Double(weights[i].getText()).doubleValue(); d = Double.parseDouble(weights[i].getText());
newW[i] = d; newW[i] = d;
} catch (Exception e) { } catch (Exception e) {
} }

View File

@ -97,7 +97,7 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
@Override @Override
public void keyReleased(KeyEvent event) { public void keyReleased(KeyEvent event) {
try { try {
int d = new Integer(pvalueTextField.getText()).intValue(); int d = Integer.parseInt(pvalueTextField.getText());
propertyWeightedLPTchebycheff.p = d; propertyWeightedLPTchebycheff.p = d;
} catch (Exception e) { } catch (Exception e) {
@ -126,14 +126,14 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
try { try {
double d = 0; double d = 0;
d = new Double(idealTextField[i].getText()).doubleValue(); d = Double.parseDouble(idealTextField[i].getText());
tmpT[i] = d; tmpT[i] = d;
} catch (Exception e) { } catch (Exception e) {
} }
try { try {
double d = 0; double d = 0;
d = new Double(weightTextField[i].getText()).doubleValue(); d = Double.parseDouble(weightTextField[i].getText());
tmpP[i] = d; tmpP[i] = d;
} catch (Exception e) { } catch (Exception e) {

View File

@ -59,7 +59,7 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
@Override @Override
public String getAsText() { public String getAsText() {
StringBuffer sbuf = new StringBuffer("{"); StringBuilder sbuf = new StringBuilder("{");
boolean first = true; boolean first = true;
for (int i = 0; i < getElementCount(); i++) { for (int i = 0; i < getElementCount(); i++) {
if (isElementSelected(i)) { if (isElementSelected(i)) {

View File

@ -22,7 +22,7 @@ public class DPointSetMultiIcon extends DComponent {
*/ */
class JumpManager { class JumpManager {
protected int index = -1; protected int index = -1;
protected ArrayList<Integer> jumps = new ArrayList<Integer>(); protected ArrayList<Integer> jumps = new ArrayList<>();
public void addJump() { public void addJump() {
jumps.add(getSize()); jumps.add(getSize());
@ -72,7 +72,7 @@ public class DPointSetMultiIcon extends DComponent {
protected boolean connectedMI; protected boolean connectedMI;
protected DPointIcon iconMI = null; protected DPointIcon iconMI = null;
protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager(); protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager();
protected ArrayList<DPointIcon> iconsMI = new ArrayList<DPointIcon>(); protected ArrayList<DPointIcon> iconsMI = new ArrayList<>();
protected Stroke strokeMI = new BasicStroke(); protected Stroke strokeMI = new BasicStroke();
protected DIntDoubleMap xMI; protected DIntDoubleMap xMI;

View File

@ -82,7 +82,7 @@ public class FunctionArea extends DArea implements Serializable {
setBorder(scaledBorder); setBorder(scaledBorder);
setAutoGrid(true); setAutoGrid(true);
setGridVisible(true); setGridVisible(true);
pointSetContainer = new ArrayList<GraphPointSet>(20); pointSetContainer = new ArrayList<>(20);
// new DMouseZoom( this ); // new DMouseZoom( this );
addPopup(); addPopup();
repaint(); repaint();

View File

@ -97,7 +97,7 @@ public class GraphPointSet {
private DPointIcon icon; private DPointIcon icon;
private String infoString = "Incomplete_Run"; private String infoString = "Incomplete_Run";
private boolean isStatisticsGraph = false; private boolean isStatisticsGraph = false;
private ArrayList<PointSet> pointSetContainer = new ArrayList<PointSet>(); private ArrayList<PointSet> pointSetContainer = new ArrayList<>();
private float stroke = (float) 1.0; private float stroke = (float) 1.0;

View File

@ -49,7 +49,7 @@ public class GraphPointSetLegend {
* @param appendIndex if true, the string entries are enumerated according to the index * @param appendIndex if true, the string entries are enumerated according to the index
*/ */
public GraphPointSetLegend(List<GraphPointSet> pointSetContainer, boolean appendIndex) { public GraphPointSetLegend(List<GraphPointSet> pointSetContainer, boolean appendIndex) {
legendEntries = new TreeSet<Pair<String, Color>>(comparator); legendEntries = new TreeSet<>(comparator);
for (int i = 0; i < pointSetContainer.size(); i++) { for (int i = 0; i < pointSetContainer.size(); i++) {
GraphPointSet pointset = pointSetContainer.get(i); GraphPointSet pointset = pointSetContainer.get(i);
if (pointset.getPointSet().getSize() > 0) { if (pointset.getPointSet().getSize() > 0) {
@ -59,7 +59,7 @@ public class GraphPointSetLegend {
} else { } else {
entryStr = pointset.getInfoString(); entryStr = pointset.getInfoString();
} }
legendEntries.add(new Pair<String, Color>(entryStr, pointset.getColor())); legendEntries.add(new Pair<>(entryStr, pointset.getColor()));
} }
} }
} }

View File

@ -10,7 +10,7 @@ public class OptimizationRun {
List<Double> fitness; List<Double> fitness;
public OptimizationRun() { public OptimizationRun() {
this.fitness = new ArrayList<Double>(); this.fitness = new ArrayList<>();
} }
public void addFitnessValue(double value) { public void addFitnessValue(double value) {

View File

@ -32,7 +32,7 @@ public class ModuleServer {
if (instanceCounter > 0) { if (instanceCounter > 0) {
EVAERROR.EXIT("ModuleServer created twice"); EVAERROR.EXIT("ModuleServer created twice");
} }
moduleClassList = new ArrayList<Class<?>>(); moduleClassList = new ArrayList<>();
String modulePckg = null; String modulePckg = null;
Class<?> filterBy = null; Class<?> filterBy = null;
@ -63,7 +63,7 @@ public class ModuleServer {
* @return Array of available modules * @return Array of available modules
*/ */
public String[] getModuleNameList() { public String[] getModuleNameList() {
List<String> moduleNameList = new ArrayList<String>(); List<String> moduleNameList = new ArrayList<>();
for (Class<?> module : moduleClassList) { for (Class<?> module : moduleClassList) {
try { try {
Method[] methods = module.getDeclaredMethods(); Method[] methods = module.getDeclaredMethods();

View File

@ -557,7 +557,7 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
// data to be stored in file // data to be stored in file
double tmpd = 0; double tmpd = 0;
StringBuffer tmpLine = new StringBuffer(""); StringBuilder tmpLine = new StringBuilder("");
tmpLine.append(population.getFunctionCalls()); tmpLine.append(population.getFunctionCalls());
tmpLine.append("\t"); tmpLine.append("\t");
tmpLine.append(population.getBestEAIndividual().getFitness(0)); tmpLine.append(population.getBestEAIndividual().getFitness(0));

View File

@ -46,7 +46,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
protected InterfaceMutation mutationOperator = new NoMutation(); protected InterfaceMutation mutationOperator = new NoMutation();
protected InterfaceCrossover crossoverOperator = new NoCrossover(); protected InterfaceCrossover crossoverOperator = new NoCrossover();
protected InterfaceInitialization initializationOperator = new DefaultInitialization(); protected InterfaceInitialization initializationOperator = new DefaultInitialization();
protected HashMap<String, Object> dataHash = new HashMap<String, Object>(); protected HashMap<String, Object> dataHash = new HashMap<>();
// introduced for the nichingPSO/ANPSO (M.Aschoff) // introduced for the nichingPSO/ANPSO (M.Aschoff)
private int individualIndex = -1; private int individualIndex = -1;
@ -156,9 +156,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
parentIDs = new Long[individual.parentIDs.length]; parentIDs = new Long[individual.parentIDs.length];
System.arraycopy(individual.parentIDs, 0, parentIDs, 0, parentIDs.length); System.arraycopy(individual.parentIDs, 0, parentIDs, 0, parentIDs.length);
parentTree = new AbstractEAIndividual[individual.parentTree.length]; parentTree = new AbstractEAIndividual[individual.parentTree.length];
for (int i = 0; i < parentTree.length; i++) { System.arraycopy(individual.parentTree, 0, parentTree, 0, parentTree.length);
parentTree[i] = individual.parentTree[i];
}
} }
} }
@ -406,7 +404,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
} }
public String getHeritageTree(int depth) { public String getHeritageTree(int depth) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append(getIndyID()); sb.append(getIndyID());
sb.append(" "); sb.append(" ");
if ((depth > 0) && (parentTree != null)) { if ((depth > 0) && (parentTree != null)) {
@ -596,9 +594,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
this.fitness[index] = fitness; this.fitness[index] = fitness;
} else { } else {
double[] tmpD = new double[index + 1]; double[] tmpD = new double[index + 1];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(this.fitness, 0, tmpD, 0, this.fitness.length);
tmpD[i] = this.fitness[i];
}
this.fitness = tmpD; this.fitness = tmpD;
this.fitness[index] = fitness; this.fitness[index] = fitness;
} }
@ -833,9 +829,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
this.selectionProbability[index] = sel; this.selectionProbability[index] = sel;
} else { } else {
double[] tmpD = new double[index + 1]; double[] tmpD = new double[index + 1];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(this.selectionProbability, 0, tmpD, 0, this.selectionProbability.length);
tmpD[i] = this.selectionProbability[i];
}
this.selectionProbability = tmpD; this.selectionProbability = tmpD;
this.selectionProbability[index] = sel; this.selectionProbability[index] = sel;
} }

View File

@ -53,13 +53,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -54,13 +54,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -49,13 +49,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -65,13 +65,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -36,13 +36,9 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -51,13 +51,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -59,15 +59,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.precision = individual.precision; this.precision = individual.precision;
this.doubleCoding = individual.doubleCoding; this.doubleCoding = individual.doubleCoding;
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -59,14 +59,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.intergerCoding = individual.intergerCoding; this.intergerCoding = individual.intergerCoding;
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -33,13 +33,9 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -97,13 +97,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -59,13 +59,9 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }
@ -184,9 +180,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
@Override @Override
public int[] getIntegerData() { public int[] getIntegerData() {
this.phenotype = new int[this.initializationRange.length]; this.phenotype = new int[this.initializationRange.length];
for (int i = 0; i < this.phenotype.length; i++) { System.arraycopy(this.genotype, 0, this.phenotype, 0, this.phenotype.length);
this.phenotype[i] = this.genotype[i];
}
return this.phenotype; return this.phenotype;
} }
@ -221,9 +215,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
public void setIntGenotype(int[] doubleData) { public void setIntGenotype(int[] doubleData) {
this.setIntPhenotype(doubleData); this.setIntPhenotype(doubleData);
this.genotype = new int[this.initializationRange.length]; this.genotype = new int[this.initializationRange.length];
for (int i = 0; i < doubleData.length; i++) { System.arraycopy(doubleData, 0, this.genotype, 0, doubleData.length);
this.genotype[i] = doubleData[i];
}
} }
/************************************************************************************ /************************************************************************************

View File

@ -33,13 +33,9 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -68,13 +68,9 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
cloneAEAObjects(individual); cloneAEAObjects(individual);
} }

View File

@ -52,13 +52,9 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone(); this.mutationOperator = (InterfaceMutation) individual.mutationOperator.clone();
this.mutationProbability = individual.mutationProbability; this.mutationProbability = individual.mutationProbability;
this.selectionProbability = new double[individual.selectionProbability.length]; this.selectionProbability = new double[individual.selectionProbability.length];
for (int i = 0; i < this.selectionProbability.length; i++) { System.arraycopy(individual.selectionProbability, 0, this.selectionProbability, 0, this.selectionProbability.length);
this.selectionProbability[i] = individual.selectionProbability[i];
}
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { System.arraycopy(individual.fitness, 0, this.fitness, 0, this.fitness.length);
this.fitness[i] = individual.fitness[i];
}
this.cloneAEAObjects(individual); this.cloneAEAObjects(individual);
} }

View File

@ -144,7 +144,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
((GPNodeInput) currentNode).setIdentifier(currentNode.getOpIdentifier()); ((GPNodeInput) currentNode).setIdentifier(currentNode.getOpIdentifier());
} }
} }
return new Pair<AbstractGPNode, String>(currentNode, restStr); return new Pair<>(currentNode, restStr);
} else { } else {
restStr = str.substring(cutFront + 1).trim(); // cut this op and front brace restStr = str.substring(cutFront + 1).trim(); // cut this op and front brace
currentNode.nodes = new AbstractGPNode[currentNode.getArity()]; currentNode.nodes = new AbstractGPNode[currentNode.getArity()];
@ -159,7 +159,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
e.printStackTrace(); e.printStackTrace();
} }
} }
return new Pair<AbstractGPNode, String>(currentNode, restStr); return new Pair<>(currentNode, restStr);
} }
} }
} }
@ -175,7 +175,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
*/ */
public static Vector<AbstractGPNode> getNodeTypes() { public static Vector<AbstractGPNode> getNodeTypes() {
ArrayList<String> cls = GenericObjectEditor.getClassesFromClassPath(AbstractGPNode.class.getCanonicalName(), null); ArrayList<String> cls = GenericObjectEditor.getClassesFromClassPath(AbstractGPNode.class.getCanonicalName(), null);
Vector<AbstractGPNode> nodeTypes = new Vector<AbstractGPNode>(cls.size()); Vector<AbstractGPNode> nodeTypes = new Vector<>(cls.size());
for (int i = 0; i < cls.size(); i++) { for (int i = 0; i < cls.size(); i++) {
try { try {
AbstractGPNode node = (AbstractGPNode) Class.forName((String) cls.get(i)).newInstance(); AbstractGPNode node = (AbstractGPNode) Class.forName((String) cls.get(i)).newInstance();
@ -206,7 +206,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
} }
try { try {
Double d = Double.parseDouble(firstArg); Double d = Double.parseDouble(firstArg);
return new Pair<Double, String>(d, str.substring(firstArg.length())); return new Pair<>(d, str.substring(firstArg.length()));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
if (expect) { if (expect) {
System.err.println("String has unknown prefix: " + str); System.err.println("String has unknown prefix: " + str);
@ -246,7 +246,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
*/ */
private static Vector<AbstractGPNode> match( private static Vector<AbstractGPNode> match(
Vector<AbstractGPNode> nodeTypes, String str, boolean firstLongestOnly, boolean ignoreCase) { Vector<AbstractGPNode> nodeTypes, String str, boolean firstLongestOnly, boolean ignoreCase) {
Vector<AbstractGPNode> matching = new Vector<AbstractGPNode>(); Vector<AbstractGPNode> matching = new Vector<>();
for (int i = 0; i < nodeTypes.size(); i++) { for (int i = 0; i < nodeTypes.size(); i++) {
String reqPrefix = nodeTypes.get(i).getOpIdentifier(); String reqPrefix = nodeTypes.get(i).getOpIdentifier();
if (nodeTypes.get(i).getArity() > 0) { if (nodeTypes.get(i).getArity() > 0) {
@ -261,7 +261,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
if (matching.size() > 1 && firstLongestOnly) { // allow only the longest match (or first longest) if (matching.size() > 1 && firstLongestOnly) { // allow only the longest match (or first longest)
int maxLen = matching.get(0).getOpIdentifier().length(); int maxLen = matching.get(0).getOpIdentifier().length();
AbstractGPNode longest = matching.get(0); AbstractGPNode longest = matching.get(0);
Vector<AbstractGPNode> longestList = new Vector<AbstractGPNode>(); Vector<AbstractGPNode> longestList = new Vector<>();
longestList.add(longest); longestList.add(longest);
for (int i = 1; i < matching.size(); i++) { for (int i = 1; i < matching.size(); i++) {
if (matching.get(i).getOpIdentifier().length() > maxLen) { if (matching.get(i).getOpIdentifier().length() > maxLen) {
@ -338,7 +338,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @return * @return
*/ */
public static String createNodeList() { public static String createNodeList() {
String ret = new String(); String ret = "";
Class<?> cls = AbstractGPNode.class; Class<?> cls = AbstractGPNode.class;
Class<?>[] nodes = ReflectPackage.getAssignableClassesInPackage(cls.getPackage().getName(), AbstractGPNode.class, true, false); Class<?>[] nodes = ReflectPackage.getAssignableClassesInPackage(cls.getPackage().getName(), AbstractGPNode.class, true, false);

View File

@ -18,9 +18,9 @@ public class GPArea implements java.io.Serializable {
*/ */
private transient PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); private transient PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
private ArrayList<AbstractGPNode> completeList = new ArrayList<AbstractGPNode>(); private ArrayList<AbstractGPNode> completeList = new ArrayList<>();
private ArrayList<AbstractGPNode> reducedList = new ArrayList<AbstractGPNode>(); private ArrayList<AbstractGPNode> reducedList = new ArrayList<>();
private ArrayList<Boolean> blackList = new ArrayList<Boolean>(); private ArrayList<Boolean> blackList = new ArrayList<>();
public GPArea() { public GPArea() {
@ -50,7 +50,7 @@ public class GPArea implements java.io.Serializable {
*/ */
public void add2CompleteList(AbstractGPNode n) { public void add2CompleteList(AbstractGPNode n) {
this.completeList.add(n); this.completeList.add(n);
this.blackList.add(new Boolean(true)); this.blackList.add(Boolean.TRUE);
} }
/** /**
@ -61,7 +61,7 @@ public class GPArea implements java.io.Serializable {
*/ */
public void add2CompleteList(AbstractGPNode n, boolean b) { public void add2CompleteList(AbstractGPNode n, boolean b) {
this.completeList.add(n); this.completeList.add(n);
this.blackList.add(new Boolean(b)); this.blackList.add(Boolean.valueOf(b));
} }
/** /**
@ -89,7 +89,7 @@ public class GPArea implements java.io.Serializable {
* @param b the boolean value * @param b the boolean value
*/ */
public void setBlackListElement(int i, boolean b) { public void setBlackListElement(int i, boolean b) {
this.blackList.set(i, new Boolean(b)); this.blackList.set(i, Boolean.valueOf(b));
} }
/** /**
@ -124,7 +124,7 @@ public class GPArea implements java.io.Serializable {
* This method compiles the Complete List to the allowed list using the BlackList * This method compiles the Complete List to the allowed list using the BlackList
*/ */
public void compileReducedList() { public void compileReducedList() {
this.reducedList = new ArrayList<AbstractGPNode>(); this.reducedList = new ArrayList<>();
for (int i = 0; i < this.completeList.size(); i++) { for (int i = 0; i < this.completeList.size(); i++) {
if (this.blackList.get(i).booleanValue()) { if (this.blackList.get(i).booleanValue()) {
this.reducedList.add(this.completeList.get(i)); this.reducedList.add(this.completeList.get(i));
@ -139,7 +139,7 @@ public class GPArea implements java.io.Serializable {
* @param targetarity The target arity. * @param targetarity The target arity.
*/ */
public AbstractGPNode getRandomNodeWithArity(int targetarity) { public AbstractGPNode getRandomNodeWithArity(int targetarity) {
ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>(); ArrayList<AbstractGPNode> tmpArray = new ArrayList<>();
for (int i = 0; i < this.reducedList.size(); i++) { for (int i = 0; i < this.reducedList.size(); i++) {
if (this.reducedList.get(i).getArity() == targetarity) { if (this.reducedList.get(i).getArity() == targetarity) {
tmpArray.add(this.reducedList.get(i)); tmpArray.add(this.reducedList.get(i));
@ -167,7 +167,7 @@ public class GPArea implements java.io.Serializable {
* This method will return a non terminal * This method will return a non terminal
*/ */
public AbstractGPNode getRandomNonTerminal() { public AbstractGPNode getRandomNonTerminal() {
ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>(); ArrayList<AbstractGPNode> tmpArray = new ArrayList<>();
for (int i = 0; i < this.reducedList.size(); i++) { for (int i = 0; i < this.reducedList.size(); i++) {
if (this.reducedList.get(i).getArity() > 0) { if (this.reducedList.get(i).getArity() > 0) {
tmpArray.add(this.reducedList.get(i)); tmpArray.add(this.reducedList.get(i));
@ -185,9 +185,9 @@ public class GPArea implements java.io.Serializable {
} }
public void clear() { public void clear() {
completeList = new ArrayList<AbstractGPNode>(); completeList = new ArrayList<>();
reducedList = new ArrayList<AbstractGPNode>(); reducedList = new ArrayList<>();
blackList = new ArrayList<Boolean>(); blackList = new ArrayList<>();
propertyChangeSupport.firePropertyChange("GPArea", null, this); propertyChangeSupport.firePropertyChange("GPArea", null, this);
} }

View File

@ -99,7 +99,7 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
for (int i = 0; i < textField.length; i++) { for (int i = 0; i < textField.length; i++) {
mocco.view.referencePoint[i] = new Double(textField[i].getText()).doubleValue(); mocco.view.referencePoint[i] = Double.parseDouble(textField[i].getText());
} }
mocco.view.problemChanged(false); mocco.view.problemChanged(false);
} }

View File

@ -69,7 +69,7 @@ public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceP
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
String s = textField.getText(); String s = textField.getText();
try { try {
int t = new Integer(s).intValue(); int t = Integer.parseInt(s);
mocco.state.initialPopulationSize = t; mocco.state.initialPopulationSize = t;
} catch (java.lang.NumberFormatException e) { } catch (java.lang.NumberFormatException e) {

View File

@ -204,7 +204,7 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
double[] w = new double[tradeOffTextFields.length]; double[] w = new double[tradeOffTextFields.length];
double sum = 0; double sum = 0;
for (int i = 0; i < tradeOffTextFields.length; i++) { for (int i = 0; i < tradeOffTextFields.length; i++) {
w[i] = new Double(tradeOffTextFields[i][i].getText()).doubleValue(); w[i] = Double.parseDouble(tradeOffTextFields[i][i].getText());
sum += w[i]; sum += w[i];
} }
if (new Double(sum).isNaN()) { if (new Double(sum).isNaN()) {
@ -226,7 +226,7 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
double[] w = new double[tradeOffTextFields.length]; double[] w = new double[tradeOffTextFields.length];
for (int i = 0; i < tradeOffTextFields.length; i++) { for (int i = 0; i < tradeOffTextFields.length; i++) {
w[i] = new Double(tradeOffTextFields[i][i].getText()).doubleValue(); w[i] = Double.parseDouble(tradeOffTextFields[i][i].getText());
} }
MOSOWeightedFitness wf = new MOSOWeightedFitness(); MOSOWeightedFitness wf = new MOSOWeightedFitness();
// I've to set this before I change the parameters, because the problem sets the // I've to set this before I change the parameters, because the problem sets the

View File

@ -217,12 +217,12 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
// first read the values // first read the values
try { try {
perturbations = new Integer(numPerTextField.getText()).intValue(); perturbations = Integer.parseInt(numPerTextField.getText());
} catch (java.lang.NumberFormatException e) { } catch (java.lang.NumberFormatException e) {
System.out.println("Can't read k."); System.out.println("Can't read k.");
} }
try { try {
perturbation = new Double(sizePerTextField.getText()).doubleValue(); perturbation = Double.parseDouble(sizePerTextField.getText());
} catch (java.lang.NumberFormatException e) { } catch (java.lang.NumberFormatException e) {
System.out.println("Can't read amount of perturbation."); System.out.println("Can't read amount of perturbation.");
} }

View File

@ -263,8 +263,8 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
weights = new double[refSolTextField.length]; weights = new double[refSolTextField.length];
relax = new double[refSolTextField.length]; relax = new double[refSolTextField.length];
for (int i = 0; i < refSolTextField.length; i++) { for (int i = 0; i < refSolTextField.length; i++) {
weights[i] = new Double(weightTextField[i].getText()).doubleValue(); weights[i] = Double.parseDouble(weightTextField[i].getText());
relax[i] = new Double(relaxTextField[i].getText()).doubleValue(); relax[i] = Double.parseDouble(relaxTextField[i].getText());
if ((satisfied[i].isSelected()) && (obj[i].getOptimizationMode().contains("Objective"))) { if ((satisfied[i].isSelected()) && (obj[i].getOptimizationMode().contains("Objective"))) {
weights[i] = 0; weights[i] = 0;
if (obj[i].is2BMinimized()) { if (obj[i].is2BMinimized()) {

View File

@ -219,7 +219,7 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
// first read the values // first read the values
try { try {
perturbations = new Integer(numPer.getText()).intValue(); perturbations = Integer.parseInt(numPer.getText());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
System.out.println("Can't read k."); System.out.println("Can't read k.");
} }
@ -251,11 +251,11 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
sum = 0; sum = 0;
for (int j = 0; j < tmpD.length; j++) { for (int j = 0; j < tmpD.length; j++) {
try { try {
l = new Double(lowerLimit[j].getText()).doubleValue(); l = Double.parseDouble(lowerLimit[j].getText());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
try { try {
u = new Double(upperLimit[j].getText()).doubleValue(); u = Double.parseDouble(upperLimit[j].getText());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
if (l < 0) { if (l < 0) {

View File

@ -95,9 +95,7 @@ public class MOCCOState {
} }
Population[] newPop = new Population[this.populationHistory.length + 1]; Population[] newPop = new Population[this.populationHistory.length + 1];
for (int i = 0; i < this.populationHistory.length; i++) { System.arraycopy(this.populationHistory, 0, newPop, 0, this.populationHistory.length);
newPop[i] = this.populationHistory[i];
}
newPop[newPop.length - 1] = (Population) pop.clone(); newPop[newPop.length - 1] = (Population) pop.clone();
newPop[newPop.length - 1].addPopulation(newPop[newPop.length - 1].getArchive()); newPop[newPop.length - 1].addPopulation(newPop[newPop.length - 1].getArchive());
newPop[newPop.length - 1].SetArchive(null); newPop[newPop.length - 1].SetArchive(null);

View File

@ -23,7 +23,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
protected AbstractModuleAdapter() { protected AbstractModuleAdapter() {
instanceCounter++; instanceCounter++;
instanceNumber = instanceCounter; instanceNumber = instanceCounter;
optimizationStateListeners = new ArrayList<OptimizationStateListener>(); optimizationStateListeners = new ArrayList<>();
} }
/** /**

View File

@ -157,7 +157,7 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
@Override @Override
public void addInformableInstance(InterfaceNotifyOnInformers o) { public void addInformableInstance(InterfaceNotifyOnInformers o) {
if (toInformAboutInformers == null) { if (toInformAboutInformers == null) {
toInformAboutInformers = new LinkedList<InterfaceNotifyOnInformers>(); toInformAboutInformers = new LinkedList<>();
} }
if (!toInformAboutInformers.contains(o)) { if (!toInformAboutInformers.contains(o)) {
toInformAboutInformers.add(o); toInformAboutInformers.add(o);
@ -193,7 +193,7 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
} }
private List<InterfaceAdditionalPopulationInformer> getInformerList() { private List<InterfaceAdditionalPopulationInformer> getInformerList() {
LinkedList<InterfaceAdditionalPopulationInformer> ret = new LinkedList<InterfaceAdditionalPopulationInformer>(); LinkedList<InterfaceAdditionalPopulationInformer> ret = new LinkedList<>();
if (problem instanceof InterfaceAdditionalPopulationInformer) { if (problem instanceof InterfaceAdditionalPopulationInformer) {
ret.add(problem); ret.add(problem);
} }

View File

@ -9,12 +9,10 @@ import eva2.optimization.operator.paramcontrol.ConstantParameters;
import eva2.optimization.operator.paramcontrol.InterfaceParameterControl; import eva2.optimization.operator.paramcontrol.InterfaceParameterControl;
import eva2.optimization.operator.postprocess.PostProcess; import eva2.optimization.operator.postprocess.PostProcess;
import eva2.optimization.operator.postprocess.PostProcessParams; import eva2.optimization.operator.postprocess.PostProcessParams;
import eva2.optimization.operator.postprocess.SolutionHistogram;
import eva2.optimization.operator.terminators.EvaluationTerminator; import eva2.optimization.operator.terminators.EvaluationTerminator;
import eva2.optimization.operator.terminators.GenerationTerminator; import eva2.optimization.operator.terminators.GenerationTerminator;
import eva2.optimization.operator.terminators.InterfaceTerminator; import eva2.optimization.operator.terminators.InterfaceTerminator;
import eva2.optimization.population.Population; import eva2.optimization.population.Population;
import eva2.optimization.population.PopulationInterface;
import eva2.problems.AbstractOptimizationProblem; import eva2.problems.AbstractOptimizationProblem;
import eva2.problems.InterfaceAdditionalPopulationInformer; import eva2.problems.InterfaceAdditionalPopulationInformer;
import eva2.optimization.stat.InterfaceStatistics; import eva2.optimization.stat.InterfaceStatistics;
@ -398,7 +396,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
} }
protected List<InterfaceAdditionalPopulationInformer> getInformerList() { protected List<InterfaceAdditionalPopulationInformer> getInformerList() {
List<InterfaceAdditionalPopulationInformer> informerList = new ArrayList<InterfaceAdditionalPopulationInformer>(2); List<InterfaceAdditionalPopulationInformer> informerList = new ArrayList<>(2);
informerList.add(this.optimizationParameters.getProblem()); informerList.add(this.optimizationParameters.getProblem());
if (this.optimizationParameters.getOptimizer() instanceof InterfaceAdditionalPopulationInformer) { if (this.optimizationParameters.getOptimizer() instanceof InterfaceAdditionalPopulationInformer) {
informerList.add((InterfaceAdditionalPopulationInformer) this.optimizationParameters.getOptimizer()); informerList.add((InterfaceAdditionalPopulationInformer) this.optimizationParameters.getOptimizer());

View File

@ -45,9 +45,7 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
this.SOM = new double[a.SOM.length][a.SOM[0].length][a.SOM[0][0].length]; this.SOM = new double[a.SOM.length][a.SOM[0].length][a.SOM[0][0].length];
for (int i = 0; i < a.SOM.length; i++) { for (int i = 0; i < a.SOM.length; i++) {
for (int j = 0; j < a.SOM[0].length; j++) { for (int j = 0; j < a.SOM[0].length; j++) {
for (int k = 0; k < a.SOM[0][0].length; k++) { System.arraycopy(a.SOM[i][j], 0, this.SOM[i][j], 0, a.SOM[0][0].length);
this.SOM[i][j][k] = a.SOM[i][j][k];
}
} }
} }
} }
@ -55,9 +53,7 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
this.SOMClass = new int[a.SOMClass.length][a.SOMClass[0].length][a.SOMClass[0][0].length]; this.SOMClass = new int[a.SOMClass.length][a.SOMClass[0].length][a.SOMClass[0][0].length];
for (int i = 0; i < a.SOMClass.length; i++) { for (int i = 0; i < a.SOMClass.length; i++) {
for (int j = 0; j < a.SOMClass[0].length; j++) { for (int j = 0; j < a.SOMClass[0].length; j++) {
for (int k = 0; k < a.SOMClass[0][0].length; k++) { System.arraycopy(a.SOMClass[i][j], 0, this.SOMClass[i][j], 0, a.SOMClass[0][0].length);
this.SOMClass[i][j][k] = a.SOMClass[i][j][k];
}
} }
} }
} }

View File

@ -64,16 +64,12 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
this.minimumGroupSize = a.minimumGroupSize; this.minimumGroupSize = a.minimumGroupSize;
if (a.clustered != null) { if (a.clustered != null) {
this.clustered = new boolean[a.clustered.length]; this.clustered = new boolean[a.clustered.length];
for (int i = 0; i < this.clustered.length; i++) { System.arraycopy(a.clustered, 0, this.clustered, 0, this.clustered.length);
this.clustered[i] = a.clustered[i];
}
} }
if (a.connectionMatrix != null) { if (a.connectionMatrix != null) {
this.connectionMatrix = new boolean[a.connectionMatrix.length][a.connectionMatrix[0].length]; this.connectionMatrix = new boolean[a.connectionMatrix.length][a.connectionMatrix[0].length];
for (int i = 0; i < this.connectionMatrix.length; i++) { for (int i = 0; i < this.connectionMatrix.length; i++) {
for (int j = 0; j < this.connectionMatrix[i].length; j++) { System.arraycopy(a.connectionMatrix[i], 0, this.connectionMatrix[i], 0, this.connectionMatrix[i].length);
this.connectionMatrix[i][j] = a.connectionMatrix[i][j];
}
} }
} }
} }
@ -95,7 +91,7 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
clustered = new boolean[pop.size()]; clustered = new boolean[pop.size()];
AbstractEAIndividual tmpIndy1, tmpIndy2; AbstractEAIndividual tmpIndy1, tmpIndy2;
Population PopulationOfUnclustered, Cluster, template; Population PopulationOfUnclustered, Cluster, template;
ArrayList<Population> ClusteredPopulations = new ArrayList<Population>(); ArrayList<Population> ClusteredPopulations = new ArrayList<>();
template = (Population) pop.clone(); template = (Population) pop.clone();
template.clear(); template.clear();

View File

@ -123,9 +123,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
numbOfAssigned = new int[this.k]; numbOfAssigned = new int[this.k];
for (int i = 0; i < newC.length; i++) { for (int i = 0; i < newC.length; i++) {
numbOfAssigned[i] = 1; numbOfAssigned[i] = 1;
for (int j = 0; j < newC[i].length; j++) { System.arraycopy(this.c[i], 0, newC[i], 0, newC[i].length);
newC[i][j] = this.c[i][j];
}
} }
for (int i = 0; i < assignment.length; i++) { for (int i = 0; i < assignment.length; i++) {
numbOfAssigned[assignment[i]]++; numbOfAssigned[assignment[i]]++;

View File

@ -1,6 +1,5 @@
package eva2.optimization.operator.cluster; package eva2.optimization.operator.cluster;
import eva2.gui.BeanInspector;
import eva2.gui.editor.GenericObjectEditor; import eva2.gui.editor.GenericObjectEditor;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.individuals.AbstractEAIndividualComparator; import eva2.optimization.individuals.AbstractEAIndividualComparator;
@ -258,7 +257,7 @@ public class ClusteringNearestBetter implements InterfaceClustering, Serializabl
// Mark them as clustered and start with the next best unclustered. // Mark them as clustered and start with the next best unclustered.
int current = 0; // top indy is first int current = 0; // top indy is first
boolean[] clustered = new boolean[pop.size()]; boolean[] clustered = new boolean[pop.size()];
LinkedList<Population> allClusters = new LinkedList<Population>(); LinkedList<Population> allClusters = new LinkedList<>();
while (current < sorted.size()) { while (current < sorted.size()) {
Population currentClust = pop.cloneWithoutInds(); Population currentClust = pop.cloneWithoutInds();
currentClust.add(sorted.get(current)); currentClust.add(sorted.get(current));
@ -270,7 +269,7 @@ public class ClusteringNearestBetter implements InterfaceClustering, Serializabl
while (current < sorted.size() && (clustered[current])) current++; while (current < sorted.size() && (clustered[current])) current++;
} }
ArrayList<Population> finalClusts = new ArrayList<Population>(allClusters.size()); ArrayList<Population> finalClusts = new ArrayList<>(allClusters.size());
finalClusts.add(pop.cloneWithoutInds()); finalClusts.add(pop.cloneWithoutInds());
for (Population clust : allClusters) { for (Population clust : allClusters) {
if (clust.size() < minimumGroupSize) { // add to loner population if (clust.size() < minimumGroupSize) { // add to loner population
@ -322,7 +321,7 @@ public class ClusteringNearestBetter implements InterfaceClustering, Serializabl
} }
// the closest best for indy i is now known. connect them in the graph. // the closest best for indy i is now known. connect them in the graph.
if (children[uplink[i]] == null) { if (children[uplink[i]] == null) {
children[uplink[i]] = new Vector<Integer>(); children[uplink[i]] = new Vector<>();
} }
children[uplink[i]].add(i); children[uplink[i]].add(i);
edgeLengthSum += uplinkDist[i]; edgeLengthSum += uplinkDist[i];

View File

@ -92,9 +92,7 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
} }
double[][] nParents = new double[parents.length - 1][]; double[][] nParents = new double[parents.length - 1][];
for (int i = 1; i < parents.length; i++) { System.arraycopy(parents, 1, nParents, 0, parents.length - 1);
nParents[i - 1] = parents[i];
}
double[] g = Mathematics.meanVect(nParents), tmpD; double[] g = Mathematics.meanVect(nParents), tmpD;
double w, v; double w, v;
ArrayList givenCoordinates = this.getGivenCoordinates(g, nParents); ArrayList givenCoordinates = this.getGivenCoordinates(g, nParents);
@ -103,9 +101,7 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
// now determine the offsprings // now determine the offsprings
for (int i = 0; i < children.length; i++) { for (int i = 0; i < children.length; i++) {
// first the mean // first the mean
for (int j = 0; j < g.length; j++) { System.arraycopy(g, 0, children[i], 0, g.length);
children[i][j] = g[j];
}
// then the given coordinates // then the given coordinates
for (int j = 0; j < givenCoordinates.size(); j++) { for (int j = 0; j < givenCoordinates.size(); j++) {
tmpD = (double[]) givenCoordinates.get(j); tmpD = (double[]) givenCoordinates.get(j);

View File

@ -1,7 +1,6 @@
package eva2.optimization.operator.crossover; package eva2.optimization.operator.crossover;
import eva2.gui.BeanInspector;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.individuals.InterfaceGAIndividual; import eva2.optimization.individuals.InterfaceGAIndividual;
import eva2.optimization.individuals.InterfaceGIIndividual; import eva2.optimization.individuals.InterfaceGIIndividual;

View File

@ -26,10 +26,7 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
this.weightsLabel = d.weightsLabel; this.weightsLabel = d.weightsLabel;
this.normalizationEnabled = d.normalizationEnabled; this.normalizationEnabled = d.normalizationEnabled;
this.availableTargets = new InterfaceCrossover[d.availableTargets.length]; this.availableTargets = new InterfaceCrossover[d.availableTargets.length];
for (int i = 0; i < this.availableTargets.length; i++) { System.arraycopy(d.availableTargets, 0, this.availableTargets, 0, this.availableTargets.length);
//this.availableTargets[i] = (InterfaceMutation)d.availableTargets[i].clone();
this.availableTargets[i] = d.availableTargets[i];
}
this.selectedTargets = new InterfaceCrossover[d.selectedTargets.length]; this.selectedTargets = new InterfaceCrossover[d.selectedTargets.length];
for (int i = 0; i < this.selectedTargets.length; i++) { for (int i = 0; i < this.selectedTargets.length; i++) {
this.selectedTargets[i] = (InterfaceCrossover) d.selectedTargets[i].clone(); this.selectedTargets[i] = (InterfaceCrossover) d.selectedTargets[i].clone();
@ -67,15 +64,11 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
if (d.length > this.weights.length) { if (d.length > this.weights.length) {
double[] newWeights = new double[d.length]; double[] newWeights = new double[d.length];
for (int i = 0; i < this.weights.length; i++) { System.arraycopy(this.weights, 0, newWeights, 0, this.weights.length);
newWeights[i] = this.weights[i];
}
this.weights = newWeights; this.weights = newWeights;
} else { } else {
double[] newWeights = new double[d.length]; double[] newWeights = new double[d.length];
for (int i = 0; i < d.length; i++) { System.arraycopy(this.weights, 0, newWeights, 0, d.length);
newWeights[i] = this.weights[i];
}
this.weights = newWeights; this.weights = newWeights;
} }
} }

View File

@ -229,9 +229,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
crossoverMixer.addCrossers((InterfaceCrossover) crossoverMixer.getAvailableCrossers()[0].clone()); crossoverMixer.addCrossers((InterfaceCrossover) crossoverMixer.getAvailableCrossers()[0].clone());
int l = crossoverMixer.getSelectedCrossers().length; int l = crossoverMixer.getSelectedCrossers().length;
GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l]; GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l];
for (int i = 0; i < editors.length; i++) { System.arraycopy(editors, 0, newEdit, 0, editors.length);
newEdit[i] = editors[i];
}
InterfaceCrossover[] list = crossoverMixer.getSelectedCrossers(); InterfaceCrossover[] list = crossoverMixer.getSelectedCrossers();
l--; l--;
newEdit[l] = new GeneralOptimizationEditorProperty(); newEdit[l] = new GeneralOptimizationEditorProperty();
@ -310,7 +308,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
for (int i = 0; i < newW.length; i++) { for (int i = 0; i < newW.length; i++) {
try { try {
double d = 0; double d = 0;
d = new Double(weights[i].getText()).doubleValue(); d = Double.parseDouble(weights[i].getText());
newW[i] = d; newW[i] = d;
} catch (Exception e) { } catch (Exception e) {
} }

View File

@ -1,6 +1,5 @@
package eva2.optimization.operator.mutation; package eva2.optimization.operator.mutation;
import eva2.gui.BeanInspector;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.individuals.InterfaceESIndividual; import eva2.optimization.individuals.InterfaceESIndividual;
import eva2.optimization.population.Population; import eva2.optimization.population.Population;
@ -178,7 +177,7 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab
*/ */
@Override @Override
public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, Population partners) { public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, Population partners) {
ArrayList<Double> tmpList = new ArrayList<Double>(); ArrayList<Double> tmpList = new ArrayList<>();
if (indy1.getMutationOperator() instanceof MutateESCorrVector) { if (indy1.getMutationOperator() instanceof MutateESCorrVector) {
tmpList.add(((MutateESCorrVector) indy1.getMutationOperator()).scalingDev); tmpList.add(((MutateESCorrVector) indy1.getMutationOperator()).scalingDev);
} }

View File

@ -30,16 +30,12 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab
public MutateESCorrolated(MutateESCorrolated mutator) { public MutateESCorrolated(MutateESCorrolated mutator) {
if ((mutator.sigmas != null)) { if ((mutator.sigmas != null)) {
this.sigmas = new double[mutator.sigmas.length]; this.sigmas = new double[mutator.sigmas.length];
for (int i = 0; i < this.sigmas.length; i++) { System.arraycopy(mutator.sigmas, 0, this.sigmas, 0, this.sigmas.length);
this.sigmas[i] = mutator.sigmas[i];
}
} }
if (mutator.alphas != null) { if (mutator.alphas != null) {
this.alphas = new double[mutator.alphas.length]; this.alphas = new double[mutator.alphas.length];
for (int i = 0; i < this.alphas.length; i++) { System.arraycopy(mutator.alphas, 0, this.alphas, 0, this.alphas.length);
this.alphas[i] = mutator.alphas[i];
}
} }

View File

@ -92,9 +92,7 @@ public class MutateESCovarianceMatrixAdaptionPlus extends
public void updateCovariance() { public void updateCovariance() {
double[] step = new double[D]; double[] step = new double[D];
for (int i = 0; i < D; i++) { System.arraycopy(Bz, 0, step, 0, D);
step[i] = Bz[i];
}
updateCovariance(step); updateCovariance(step);
} }

View File

@ -134,7 +134,7 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
@Override @Override
public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, Population partners) { public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, Population partners) {
if (crossoverType != MutateESCrossoverTypeEnum.none) { if (crossoverType != MutateESCrossoverTypeEnum.none) {
ArrayList<Double> tmpList = new ArrayList<Double>(); ArrayList<Double> tmpList = new ArrayList<>();
if (indy1.getMutationOperator() instanceof MutateESGlobal) { if (indy1.getMutationOperator() instanceof MutateESGlobal) {
tmpList.add(new Double(((MutateESGlobal) indy1.getMutationOperator()).mutationStepSize)); tmpList.add(new Double(((MutateESGlobal) indy1.getMutationOperator()).mutationStepSize));
} }

View File

@ -37,9 +37,7 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
public MutateESLocal(MutateESLocal mutator) { public MutateESLocal(MutateESLocal mutator) {
if (mutator.sigmas != null) { if (mutator.sigmas != null) {
this.sigmas = new double[mutator.sigmas.length]; this.sigmas = new double[mutator.sigmas.length];
for (int i = 0; i < this.sigmas.length; i++) { System.arraycopy(mutator.sigmas, 0, this.sigmas, 0, this.sigmas.length);
this.sigmas[i] = mutator.sigmas[i];
}
} }
this.mutationStepSize = mutator.mutationStepSize; this.mutationStepSize = mutator.mutationStepSize;
this.tau1 = mutator.tau1; this.tau1 = mutator.tau1;

View File

@ -125,7 +125,6 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
this.dN[i] = 0; this.dN[i] = 0;
this.mainV[i] = 0; this.mainV[i] = 0;
} }
;
this.xi_dach = Math.sqrt(this.N - 0.5); this.xi_dach = Math.sqrt(this.N - 0.5);
for (int i = 0; i < this.N; i++) { for (int i = 0; i < this.N; i++) {
this.Z[i] = RNG.gaussianDouble(1.0); this.Z[i] = RNG.gaussianDouble(1.0);

View File

@ -1,6 +1,5 @@
package eva2.optimization.operator.mutation; package eva2.optimization.operator.mutation;
import eva2.gui.BeanInspector;
import eva2.gui.editor.GenericObjectEditor; import eva2.gui.editor.GenericObjectEditor;
import eva2.optimization.enums.ESMutationInitialSigma; import eva2.optimization.enums.ESMutationInitialSigma;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;

View File

@ -103,9 +103,7 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa
int[] tmp = new int[x.length]; int[] tmp = new int[x.length];
int[] without = new int[x.length - length]; int[] without = new int[x.length - length];
int[] insert = new int[length]; int[] insert = new int[length];
for (int i = 0; i < length; i++) { System.arraycopy(x, 0 + from, insert, 0, length);
insert[i] = x[i + from];
}
for (int i = 0; i < without.length; i++) { for (int i = 0; i < without.length; i++) {
if (i < from) { if (i < from) {
without[i] = x[i]; without[i] = x[i];
@ -113,15 +111,9 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa
without[i] = x[i + length]; without[i] = x[i + length];
} }
} }
for (int i = 0; i < to; i++) { System.arraycopy(without, 0, tmp, 0, to);
tmp[i] = without[i]; System.arraycopy(insert, to - to, tmp, to, to + length - to);
} System.arraycopy(without, to + length - length, tmp, to + length, x.length - (to + length));
for (int i = to; i < to + length; i++) {
tmp[i] = insert[i - to];
}
for (int i = to + length; i < x.length; i++) {
tmp[i] = without[i - length];
}
// System.out.println(""+from+"/"+to+"/"+length); // System.out.println(""+from+"/"+to+"/"+length);
// this.printInt("After ", tmp); // this.printInt("After ", tmp);
((InterfaceGIIndividual) individual).setIGenotype(tmp); ((InterfaceGIIndividual) individual).setIGenotype(tmp);

View File

@ -2,7 +2,6 @@ package eva2.optimization.operator.mutation;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.individuals.IndividualInterface;
import eva2.optimization.individuals.InterfaceGPIndividual; import eva2.optimization.individuals.InterfaceGPIndividual;
import eva2.optimization.population.Population; import eva2.optimization.population.Population;
import eva2.problems.InterfaceOptimizationProblem; import eva2.problems.InterfaceOptimizationProblem;

View File

@ -30,10 +30,7 @@ public class PropertyMutationMixer implements java.io.Serializable {
this.weightsLabel = d.weightsLabel; this.weightsLabel = d.weightsLabel;
this.normalizationEnabled = d.normalizationEnabled; this.normalizationEnabled = d.normalizationEnabled;
this.availableTargets = new InterfaceMutation[d.availableTargets.length]; this.availableTargets = new InterfaceMutation[d.availableTargets.length];
for (int i = 0; i < this.availableTargets.length; i++) { System.arraycopy(d.availableTargets, 0, this.availableTargets, 0, this.availableTargets.length);
//this.availableTargets[i] = (InterfaceMutation)d.availableTargets[i].clone();
this.availableTargets[i] = d.availableTargets[i];
}
this.selectedTargets = new InterfaceMutation[d.selectedTargets.length]; this.selectedTargets = new InterfaceMutation[d.selectedTargets.length];
for (int i = 0; i < this.selectedTargets.length; i++) { for (int i = 0; i < this.selectedTargets.length; i++) {
this.selectedTargets[i] = (InterfaceMutation) d.selectedTargets[i].clone(); this.selectedTargets[i] = (InterfaceMutation) d.selectedTargets[i].clone();
@ -71,15 +68,11 @@ public class PropertyMutationMixer implements java.io.Serializable {
if (d.length > this.weights.length) { if (d.length > this.weights.length) {
double[] newWeights = new double[d.length]; double[] newWeights = new double[d.length];
for (int i = 0; i < this.weights.length; i++) { System.arraycopy(this.weights, 0, newWeights, 0, this.weights.length);
newWeights[i] = this.weights[i];
}
this.weights = newWeights; this.weights = newWeights;
} else { } else {
double[] newWeights = new double[d.length]; double[] newWeights = new double[d.length];
for (int i = 0; i < d.length; i++) { System.arraycopy(this.weights, 0, newWeights, 0, d.length);
newWeights[i] = this.weights[i];
}
this.weights = newWeights; this.weights = newWeights;
} }
} }

View File

@ -231,9 +231,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
mutatorsWithWeights.addMutator((InterfaceMutation) mutatorsWithWeights.getAvailableMutators()[0].clone()); mutatorsWithWeights.addMutator((InterfaceMutation) mutatorsWithWeights.getAvailableMutators()[0].clone());
int l = mutatorsWithWeights.getSelectedMutators().length; int l = mutatorsWithWeights.getSelectedMutators().length;
GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l]; GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l];
for (int i = 0; i < editors.length; i++) { System.arraycopy(editors, 0, newEdit, 0, editors.length);
newEdit[i] = editors[i];
}
InterfaceMutation[] list = mutatorsWithWeights.getSelectedMutators(); InterfaceMutation[] list = mutatorsWithWeights.getSelectedMutators();
l--; l--;
newEdit[l] = new GeneralOptimizationEditorProperty(); newEdit[l] = new GeneralOptimizationEditorProperty();
@ -312,7 +310,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
for (int i = 0; i < newW.length; i++) { for (int i = 0; i < newW.length; i++) {
try { try {
double d = 0; double d = 0;
d = new Double(weights[i].getText()).doubleValue(); d = Double.parseDouble(weights[i].getText());
newW[i] = d; newW[i] = d;
} catch (Exception e) { } catch (Exception e) {
} }

View File

@ -63,7 +63,7 @@ public class ImprovementDeactivationStrategy implements InterfaceDeactivationStr
return false; return false;
} else { } else {
List<Double> lst = bests.subList(bests.size() - haltingWindow, bests.size()); List<Double> lst = bests.subList(bests.size() - haltingWindow, bests.size());
bests = new Vector<Double>(haltingWindow); bests = new Vector<>(haltingWindow);
bests.addAll(lst); bests.addAll(lst);
for (int i = 1; i < pop.size(); i++) { for (int i = 1; i < pop.size(); i++) {
for (int k = 0; k < haltingWindow; k++) { for (int k = 0; k < haltingWindow; k++) {

View File

@ -28,7 +28,7 @@ public class ConstraintBasedAdaption implements ParamAdaption, Serializable {
private double currentFactor = 1.; private double currentFactor = 1.;
private int genGap = 5; private int genGap = 5;
LinkedList<Boolean> lastBestSatisfactionState = new LinkedList<Boolean>(); LinkedList<Boolean> lastBestSatisfactionState = new LinkedList<>();
private static String target = "penaltyFactor"; private static String target = "penaltyFactor";

View File

@ -131,7 +131,7 @@ public class ParameterControlManager implements InterfaceParameterControl, Seria
*/ */
public String[] getControlledParameters() { public String[] getControlledParameters() {
if (singleAdapters != null) { if (singleAdapters != null) {
Vector<String> names = new Vector<String>(singleAdapters.length); Vector<String> names = new Vector<>(singleAdapters.length);
for (ParamAdaption singleAdapter : singleAdapters) { for (ParamAdaption singleAdapter : singleAdapters) {
String prm = singleAdapter.getControlledParam(); String prm = singleAdapter.getControlledParam();
if (prm != null) { if (prm != null) {
@ -183,9 +183,7 @@ public class ParameterControlManager implements InterfaceParameterControl, Seria
setSingleAdapters(new ParamAdaption[]{pa}); setSingleAdapters(new ParamAdaption[]{pa});
} else { } else {
ParamAdaption[] newP = new ParamAdaption[singleAdapters.length + 1]; ParamAdaption[] newP = new ParamAdaption[singleAdapters.length + 1];
for (int i = 0; i < singleAdapters.length; i++) { System.arraycopy(singleAdapters, 0, newP, 0, singleAdapters.length);
newP[i] = singleAdapters[i];
}
newP[newP.length - 1] = pa; newP[newP.length - 1] = pa;
setSingleAdapters(newP); setSingleAdapters(newP);
} }
@ -210,7 +208,7 @@ public class ParameterControlManager implements InterfaceParameterControl, Seria
public static List<Object> listOfControllables( public static List<Object> listOfControllables(
Object target) { Object target) {
Pair<String[], Object[]> propsNamesVals = BeanInspector.getPublicPropertiesOf(target, true, true); Pair<String[], Object[]> propsNamesVals = BeanInspector.getPublicPropertiesOf(target, true, true);
ArrayList<Object> controllables = new ArrayList<Object>(); ArrayList<Object> controllables = new ArrayList<>();
// Object ownParamCtrl = BeanInspector.callIfAvailable(target, "getParameterControl", null); // if the target itself has a ParameterControlManager, add it to the list of controllables. // Object ownParamCtrl = BeanInspector.callIfAvailable(target, "getParameterControl", null); // if the target itself has a ParameterControlManager, add it to the list of controllables.
// if (ownParamCtrl!=null) controllables.add(ownParamCtrl); // if (ownParamCtrl!=null) controllables.add(ownParamCtrl);
Object[] objs = propsNamesVals.tail; Object[] objs = propsNamesVals.tail;

View File

@ -27,16 +27,12 @@ public class MetricD1ApproxParetoFront implements eva2.optimization.operator.par
public MetricD1ApproxParetoFront(MetricD1ApproxParetoFront b) { public MetricD1ApproxParetoFront(MetricD1ApproxParetoFront b) {
if (b.titles != null) { if (b.titles != null) {
this.titles = new String[b.titles.length]; this.titles = new String[b.titles.length];
for (int i = 0; i < this.titles.length; i++) { System.arraycopy(b.titles, 0, this.titles, 0, this.titles.length);
this.titles[i] = b.titles[i];
}
} }
if (b.reference != null) { if (b.reference != null) {
this.reference = new double[b.reference.length][b.reference[0].length]; this.reference = new double[b.reference.length][b.reference[0].length];
for (int i = 0; i < this.reference.length; i++) { for (int i = 0; i < this.reference.length; i++) {
for (int j = 0; j < this.reference[i].length; j++) { System.arraycopy(b.reference[i], 0, this.reference[i], 0, this.reference[i].length);
this.reference[i][j] = b.reference[i][j];
}
} }
} }
} }
@ -75,7 +71,7 @@ public class MetricD1ApproxParetoFront implements eva2.optimization.operator.par
lines[i].trim(); lines[i].trim();
tmpS = lines[i].split("\t"); tmpS = lines[i].split("\t");
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) { for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
tmpD[j] = new Double(tmpS[j]).doubleValue(); tmpD[j] = Double.parseDouble(tmpS[j]);
} }
tmpA.add(tmpD); tmpA.add(tmpD);
} }

View File

@ -28,16 +28,12 @@ public class MetricD1TrueParetoFront implements eva2.optimization.operator.paret
public MetricD1TrueParetoFront(MetricD1TrueParetoFront b) { public MetricD1TrueParetoFront(MetricD1TrueParetoFront b) {
if (b.titles != null) { if (b.titles != null) {
this.titles = new String[b.titles.length]; this.titles = new String[b.titles.length];
for (int i = 0; i < this.titles.length; i++) { System.arraycopy(b.titles, 0, this.titles, 0, this.titles.length);
this.titles[i] = b.titles[i];
}
} }
if (b.reference != null) { if (b.reference != null) {
this.reference = new double[b.reference.length][b.reference[0].length]; this.reference = new double[b.reference.length][b.reference[0].length];
for (int i = 0; i < this.reference.length; i++) { for (int i = 0; i < this.reference.length; i++) {
for (int j = 0; j < this.reference[i].length; j++) { System.arraycopy(b.reference[i], 0, this.reference[i], 0, this.reference[i].length);
this.reference[i][j] = b.reference[i][j];
}
} }
} }
} }
@ -76,7 +72,7 @@ public class MetricD1TrueParetoFront implements eva2.optimization.operator.paret
lines[i].trim(); lines[i].trim();
tmpS = lines[i].split("\t"); tmpS = lines[i].split("\t");
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) { for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
tmpD[j] = new Double(tmpS[j]).doubleValue(); tmpD[j] = Double.parseDouble(tmpS[j]);
} }
tmpA.add(tmpD); tmpA.add(tmpD);
} }

View File

@ -30,16 +30,12 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
this.epsilon = b.epsilon; this.epsilon = b.epsilon;
if (b.titles != null) { if (b.titles != null) {
this.titles = new String[b.titles.length]; this.titles = new String[b.titles.length];
for (int i = 0; i < this.titles.length; i++) { System.arraycopy(b.titles, 0, this.titles, 0, this.titles.length);
this.titles[i] = b.titles[i];
}
} }
if (b.reference != null) { if (b.reference != null) {
this.reference = new double[b.reference.length][b.reference[0].length]; this.reference = new double[b.reference.length][b.reference[0].length];
for (int i = 0; i < this.reference.length; i++) { for (int i = 0; i < this.reference.length; i++) {
for (int j = 0; j < this.reference[i].length; j++) { System.arraycopy(b.reference[i], 0, this.reference[i], 0, this.reference[i].length);
this.reference[i][j] = b.reference[i][j];
}
} }
} }
} }
@ -78,7 +74,7 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
lines[i].trim(); lines[i].trim();
tmpS = lines[i].split("\t"); tmpS = lines[i].split("\t");
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) { for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
tmpD[j] = new Double(tmpS[j]).doubleValue(); tmpD[j] = Double.parseDouble(tmpS[j]);
} }
tmpA.add(tmpD); tmpA.add(tmpD);
} }

View File

@ -26,16 +26,12 @@ public class MetricMaximumParetoFrontError implements eva2.optimization.operator
public MetricMaximumParetoFrontError(MetricMaximumParetoFrontError b) { public MetricMaximumParetoFrontError(MetricMaximumParetoFrontError b) {
if (b.titles != null) { if (b.titles != null) {
this.titles = new String[b.titles.length]; this.titles = new String[b.titles.length];
for (int i = 0; i < this.titles.length; i++) { System.arraycopy(b.titles, 0, this.titles, 0, this.titles.length);
this.titles[i] = b.titles[i];
}
} }
if (b.reference != null) { if (b.reference != null) {
this.reference = new double[b.reference.length][b.reference[0].length]; this.reference = new double[b.reference.length][b.reference[0].length];
for (int i = 0; i < this.reference.length; i++) { for (int i = 0; i < this.reference.length; i++) {
for (int j = 0; j < this.reference[i].length; j++) { System.arraycopy(b.reference[i], 0, this.reference[i], 0, this.reference[i].length);
this.reference[i][j] = b.reference[i][j];
}
} }
} }
} }
@ -74,7 +70,7 @@ public class MetricMaximumParetoFrontError implements eva2.optimization.operator
lines[i].trim(); lines[i].trim();
tmpS = lines[i].split("\t"); tmpS = lines[i].split("\t");
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) { for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
tmpD[j] = new Double(tmpS[j]).doubleValue(); tmpD[j] = Double.parseDouble(tmpS[j]);
} }
tmpA.add(tmpD); tmpA.add(tmpD);
} }

View File

@ -1,6 +1,5 @@
package eva2.optimization.operator.paretofrontmetrics; package eva2.optimization.operator.paretofrontmetrics;
import eva2.gui.BeanInspector;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.individuals.ESIndividualDoubleData; import eva2.optimization.individuals.ESIndividualDoubleData;
import eva2.optimization.operator.archiving.ArchivingAllDominating; import eva2.optimization.operator.archiving.ArchivingAllDominating;
@ -102,14 +101,10 @@ public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable
double[] tmpF, redF; double[] tmpF, redF;
for (int i = 0; i < f.length; i++) { for (int i = 0; i < f.length; i++) {
tmpF = ((AbstractEAIndividual) archive.get(i)).getFitness(); tmpF = ((AbstractEAIndividual) archive.get(i)).getFitness();
for (int j = 0; j < dim; j++) { System.arraycopy(tmpF, 0, f[i], 0, dim);
f[i][j] = tmpF[j];
}
if (smPop != null) { if (smPop != null) {
redF = new double[tmpF.length - 1]; redF = new double[tmpF.length - 1];
for (int j = 0; j < redF.length; j++) { System.arraycopy(tmpF, 0, redF, 0, redF.length);
redF[j] = tmpF[j];
}
tmpIndy = new ESIndividualDoubleData(); tmpIndy = new ESIndividualDoubleData();
tmpIndy.setFitness(redF); tmpIndy.setFitness(redF);
smPop.add(i, tmpIndy); smPop.add(i, tmpIndy);
@ -172,9 +167,7 @@ public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable
tmpS = this.calculateSMetric(tmpPop, tmpBorder, dim - 1); tmpS = this.calculateSMetric(tmpPop, tmpBorder, dim - 1);
result += (f[tmpIndex][dim - 1] - lastValue[dim - 1]) * tmpS; result += (f[tmpIndex][dim - 1] - lastValue[dim - 1]) * tmpS;
} }
for (int j = 0; j < f[tmpIndex].length; j++) { System.arraycopy(f[tmpIndex], 0, lastValue, 0, f[tmpIndex].length);
lastValue[j] = f[tmpIndex][j];
}
} else { } else {
// no smallest found break // no smallest found break
i = f.length + 1; i = f.length + 1;

View File

@ -86,7 +86,7 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
lines[i].trim(); lines[i].trim();
tmpS = lines[i].split("\t"); tmpS = lines[i].split("\t");
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) { for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
tmpD[j] = new Double(tmpS[j]).doubleValue(); tmpD[j] = Double.parseDouble(tmpS[j]);
} }
tmpA.add(tmpD); tmpA.add(tmpD);
} }
@ -151,14 +151,10 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
double[] tmpF, redF; double[] tmpF, redF;
for (int i = 0; i < f.length; i++) { for (int i = 0; i < f.length; i++) {
tmpF = ((AbstractEAIndividual) archive.get(i)).getFitness(); tmpF = ((AbstractEAIndividual) archive.get(i)).getFitness();
for (int j = 0; j < dim; j++) { System.arraycopy(tmpF, 0, f[i], 0, dim);
f[i][j] = tmpF[j];
}
if (smPop != null) { if (smPop != null) {
redF = new double[tmpF.length - 1]; redF = new double[tmpF.length - 1];
for (int j = 0; j < redF.length; j++) { System.arraycopy(tmpF, 0, redF, 0, redF.length);
redF[j] = tmpF[j];
}
tmpIndy = new ESIndividualDoubleData(); tmpIndy = new ESIndividualDoubleData();
tmpIndy.setFitness(redF); tmpIndy.setFitness(redF);
smPop.add(i, tmpIndy); smPop.add(i, tmpIndy);
@ -220,9 +216,7 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
tmpS = this.calculateSMetric(tmpPop, tmpBorder, dim - 1); tmpS = this.calculateSMetric(tmpPop, tmpBorder, dim - 1);
result += (f[tmpIndex][dim - 1] - lastValue[dim - 1]) * tmpS; result += (f[tmpIndex][dim - 1] - lastValue[dim - 1]) * tmpS;
} }
for (int j = 0; j < f[tmpIndex].length; j++) { System.arraycopy(f[tmpIndex], 0, lastValue, 0, f[tmpIndex].length);
lastValue[j] = f[tmpIndex][j];
}
} else { } else {
// no smallest found break // no smallest found break
i = f.length + 1; i = f.length + 1;

View File

@ -35,7 +35,6 @@ import eva2.tools.math.Mathematics;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Vector; import java.util.Vector;
@ -52,7 +51,7 @@ public class PostProcess {
// lower limit mutation step size for HC post processing // lower limit mutation step size for HC post processing
private static double minMutationStepSize = 0.0000000000000001; private static double minMutationStepSize = 0.0000000000000001;
// used for hill climbing post processing and only alive during that period // used for hill climbing post processing and only alive during that period
private static Vector<OptimizerRunnable> ppRunnables = new Vector<OptimizerRunnable>(); private static Vector<OptimizerRunnable> ppRunnables = new Vector<>();
public static final String movedDistanceKey = "PostProcessingMovedBy"; public static final String movedDistanceKey = "PostProcessingMovedBy";
public static final String movedToPositionKey = "PostProcessingMovedTo"; public static final String movedToPositionKey = "PostProcessingMovedTo";
@ -347,7 +346,7 @@ public class PostProcess {
bestDist = tmpDist; bestDist = tmpDist;
} }
} }
return new Pair<Double, Integer>(bestDist, bestIndex); return new Pair<>(bestDist, bestIndex);
} }
/** /**
@ -466,7 +465,7 @@ public class PostProcess {
int funCallsDone = pop.getFunctionCalls() - baseEvals; int funCallsDone = pop.getFunctionCalls() - baseEvals;
pop.setFunctionCalls(funCallsBefore); pop.setFunctionCalls(funCallsBefore);
return new Pair<Integer, Boolean>(funCallsDone, ppRunnable.wasAborted()); return new Pair<>(funCallsDone, ppRunnable.wasAborted());
} }
/** /**
@ -510,7 +509,7 @@ public class PostProcess {
int funCallsDone = es.getPopulation().getFunctionCalls() - baseEvals; int funCallsDone = es.getPopulation().getFunctionCalls() - baseEvals;
pop.setFunctionCalls(funCallsBefore); pop.setFunctionCalls(funCallsBefore);
return new Pair<Integer, Boolean>(funCallsDone, ppRunnable.wasAborted()); return new Pair<>(funCallsDone, ppRunnable.wasAborted());
} }
private static boolean checkRange(AbstractEAIndividual indy) { private static boolean checkRange(AbstractEAIndividual indy) {
@ -538,7 +537,7 @@ public class PostProcess {
pop.add(cand); pop.add(cand);
int evalsDone = processSingleCandidates(PostProcessMethod.nelderMead, pop, hcSteps, initPerturbation, prob, null); int evalsDone = processSingleCandidates(PostProcessMethod.nelderMead, pop, hcSteps, initPerturbation, prob, null);
return new Pair<AbstractEAIndividual, Integer>(pop.getBestEAIndividual(), evalsDone); return new Pair<>(pop.getBestEAIndividual(), evalsDone);
} }
/** /**
@ -659,7 +658,7 @@ public class PostProcess {
* @see #processWithNMS(Population, AbstractOptimizationProblem, InterfaceTerminator, int) * @see #processWithNMS(Population, AbstractOptimizationProblem, InterfaceTerminator, int)
*/ */
public static int processSingleCandidatesNMCMA(PostProcessMethod method, Population candidates, InterfaceTerminator term, double maxRelativePerturbation, AbstractOptimizationProblem prob) { public static int processSingleCandidatesNMCMA(PostProcessMethod method, Population candidates, InterfaceTerminator term, double maxRelativePerturbation, AbstractOptimizationProblem prob) {
ArrayList<Population> nmPops = new ArrayList<Population>(); ArrayList<Population> nmPops = new ArrayList<>();
int stepsPerf = 0; int stepsPerf = 0;
Population subPop; Population subPop;
@ -906,7 +905,7 @@ public class PostProcess {
Population found = getFoundOptima(pop, mmp.getRealOptima(), 0.05, true); Population found = getFoundOptima(pop, mmp.getRealOptima(), 0.05, true);
System.out.println("all found (" + found.size() + "): " + BeanInspector.toString(found)); System.out.println("all found (" + found.size() + "): " + BeanInspector.toString(found));
Pair<Population, Double> popD = new Pair<Population, Double>(pop, 1.); Pair<Population, Double> popD = new Pair<>(pop, 1.);
int i = 0; int i = 0;
int evalCnt = 0; int evalCnt = 0;
while (popD.tail() > 0.001) { while (popD.tail() > 0.001) {
@ -947,7 +946,7 @@ public class PostProcess {
clust.setFunctionCalls(evalsBefore + evalsDone); clust.setFunctionCalls(evalsBefore + evalsDone);
double improvement = EuclideanMetric.euclideanDistance(meanFit, clust.getMeanFitness()); double improvement = EuclideanMetric.euclideanDistance(meanFit, clust.getMeanFitness());
return new Pair<Population, Double>(clust, improvement); return new Pair<>(clust, improvement);
} }
/** /**

View File

@ -1,6 +1,5 @@
package eva2.optimization.operator.terminators; package eva2.optimization.operator.terminators;
import eva2.gui.BeanInspector;
import eva2.optimization.population.InterfaceSolutionSet; import eva2.optimization.population.InterfaceSolutionSet;
import eva2.optimization.population.PopulationInterface; import eva2.optimization.population.PopulationInterface;
import eva2.problems.InterfaceOptimizationProblem; import eva2.problems.InterfaceOptimizationProblem;
@ -129,7 +128,7 @@ public abstract class PopulationMeasureTerminator implements InterfaceTerminator
* @return * @return
*/ */
protected String getTerminationMessage() { protected String getTerminationMessage() {
StringBuffer sb = new StringBuffer(getMeasureName()); StringBuilder sb = new StringBuilder(getMeasureName());
// if (convergenceCondition.isSelectedString("Relative")) sb.append(" converged relatively "); // if (convergenceCondition.isSelectedString("Relative")) sb.append(" converged relatively ");
switch (changeType) { switch (changeType) {
case absoluteChange: case absoluteChange:

View File

@ -27,9 +27,7 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser
super(population); super(population);
this.probabilityVector = new double[population.probabilityVector.length]; this.probabilityVector = new double[population.probabilityVector.length];
for (int i = 0; i < this.probabilityVector.length; i++) { System.arraycopy(population.probabilityVector, 0, this.probabilityVector, 0, this.probabilityVector.length);
this.probabilityVector[i] = population.probabilityVector[i];
}
} }
@Override @Override

View File

@ -56,7 +56,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
*/ */
PopulationInitMethod initMethod = PopulationInitMethod.individualDefault; PopulationInitMethod initMethod = PopulationInitMethod.individualDefault;
private double[] seedPos = new double[10]; private double[] seedPos = new double[10];
private Pair<Integer, Integer> seedCardinality = new Pair<Integer, Integer>(5, 1); private Pair<Integer, Integer> seedCardinality = new Pair<>(5, 1);
private double aroundDist = 0.1; private double aroundDist = 0.1;
transient private ArrayList<InterfacePopulationChangedEventListener> listeners = null; transient private ArrayList<InterfacePopulationChangedEventListener> listeners = null;
@ -80,7 +80,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
/** /**
* Best n Individuals in the history. * Best n Individuals in the history.
*/ */
private transient LinkedList<AbstractEAIndividual> historyList = new LinkedList<AbstractEAIndividual>(); private transient LinkedList<AbstractEAIndividual> historyList = new LinkedList<>();
/** /**
* Remember when the last sorted queue was prepared. * Remember when the last sorted queue was prepared.
@ -150,7 +150,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
this(allSolutions.getCurrentPopulation().size() + allSolutions.getSolutions().size()); this(allSolutions.getCurrentPopulation().size() + allSolutions.getSolutions().size());
LOGGER.log(Level.FINER, "New population has been created."); LOGGER.log(Level.FINER, "New population has been created.");
addPopulation(allSolutions.getCurrentPopulation(), false); addPopulation(allSolutions.getCurrentPopulation(), false);
HashMap<Long, Integer> checkCols = new HashMap<Long, Integer>(size()); HashMap<Long, Integer> checkCols = new HashMap<>(size());
for (int i = 0; i < size(); i++) { for (int i = 0; i < size(); i++) {
checkCols.put(getEAIndividual(i).getIndyID(), 1); checkCols.put(getEAIndividual(i).getIndyID(), 1);
} }
@ -173,7 +173,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
*/ */
public Population(int targetSize, int binCard, int binStdDev) { public Population(int targetSize, int binCard, int binStdDev) {
this(targetSize); this(targetSize);
this.setSeedCardinality(new Pair<Integer, Integer>(binCard, binStdDev)); this.setSeedCardinality(new Pair<>(binCard, binStdDev));
this.setInitMethod(PopulationInitMethod.binCardinality); this.setInitMethod(PopulationInitMethod.binCardinality);
} }
@ -231,7 +231,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
listeners = null; listeners = null;
} }
if (population.additionalPopData != null) { if (population.additionalPopData != null) {
additionalPopData = new HashMap<String, Object>(); additionalPopData = new HashMap<>();
Set<String> keys = additionalPopData.keySet(); Set<String> keys = additionalPopData.keySet();
for (String key : keys) { for (String key : keys) {
additionalPopData.put(key, population.additionalPopData.get(key)); additionalPopData.put(key, population.additionalPopData.get(key));
@ -302,7 +302,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
public void putData(String key, Object value) { public void putData(String key, Object value) {
if (additionalPopData == null) { if (additionalPopData == null) {
additionalPopData = new HashMap<String, Object>(); additionalPopData = new HashMap<>();
} }
additionalPopData.put(key, value); additionalPopData.put(key, value);
} }
@ -364,7 +364,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
* been inited by a problem * been inited by a problem
*/ */
public void init() { public void init() {
this.historyList = new LinkedList<AbstractEAIndividual>(); this.historyList = new LinkedList<>();
this.generationCount = 0; this.generationCount = 0;
this.functionCallCount = 0; this.functionCallCount = 0;
double[] popSeed = null; double[] popSeed = null;
@ -749,7 +749,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
if (ea != null) { if (ea != null) {
if (listeners == null) { if (listeners == null) {
listeners = new ArrayList<InterfacePopulationChangedEventListener>(3); listeners = new ArrayList<>(3);
} }
if (!listeners.contains(ea)) { if (!listeners.contains(ea)) {
listeners.add(ea); listeners.add(ea);
@ -836,11 +836,11 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
* @return * @return
*/ */
public List<Pair<Integer, Integer>> findSamePositions() { public List<Pair<Integer, Integer>> findSamePositions() {
ArrayList<Pair<Integer, Integer>> dupes = new ArrayList<Pair<Integer, Integer>>(); ArrayList<Pair<Integer, Integer>> dupes = new ArrayList<>();
for (int i = 0; i < size() - 1; i++) { for (int i = 0; i < size() - 1; i++) {
int nextIndex = indexByPosition(i + 1, getEAIndividual(i)); int nextIndex = indexByPosition(i + 1, getEAIndividual(i));
if (nextIndex >= 0) { if (nextIndex >= 0) {
dupes.add(new Pair<Integer, Integer>(i, nextIndex)); dupes.add(new Pair<>(i, nextIndex));
} }
} }
return dupes; return dupes;
@ -1288,16 +1288,16 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
*/ */
protected ArrayList<AbstractEAIndividual> sortBy(Comparator<Object> comp) { protected ArrayList<AbstractEAIndividual> sortBy(Comparator<Object> comp) {
if (super.isEmpty()) { if (super.isEmpty()) {
return new ArrayList<AbstractEAIndividual>(); return new ArrayList<>();
} }
PriorityQueue<AbstractEAIndividual> sQueue = new PriorityQueue<AbstractEAIndividual>(super.size(), comp); PriorityQueue<AbstractEAIndividual> sQueue = new PriorityQueue<>(super.size(), comp);
for (int i = 0; i < super.size(); i++) { for (int i = 0; i < super.size(); i++) {
AbstractEAIndividual indy = getEAIndividual(i); AbstractEAIndividual indy = getEAIndividual(i);
if (indy != null) { if (indy != null) {
sQueue.add(indy); sQueue.add(indy);
} }
} }
ArrayList<AbstractEAIndividual> sArr = new ArrayList<AbstractEAIndividual>(this.size()); ArrayList<AbstractEAIndividual> sArr = new ArrayList<>(this.size());
AbstractEAIndividual indy; AbstractEAIndividual indy;
while ((indy = sQueue.poll()) != null) { while ((indy = sQueue.poll()) != null) {
sArr.add(indy); sArr.add(indy);
@ -2040,7 +2040,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
sel = i; sel = i;
} }
} }
return new Pair<Integer, Double>(sel, dist); return new Pair<>(sel, dist);
} }
/** /**
@ -2067,7 +2067,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
} }
} }
} }
return new Pair<Integer, Double>(sel, dist); return new Pair<>(sel, dist);
} }
/** /**
@ -2205,7 +2205,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
PhenotypeMetric metric = new PhenotypeMetric(); PhenotypeMetric metric = new PhenotypeMetric();
ArrayList<Double> distances = null; ArrayList<Double> distances = null;
if (calcVariance) { if (calcVariance) {
distances = new ArrayList<Double>(size()); distances = new ArrayList<>(size());
} }
double sum = 0; double sum = 0;
double d = 0; double d = 0;

View File

@ -3,7 +3,6 @@ package eva2.optimization.stat;
import eva2.gui.BeanInspector; import eva2.gui.BeanInspector;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.individuals.IndividualInterface; import eva2.optimization.individuals.IndividualInterface;
import eva2.optimization.operator.distancemetric.InterfaceDistanceMetric;
import eva2.optimization.population.Population; import eva2.optimization.population.Population;
import eva2.optimization.population.PopulationInterface; import eva2.optimization.population.PopulationInterface;
import eva2.problems.InterfaceAdditionalPopulationInformer; import eva2.problems.InterfaceAdditionalPopulationInformer;
@ -110,13 +109,13 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
convergenceCnt = 0; convergenceCnt = 0;
optRunsPerformed = 0; optRunsPerformed = 0;
iterationCounter = 0; iterationCounter = 0;
textListeners = new ArrayList<InterfaceTextListener>(); textListeners = new ArrayList<>();
} }
@Override @Override
public void addDataListener(InterfaceStatisticsListener l) { public void addDataListener(InterfaceStatisticsListener l) {
if (dataListeners == null) { if (dataListeners == null) {
dataListeners = new LinkedList<InterfaceStatisticsListener>(); dataListeners = new LinkedList<>();
} }
if (l != null && !dataListeners.contains(l)) { if (l != null && !dataListeners.contains(l)) {
dataListeners.add(l); dataListeners.add(l);
@ -142,7 +141,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
private void fireDataListenersFinalize() { private void fireDataListenersFinalize() {
if (dataListeners != null) { if (dataListeners != null) {
LinkedList<InterfaceStatisticsListener> toRemove = new LinkedList<InterfaceStatisticsListener>(); LinkedList<InterfaceStatisticsListener> toRemove = new LinkedList<>();
for (InterfaceStatisticsListener l : dataListeners) { for (InterfaceStatisticsListener l : dataListeners) {
boolean rm = l.notifyMultiRunFinished(currentStatHeader, finalObjectData); boolean rm = l.notifyMultiRunFinished(currentStatHeader, finalObjectData);
if (rm) { if (rm) {
@ -277,12 +276,12 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
bestFeasibleAllRuns = null; bestFeasibleAllRuns = null;
// meanBestOfRunFitness = null; // meanBestOfRunFitness = null;
// meanBestFeasibleFit = null; // meanBestFeasibleFit = null;
runBestFeasibleList = new ArrayList<IndividualInterface>(); runBestFeasibleList = new ArrayList<>();
runBestFitList = new ArrayList<IndividualInterface>(); runBestFitList = new ArrayList<>();
// if (refineMultiRuns) meanCollection = new ArrayList<double[][]>(); // if (refineMultiRuns) meanCollection = new ArrayList<double[][]>();
// else meanCollection = null; // else meanCollection = null;
if (refineMultiRuns) { if (refineMultiRuns) {
sumDataCollection = new ArrayList<Double[]>(); sumDataCollection = new ArrayList<>();
} else { } else {
sumDataCollection = null; sumDataCollection = null;
} }
@ -393,7 +392,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
} }
} }
if (finalObjectData == null) { if (finalObjectData == null) {
finalObjectData = new ArrayList<Object[]>(); finalObjectData = new ArrayList<>();
} }
finalObjectData.add(currentStatObjectData); finalObjectData.add(currentStatObjectData);
@ -571,7 +570,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
// String header = getOutputHeader(lastInformerList, bestPop); // String header = getOutputHeader(lastInformerList, bestPop);
List<Object> vals = getOutputValues(lastInformerList, bestPop); List<Object> vals = getOutputValues(lastInformerList, bestPop);
StringBuffer sbuf = new StringBuffer("Overall best statistical data: "); StringBuilder sbuf = new StringBuilder("Overall best statistical data: ");
sbuf.append(additionalFields); sbuf.append(additionalFields);
sbuf.append('\n'); sbuf.append('\n');
sbuf.append(StringTools.concatValues(vals, textFieldDelimiter)); sbuf.append(StringTools.concatValues(vals, textFieldDelimiter));
@ -610,7 +609,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
} }
public static double[] calcMedianFit(List<IndividualInterface> list) { public static double[] calcMedianFit(List<IndividualInterface> list) {
ArrayList<double[]> dblAList = new ArrayList<double[]>(list.size()); ArrayList<double[]> dblAList = new ArrayList<>(list.size());
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
dblAList.add(list.get(i).getFitness()); dblAList.add(list.get(i).getFitness());
} }
@ -702,7 +701,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @return * @return
*/ */
protected List<String> getOutputHeaderFieldNames(List<InterfaceAdditionalPopulationInformer> informerList) { protected List<String> getOutputHeaderFieldNames(List<InterfaceAdditionalPopulationInformer> informerList) {
ArrayList<String> headlineFields = new ArrayList<String>(5); ArrayList<String> headlineFields = new ArrayList<>(5);
headlineFields.addAll(Arrays.asList(getSimpleOutputHeader())); headlineFields.addAll(Arrays.asList(getSimpleOutputHeader()));
if (informerList != null) { if (informerList != null) {
headlineFields.addAll(getAdditionalHeaderMetaInfo(informerList, null)); headlineFields.addAll(getAdditionalHeaderMetaInfo(informerList, null));
@ -718,8 +717,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @return * @return
*/ */
protected List<String> getOutputMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList) { protected List<String> getOutputMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList) {
ArrayList<String> infoStrings = new ArrayList<String>(5); ArrayList<String> infoStrings = new ArrayList<>(5);
ArrayList<String> addStrings = new ArrayList<String>(5); ArrayList<String> addStrings = new ArrayList<>(5);
infoStrings.addAll(Arrays.asList(getSimpleOutputMetaInfo())); infoStrings.addAll(Arrays.asList(getSimpleOutputMetaInfo()));
if (informerList != null) { if (informerList != null) {
getAdditionalHeaderMetaInfo(informerList, addStrings); getAdditionalHeaderMetaInfo(informerList, addStrings);
@ -745,7 +744,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
protected String[] getSimpleOutputHeader() { protected String[] getSimpleOutputHeader() {
// collect the full header by using the entries of the GraphSelectionEnum // collect the full header by using the entries of the GraphSelectionEnum
GraphSelectionEnum[] vals = GraphSelectionEnum.values(); GraphSelectionEnum[] vals = GraphSelectionEnum.values();
ArrayList<String> headerEntries = new ArrayList<String>(); ArrayList<String> headerEntries = new ArrayList<>();
headerEntries.add("FunctionCalls"); headerEntries.add("FunctionCalls");
for (GraphSelectionEnum val : vals) { for (GraphSelectionEnum val : vals) {
if (isRequestedField(val)) { if (isRequestedField(val)) {
@ -765,7 +764,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
*/ */
protected String[] getSimpleOutputMetaInfo() { protected String[] getSimpleOutputMetaInfo() {
GraphSelectionEnum[] vals = GraphSelectionEnum.values(); GraphSelectionEnum[] vals = GraphSelectionEnum.values();
ArrayList<String> headerInfo = new ArrayList<String>(); ArrayList<String> headerInfo = new ArrayList<>();
headerInfo.add("The number of function evaluations"); headerInfo.add("The number of function evaluations");
for (int i = 0; i < vals.length; i++) { for (int i = 0; i < vals.length; i++) {
if (isRequestedField(vals[i])) { if (isRequestedField(vals[i])) {
@ -872,7 +871,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @see #getOutputHeaderFieldNames(java.util.List) (List) * @see #getOutputHeaderFieldNames(java.util.List) (List)
*/ */
protected List<Object> getOutputValues(List<InterfaceAdditionalPopulationInformer> informerList, PopulationInterface pop) { protected List<Object> getOutputValues(List<InterfaceAdditionalPopulationInformer> informerList, PopulationInterface pop) {
LinkedList<Object> values = new LinkedList<Object>(); LinkedList<Object> values = new LinkedList<>();
values.addAll(Arrays.asList(getSimpleOutputValues())); values.addAll(Arrays.asList(getSimpleOutputValues()));
if (informerList != null) { if (informerList != null) {
for (InterfaceAdditionalPopulationInformer informer : informerList) { for (InterfaceAdditionalPopulationInformer informer : informerList) {
@ -906,7 +905,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @return * @return
*/ */
protected List<String> getAdditionalHeaderMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList, List<String> metaInfo) { protected List<String> getAdditionalHeaderMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList, List<String> metaInfo) {
LinkedList<String> headers = new LinkedList<String>(); LinkedList<String> headers = new LinkedList<>();
if (metaInfo != null && (metaInfo.size() > 0)) { if (metaInfo != null && (metaInfo.size() > 0)) {
System.err.println("Warning, metaInfo list should be empty in AbstractStatistics.getAdditionalHeaderMetaInfo"); System.err.println("Warning, metaInfo list should be empty in AbstractStatistics.getAdditionalHeaderMetaInfo");
} }
@ -949,7 +948,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
List<Object> statValues = getOutputValues(informerList, pop); List<Object> statValues = getOutputValues(informerList, pop);
String statValuesString = StringTools.concatValues(statValues, textFieldDelimiter); String statValuesString = StringTools.concatValues(statValues, textFieldDelimiter);
return new Pair<String, Object[]>(statValuesString, statValues.toArray(new Object[statValues.size()])); return new Pair<>(statValuesString, statValues.toArray(new Object[statValues.size()]));
} }
// /** // /**

View File

@ -23,7 +23,7 @@ public class EvAStatisticalEvaluation {
public static void evaluate(InterfaceTextListener textout, OptimizationJob[] jobList, int[] selectedIndices, public static void evaluate(InterfaceTextListener textout, OptimizationJob[] jobList, int[] selectedIndices,
StatsOnSingleDataSetEnum[] singleStats, StatsOnSingleDataSetEnum[] singleStats,
StatsOnTwoSampledDataEnum[] twoSampledStats) { StatsOnTwoSampledDataEnum[] twoSampledStats) {
ArrayList<OptimizationJob> jobsToWorkWith = new ArrayList<OptimizationJob>(); ArrayList<OptimizationJob> jobsToWorkWith = new ArrayList<>();
for (int i = 0; i < jobList.length; i++) { for (int i = 0; i < jobList.length; i++) {
// remove jobs which are not finished or not selected // remove jobs which are not finished or not selected
if (jobList[i] != null && (Mathematics.contains(selectedIndices, i)) && (jobList[i].isFinishedAndComplete())) { if (jobList[i] != null && (Mathematics.contains(selectedIndices, i)) && (jobList[i].isFinishedAndComplete())) {
@ -299,10 +299,10 @@ public class EvAStatisticalEvaluation {
* @return * @return
*/ */
private static List<String> getCommonFields(List<OptimizationJob> jobList) { private static List<String> getCommonFields(List<OptimizationJob> jobList) {
List<String> lSoFar = null, tmpL = new LinkedList<String>(); List<String> lSoFar = null, tmpL = new LinkedList<>();
for (OptimizationJob j : jobList) { for (OptimizationJob j : jobList) {
if (lSoFar == null) { if (lSoFar == null) {
lSoFar = new LinkedList<String>(); lSoFar = new LinkedList<>();
for (String f : j.getFieldHeaders()) { for (String f : j.getFieldHeaders()) {
lSoFar.add(f); lSoFar.add(f);
} }
@ -313,7 +313,7 @@ public class EvAStatisticalEvaluation {
} }
} }
lSoFar = tmpL; lSoFar = tmpL;
tmpL = new LinkedList<String>(); tmpL = new LinkedList<>();
} }
} }
return lSoFar; return lSoFar;

View File

@ -243,7 +243,7 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
public void addTextListener(InterfaceTextListener tListener) { public void addTextListener(InterfaceTextListener tListener) {
if (listeners == null) { if (listeners == null) {
listeners = new LinkedList<InterfaceTextListener>(); listeners = new LinkedList<>();
} }
if (!listeners.contains(tListener)) { if (!listeners.contains(tListener)) {
listeners.add(tListener); listeners.add(tListener);

View File

@ -351,8 +351,8 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf
*/ */
@Override @Override
public void setInformers(List<InterfaceAdditionalPopulationInformer> informers) { public void setInformers(List<InterfaceAdditionalPopulationInformer> informers) {
ArrayList<String> headerFields = new ArrayList<String>(); ArrayList<String> headerFields = new ArrayList<>();
ArrayList<String> infoFields = new ArrayList<String>(); ArrayList<String> infoFields = new ArrayList<>();
// parse list of header elements, show additional Strings according to names. // parse list of header elements, show additional Strings according to names.
for (InterfaceAdditionalPopulationInformer inf : informers) { for (InterfaceAdditionalPopulationInformer inf : informers) {
String[] dataHeader = inf.getAdditionalDataHeader(); String[] dataHeader = inf.getAdditionalDataHeader();

View File

@ -53,9 +53,9 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
@Override @Override
protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) { protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) {
if (collectData) { if (collectData) {
resultData = new ArrayList<ArrayList<Object[]>>(statisticsParameter.getMultiRuns()); resultData = new ArrayList<>(statisticsParameter.getMultiRuns());
List<String> description = getOutputHeaderFieldNames(informerList); List<String> description = getOutputHeaderFieldNames(informerList);
resultHeaderStrings = new ArrayList<String>(); resultHeaderStrings = new ArrayList<>();
for (String str : description) { for (String str : description) {
resultHeaderStrings.add(str); resultHeaderStrings.add(str);
} }

View File

@ -206,8 +206,8 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
public void plotSpecificData(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informer) { public void plotSpecificData(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informer) {
double[] specificData = pop.getSpecificData(); double[] specificData = pop.getSpecificData();
int calls = pop.getFunctionCalls(); int calls = pop.getFunctionCalls();
ArrayList<String[]> description = new ArrayList<String[]>(); ArrayList<String[]> description = new ArrayList<>();
ArrayList<String> temp = new ArrayList<String>(); ArrayList<String> temp = new ArrayList<>();
String[] ss = pop.getSpecificDataNames(); String[] ss = pop.getSpecificDataNames();
for (int i = 0; i < ss.length; i++) { for (int i = 0; i < ss.length; i++) {
if (ss[i].lastIndexOf("*") == -1) { if (ss[i].lastIndexOf("*") == -1) {
@ -216,7 +216,7 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
String[] line = new String[temp.size()]; String[] line = new String[temp.size()];
temp.toArray(line); temp.toArray(line);
description.add(line); description.add(line);
temp = new ArrayList<String>(); temp = new ArrayList<>();
temp.add(ss[i]); temp.add(ss[i]);
} }
} }

View File

@ -70,7 +70,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi
*/ */
// for ANPSO it is necessary to keep an own archiv of inactive subswarms, because the standard set of // for ANPSO it is necessary to keep an own archiv of inactive subswarms, because the standard set of
// subswarms is completely renewed every iteration. // subswarms is completely renewed every iteration.
public Vector<ParticleSubSwarmOptimization> inactiveSubSwarms = new Vector<ParticleSubSwarmOptimization>(); public Vector<ParticleSubSwarmOptimization> inactiveSubSwarms = new Vector<>();
// the s matrix keeps track of how long particles are close to each other // the s matrix keeps track of how long particles are close to each other
int[][] s = new int[mainSwarmSize][mainSwarmSize]; int[][] s = new int[mainSwarmSize][mainSwarmSize];
@ -215,7 +215,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi
initSTo(0); initSTo(0);
initNicheGraph(); initNicheGraph();
inactiveSubSwarms = new Vector<ParticleSubSwarmOptimization>(); // dont want to use subswarms from old optimization run (especially not in multiruns)... inactiveSubSwarms = new Vector<>(); // dont want to use subswarms from old optimization run (especially not in multiruns)...
} }
/** /**
@ -466,7 +466,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi
* @param setOfSubswarms * @param setOfSubswarms
*/ */
public void useAsSubSwarms(Vector<Population> setOfSubswarms) { public void useAsSubSwarms(Vector<Population> setOfSubswarms) {
Vector<ParticleSubSwarmOptimization> newSubSwarms = new Vector<ParticleSubSwarmOptimization>(); Vector<ParticleSubSwarmOptimization> newSubSwarms = new Vector<>();
for (int i = 0; i < setOfSubswarms.size(); ++i) { for (int i = 0; i < setOfSubswarms.size(); ++i) {
Population pop = setOfSubswarms.get(i); Population pop = setOfSubswarms.get(i);
@ -521,7 +521,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi
List<Set<String>> connectedComps = nicheGraph.getConnectedComponents(); List<Set<String>> connectedComps = nicheGraph.getConnectedComponents();
Population tmpPop = new Population(), newMainPop = new Population(); Population tmpPop = new Population(), newMainPop = new Population();
Vector<Population> setOfSubswarms = new Vector<Population>(); Vector<Population> setOfSubswarms = new Vector<>();
boolean reinitSuperfl = true; boolean reinitSuperfl = true;
for (Set<String> connSet : connectedComps) { for (Set<String> connSet : connectedComps) {

View File

@ -101,9 +101,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
this.scoringMethod = b.scoringMethod; this.scoringMethod = b.scoringMethod;
this.edgeRate = new int[b.edgeRate.length][b.edgeRate.length]; this.edgeRate = new int[b.edgeRate.length][b.edgeRate.length];
for (int i = 0; i < this.edgeRate.length; i++) { for (int i = 0; i < this.edgeRate.length; i++) {
for (int j = 0; j < this.edgeRate[i].length; j++) { System.arraycopy(b.edgeRate[i], 0, this.edgeRate[i], 0, this.edgeRate[i].length);
this.edgeRate[i][j] = b.edgeRate[i][j];
}
} }
this.scoringMethod = b.scoringMethod; this.scoringMethod = b.scoringMethod;
// this.printExtraOutput = b.printExtraOutput; // this.printExtraOutput = b.printExtraOutput;
@ -242,7 +240,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
this.network.initScoreArray(pop); this.network.initScoreArray(pop);
double score = this.network.getNewScore(pop, -1); double score = this.network.getNewScore(pop, -1);
double score1 = score; double score1 = score;
List<Pair<Integer, Integer>> bestNetworks = new LinkedList<Pair<Integer, Integer>>(); List<Pair<Integer, Integer>> bestNetworks = new LinkedList<>();
while (improvement) { while (improvement) {
improvement = false; improvement = false;
for (int i = 0; i < this.probDim; i++) { for (int i = 0; i < this.probDim; i++) {
@ -263,7 +261,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
if (tmpScore == score) { if (tmpScore == score) {
// add the edge to the list of possible new edges // add the edge to the list of possible new edges
bestNetworks bestNetworks
.add(new Pair<Integer, Integer>(i, .add(new Pair<>(i,
j)); j));
// if we have a better score // if we have a better score
} else { } else {
@ -271,7 +269,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
bestNetworks.clear(); bestNetworks.clear();
// add the edge to the list fo possible new edges // add the edge to the list fo possible new edges
bestNetworks bestNetworks
.add(new Pair<Integer, Integer>(i, .add(new Pair<>(i,
j)); j));
// adapt the score // adapt the score
score = tmpScore; score = tmpScore;
@ -369,7 +367,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
private void printEdgeRate() { private void printEdgeRate() {
String filename = this.netFolder + "/edgeRate.m"; String filename = this.netFolder + "/edgeRate.m";
Writer w = null; Writer w = null;
PrintWriter out = null;
String message = "edgeRate" + this.scoringMethod + " = ["; String message = "edgeRate" + this.scoringMethod + " = [";
createDirectoryIfNeeded(this.netFolder); createDirectoryIfNeeded(this.netFolder);
for (int i = 0; i < this.edgeRate.length; i++) { for (int i = 0; i < this.edgeRate.length; i++) {
@ -384,14 +381,12 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
} }
} }
message += "];"; message += "];";
try { try (PrintWriter out = new PrintWriter(w)) {
w = new FileWriter(filename); w = new FileWriter(filename);
out = new PrintWriter(w);
out.write(message); out.write(message);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
out.close();
try { try {
w.close(); w.close();
} catch (IOException e) { } catch (IOException e) {
@ -403,17 +398,14 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
private void printNetworkToFile(String i) { private void printNetworkToFile(String i) {
String filename = this.netFolder + "/network_" + i + ".graphml"; String filename = this.netFolder + "/network_" + i + ".graphml";
Writer w = null; Writer w = null;
PrintWriter out = null;
String message = this.network.generateYFilesCode(); String message = this.network.generateYFilesCode();
createDirectoryIfNeeded(this.netFolder); createDirectoryIfNeeded(this.netFolder);
try { try (PrintWriter out = new PrintWriter(w)) {
w = new FileWriter(filename); w = new FileWriter(filename);
out = new PrintWriter(w);
out.write(message); out.write(message);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
out.close();
try { try {
w.close(); w.close();
} catch (IOException e) { } catch (IOException e) {

View File

@ -511,7 +511,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
// delete the worst half of refSet // delete the worst half of refSet
this.refSet.removeMembers(this.refSet.getWorstNIndividuals(this.refSet.size() - this.refSetSize / 2, this.fitCrit), false); this.refSet.removeMembers(this.refSet.getWorstNIndividuals(this.refSet.size() - this.refSetSize / 2, this.fitCrit), false);
while (this.refSet.size() < this.refSetSize) { while (this.refSet.size() < this.refSetSize) {
ArrayList<Pair<Integer, Double>> list = new ArrayList<Pair<Integer, Double>>(); ArrayList<Pair<Integer, Double>> list = new ArrayList<>();
for (int i = 0; i < this.refSet.size(); i++) { for (int i = 0; i < this.refSet.size(); i++) {
AbstractEAIndividual indy = this.refSet.getEAIndividual(i); AbstractEAIndividual indy = this.refSet.getEAIndividual(i);
list.add(Population.getClosestFarthestIndy(indy, rest, new GenotypeMetricBitSet(), false)); list.add(Population.getClosestFarthestIndy(indy, rest, new GenotypeMetricBitSet(), false));
@ -547,7 +547,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
* @return the ordered List * @return the ordered List
*/ */
private ArrayList<Integer> order(ArrayList<Integer> list) { private ArrayList<Integer> order(ArrayList<Integer> list) {
ArrayList<Integer> result = new ArrayList<Integer>(); ArrayList<Integer> result = new ArrayList<>();
for (Integer s : list) { for (Integer s : list) {
boolean done = false; boolean done = false;
if (result.isEmpty()) { if (result.isEmpty()) {
@ -576,7 +576,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
private AbstractEAIndividual improve(AbstractEAIndividual indy) { private AbstractEAIndividual improve(AbstractEAIndividual indy) {
AbstractEAIndividual tmpIndy = (AbstractEAIndividual) indy.clone(); AbstractEAIndividual tmpIndy = (AbstractEAIndividual) indy.clone();
BitSet data = ((InterfaceDataTypeBinary) tmpIndy).getBinaryData(); BitSet data = ((InterfaceDataTypeBinary) tmpIndy).getBinaryData();
ArrayList<Integer> cl = new ArrayList<Integer>(); ArrayList<Integer> cl = new ArrayList<>();
int localIter = 0; int localIter = 0;
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
if (data.get(i)) { if (data.get(i)) {
@ -638,7 +638,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
* @return the List with all the combinations * @return the List with all the combinations
*/ */
public ArrayList<Population> generateSubsets() { public ArrayList<Population> generateSubsets() {
ArrayList<Population> result = new ArrayList<Population>(); ArrayList<Population> result = new ArrayList<>();
for (int i = 0; i < this.refSet.size(); i++) { for (int i = 0; i < this.refSet.size(); i++) {
for (int j = i + 1; j < this.refSet.size(); j++) { for (int j = i + 1; j < this.refSet.size(); j++) {
Population tmp = new Population(); Population tmp = new Population();

Some files were not shown because too many files have changed in this diff Show More