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

View File

@ -156,7 +156,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
}
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");
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() {
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");
Set<Class<? extends AbstractProblemDoubleOffset>> problems = reflections.getSubTypesOf(AbstractProblemDoubleOffset.class);
for (Class<? extends AbstractProblemDoubleOffset> problem : problems) {
@ -185,7 +185,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
}
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");
Set<Class<? extends InterfaceMutation>> mutators = reflections.getSubTypesOf(InterfaceMutation.class);
for (Class<? extends InterfaceMutation> mutator : mutators) {
@ -199,7 +199,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
}
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");
Set<Class<? extends InterfaceCrossover>> crossovers = reflections.getSubTypesOf(InterfaceCrossover.class);
for (Class<? extends InterfaceCrossover> crossover : crossovers) {
@ -213,7 +213,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
}
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");
Set<Class<? extends InterfaceSelection>> selections = reflections.getSubTypesOf(InterfaceSelection.class);
for (Class<? extends InterfaceSelection> selection : selections) {

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@ public final class JEFrameRegister {
private JDesktopPane desktopPane;
private JEFrameRegister() {
this.frameList = new ArrayList<JEFrame>();
this.frameList = new ArrayList<>();
}
public static JEFrameRegister getInstance() {
@ -81,8 +81,8 @@ public final class JEFrameRegister {
* @return List of prefixes
*/
public String[] getCommonPrefixes(final int prefLen) {
List<String> prefixes = new ArrayList<String>();
List<Integer> count = new ArrayList<Integer>();
List<String> prefixes = new ArrayList<>();
List<Integer> count = new ArrayList<>();
for (int i = 0; i < frameList.size(); i++) {
String title = frameList.get(i).getTitle();
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) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
if (k != null) {
int modifiers = k.getModifiers();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ public class PropertySelectableList<T> implements java.io.Serializable {
@Override
public Object clone() {
return new PropertySelectableList<T>(this);
return new PropertySelectableList<>(this);
}
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
*/
private List<JButton> upperButtonList = new LinkedList<JButton>();
private List<JButton> upperButtonList = new LinkedList<>();
/**
* 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 List<JMenuItem> popupItemList = new LinkedList<JMenuItem>();
private List<JMenuItem> popupItemList = new LinkedList<>();
private JButton addButton = new JButton("Add");
private JButton setButton = new JButton("Set");
private JButton setAllButton = new JButton("Set all");
@ -272,11 +272,11 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
/**
* Creates a cell rendering component.
*
* @param JList the list that will be rendered in
* @param Object the cell value
* @param int which element of the list to render
* @param boolean true if the cell is selected
* @param boolean true if the cell has the focus
* @param list the list that will be rendered in
* @param value the cell value
* @param index which element of the list to render
* @param isSelected true if the cell is selected
* @param cellHasFocus true if the cell has the focus
* @return the rendering component
*/
@Override
@ -417,6 +417,7 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
JPanel combiUpperPanel = new JPanel(getButtonLayout(1, upperButtonList));
// ToDo Figure out how to now show this on Job Pane
combiUpperPanel.add(view);
view.setVisible(withAddButton);
for (JButton but : upperButtonList) {
combiUpperPanel.add(but);
@ -760,6 +761,10 @@ public class GenericArrayEditor extends JPanel implements PropertyEditor {
public void setWithAddButton(boolean 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() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -97,7 +97,7 @@ public class GraphPointSet {
private DPointIcon icon;
private String infoString = "Incomplete_Run";
private boolean isStatisticsGraph = false;
private ArrayList<PointSet> pointSetContainer = new ArrayList<PointSet>();
private ArrayList<PointSet> pointSetContainer = new ArrayList<>();
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
*/
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++) {
GraphPointSet pointset = pointSetContainer.get(i);
if (pointset.getPointSet().getSize() > 0) {
@ -59,7 +59,7 @@ public class GraphPointSetLegend {
} else {
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;
public OptimizationRun() {
this.fitness = new ArrayList<Double>();
this.fitness = new ArrayList<>();
}
public void addFitnessValue(double value) {

View File

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

View File

@ -557,7 +557,7 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
// data to be stored in file
double tmpd = 0;
StringBuffer tmpLine = new StringBuffer("");
StringBuilder tmpLine = new StringBuilder("");
tmpLine.append(population.getFunctionCalls());
tmpLine.append("\t");
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 InterfaceCrossover crossoverOperator = new NoCrossover();
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)
private int individualIndex = -1;
@ -156,9 +156,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
parentIDs = new Long[individual.parentIDs.length];
System.arraycopy(individual.parentIDs, 0, parentIDs, 0, parentIDs.length);
parentTree = new AbstractEAIndividual[individual.parentTree.length];
for (int i = 0; i < parentTree.length; i++) {
parentTree[i] = individual.parentTree[i];
}
System.arraycopy(individual.parentTree, 0, parentTree, 0, parentTree.length);
}
}
@ -406,7 +404,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
}
public String getHeritageTree(int depth) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(getIndyID());
sb.append(" ");
if ((depth > 0) && (parentTree != null)) {
@ -596,9 +594,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
this.fitness[index] = fitness;
} else {
double[] tmpD = new double[index + 1];
for (int i = 0; i < this.fitness.length; i++) {
tmpD[i] = this.fitness[i];
}
System.arraycopy(this.fitness, 0, tmpD, 0, this.fitness.length);
this.fitness = tmpD;
this.fitness[index] = fitness;
}
@ -833,9 +829,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
this.selectionProbability[index] = sel;
} else {
double[] tmpD = new double[index + 1];
for (int i = 0; i < this.selectionProbability.length; i++) {
tmpD[i] = this.selectionProbability[i];
}
System.arraycopy(this.selectionProbability, 0, tmpD, 0, this.selectionProbability.length);
this.selectionProbability = tmpD;
this.selectionProbability[index] = sel;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -144,7 +144,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
((GPNodeInput) currentNode).setIdentifier(currentNode.getOpIdentifier());
}
}
return new Pair<AbstractGPNode, String>(currentNode, restStr);
return new Pair<>(currentNode, restStr);
} else {
restStr = str.substring(cutFront + 1).trim(); // cut this op and front brace
currentNode.nodes = new AbstractGPNode[currentNode.getArity()];
@ -159,7 +159,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
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() {
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++) {
try {
AbstractGPNode node = (AbstractGPNode) Class.forName((String) cls.get(i)).newInstance();
@ -206,7 +206,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
}
try {
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) {
if (expect) {
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(
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++) {
String reqPrefix = nodeTypes.get(i).getOpIdentifier();
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)
int maxLen = matching.get(0).getOpIdentifier().length();
AbstractGPNode longest = matching.get(0);
Vector<AbstractGPNode> longestList = new Vector<AbstractGPNode>();
Vector<AbstractGPNode> longestList = new Vector<>();
longestList.add(longest);
for (int i = 1; i < matching.size(); i++) {
if (matching.get(i).getOpIdentifier().length() > maxLen) {
@ -338,7 +338,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @return
*/
public static String createNodeList() {
String ret = new String();
String ret = "";
Class<?> cls = AbstractGPNode.class;
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 ArrayList<AbstractGPNode> completeList = new ArrayList<AbstractGPNode>();
private ArrayList<AbstractGPNode> reducedList = new ArrayList<AbstractGPNode>();
private ArrayList<Boolean> blackList = new ArrayList<Boolean>();
private ArrayList<AbstractGPNode> completeList = new ArrayList<>();
private ArrayList<AbstractGPNode> reducedList = new ArrayList<>();
private ArrayList<Boolean> blackList = new ArrayList<>();
public GPArea() {
@ -50,7 +50,7 @@ public class GPArea implements java.io.Serializable {
*/
public void add2CompleteList(AbstractGPNode 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) {
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
*/
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
*/
public void compileReducedList() {
this.reducedList = new ArrayList<AbstractGPNode>();
this.reducedList = new ArrayList<>();
for (int i = 0; i < this.completeList.size(); i++) {
if (this.blackList.get(i).booleanValue()) {
this.reducedList.add(this.completeList.get(i));
@ -139,7 +139,7 @@ public class GPArea implements java.io.Serializable {
* @param targetarity The target arity.
*/
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++) {
if (this.reducedList.get(i).getArity() == targetarity) {
tmpArray.add(this.reducedList.get(i));
@ -167,7 +167,7 @@ public class GPArea implements java.io.Serializable {
* This method will return a non terminal
*/
public AbstractGPNode getRandomNonTerminal() {
ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>();
ArrayList<AbstractGPNode> tmpArray = new ArrayList<>();
for (int i = 0; i < this.reducedList.size(); i++) {
if (this.reducedList.get(i).getArity() > 0) {
tmpArray.add(this.reducedList.get(i));
@ -185,9 +185,9 @@ public class GPArea implements java.io.Serializable {
}
public void clear() {
completeList = new ArrayList<AbstractGPNode>();
reducedList = new ArrayList<AbstractGPNode>();
blackList = new ArrayList<Boolean>();
completeList = new ArrayList<>();
reducedList = new ArrayList<>();
blackList = new ArrayList<>();
propertyChangeSupport.firePropertyChange("GPArea", null, this);
}

View File

@ -99,7 +99,7 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
@Override
public void actionPerformed(ActionEvent event) {
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);
}

View File

@ -69,7 +69,7 @@ public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceP
public void actionPerformed(ActionEvent event) {
String s = textField.getText();
try {
int t = new Integer(s).intValue();
int t = Integer.parseInt(s);
mocco.state.initialPopulationSize = t;
} 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 sum = 0;
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];
}
if (new Double(sum).isNaN()) {
@ -226,7 +226,7 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
public void actionPerformed(ActionEvent event) {
double[] w = new double[tradeOffTextFields.length];
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();
// 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) {
// first read the values
try {
perturbations = new Integer(numPerTextField.getText()).intValue();
perturbations = Integer.parseInt(numPerTextField.getText());
} catch (java.lang.NumberFormatException e) {
System.out.println("Can't read k.");
}
try {
perturbation = new Double(sizePerTextField.getText()).doubleValue();
perturbation = Double.parseDouble(sizePerTextField.getText());
} catch (java.lang.NumberFormatException e) {
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];
relax = new double[refSolTextField.length];
for (int i = 0; i < refSolTextField.length; i++) {
weights[i] = new Double(weightTextField[i].getText()).doubleValue();
relax[i] = new Double(relaxTextField[i].getText()).doubleValue();
weights[i] = Double.parseDouble(weightTextField[i].getText());
relax[i] = Double.parseDouble(relaxTextField[i].getText());
if ((satisfied[i].isSelected()) && (obj[i].getOptimizationMode().contains("Objective"))) {
weights[i] = 0;
if (obj[i].is2BMinimized()) {

View File

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

View File

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

View File

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

View File

@ -157,7 +157,7 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
@Override
public void addInformableInstance(InterfaceNotifyOnInformers o) {
if (toInformAboutInformers == null) {
toInformAboutInformers = new LinkedList<InterfaceNotifyOnInformers>();
toInformAboutInformers = new LinkedList<>();
}
if (!toInformAboutInformers.contains(o)) {
toInformAboutInformers.add(o);
@ -193,7 +193,7 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
}
private List<InterfaceAdditionalPopulationInformer> getInformerList() {
LinkedList<InterfaceAdditionalPopulationInformer> ret = new LinkedList<InterfaceAdditionalPopulationInformer>();
LinkedList<InterfaceAdditionalPopulationInformer> ret = new LinkedList<>();
if (problem instanceof InterfaceAdditionalPopulationInformer) {
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.postprocess.PostProcess;
import eva2.optimization.operator.postprocess.PostProcessParams;
import eva2.optimization.operator.postprocess.SolutionHistogram;
import eva2.optimization.operator.terminators.EvaluationTerminator;
import eva2.optimization.operator.terminators.GenerationTerminator;
import eva2.optimization.operator.terminators.InterfaceTerminator;
import eva2.optimization.population.Population;
import eva2.optimization.population.PopulationInterface;
import eva2.problems.AbstractOptimizationProblem;
import eva2.problems.InterfaceAdditionalPopulationInformer;
import eva2.optimization.stat.InterfaceStatistics;
@ -398,7 +396,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
}
protected List<InterfaceAdditionalPopulationInformer> getInformerList() {
List<InterfaceAdditionalPopulationInformer> informerList = new ArrayList<InterfaceAdditionalPopulationInformer>(2);
List<InterfaceAdditionalPopulationInformer> informerList = new ArrayList<>(2);
informerList.add(this.optimizationParameters.getProblem());
if (this.optimizationParameters.getOptimizer() instanceof InterfaceAdditionalPopulationInformer) {
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];
for (int i = 0; i < a.SOM.length; i++) {
for (int j = 0; j < a.SOM[0].length; j++) {
for (int k = 0; k < a.SOM[0][0].length; k++) {
this.SOM[i][j][k] = a.SOM[i][j][k];
}
System.arraycopy(a.SOM[i][j], 0, this.SOM[i][j], 0, a.SOM[0][0].length);
}
}
}
@ -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];
for (int i = 0; i < a.SOMClass.length; i++) {
for (int j = 0; j < a.SOMClass[0].length; j++) {
for (int k = 0; k < a.SOMClass[0][0].length; k++) {
this.SOMClass[i][j][k] = a.SOMClass[i][j][k];
}
System.arraycopy(a.SOMClass[i][j], 0, this.SOMClass[i][j], 0, a.SOMClass[0][0].length);
}
}
}

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package eva2.optimization.operator.cluster;
import eva2.gui.BeanInspector;
import eva2.gui.editor.GenericObjectEditor;
import eva2.optimization.individuals.AbstractEAIndividual;
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.
int current = 0; // top indy is first
boolean[] clustered = new boolean[pop.size()];
LinkedList<Population> allClusters = new LinkedList<Population>();
LinkedList<Population> allClusters = new LinkedList<>();
while (current < sorted.size()) {
Population currentClust = pop.cloneWithoutInds();
currentClust.add(sorted.get(current));
@ -270,7 +269,7 @@ public class ClusteringNearestBetter implements InterfaceClustering, Serializabl
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());
for (Population clust : allClusters) {
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.
if (children[uplink[i]] == null) {
children[uplink[i]] = new Vector<Integer>();
children[uplink[i]] = new Vector<>();
}
children[uplink[i]].add(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][];
for (int i = 1; i < parents.length; i++) {
nParents[i - 1] = parents[i];
}
System.arraycopy(parents, 1, nParents, 0, parents.length - 1);
double[] g = Mathematics.meanVect(nParents), tmpD;
double w, v;
ArrayList givenCoordinates = this.getGivenCoordinates(g, nParents);
@ -103,9 +101,7 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
// now determine the offsprings
for (int i = 0; i < children.length; i++) {
// first the mean
for (int j = 0; j < g.length; j++) {
children[i][j] = g[j];
}
System.arraycopy(g, 0, children[i], 0, g.length);
// then the given coordinates
for (int j = 0; j < givenCoordinates.size(); j++) {
tmpD = (double[]) givenCoordinates.get(j);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package eva2.optimization.operator.mutation;
import eva2.gui.BeanInspector;
import eva2.gui.editor.GenericObjectEditor;
import eva2.optimization.enums.ESMutationInitialSigma;
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[] without = new int[x.length - length];
int[] insert = new int[length];
for (int i = 0; i < length; i++) {
insert[i] = x[i + from];
}
System.arraycopy(x, 0 + from, insert, 0, length);
for (int i = 0; i < without.length; i++) {
if (i < from) {
without[i] = x[i];
@ -113,15 +111,9 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa
without[i] = x[i + length];
}
}
for (int i = 0; i < to; i++) {
tmp[i] = without[i];
}
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.arraycopy(without, 0, tmp, 0, to);
System.arraycopy(insert, to - to, tmp, to, to + length - to);
System.arraycopy(without, to + length - length, tmp, to + length, x.length - (to + length));
// System.out.println(""+from+"/"+to+"/"+length);
// this.printInt("After ", 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.IndividualInterface;
import eva2.optimization.individuals.InterfaceGPIndividual;
import eva2.optimization.population.Population;
import eva2.problems.InterfaceOptimizationProblem;

View File

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

View File

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

View File

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

View File

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

View File

@ -131,7 +131,7 @@ public class ParameterControlManager implements InterfaceParameterControl, Seria
*/
public String[] getControlledParameters() {
if (singleAdapters != null) {
Vector<String> names = new Vector<String>(singleAdapters.length);
Vector<String> names = new Vector<>(singleAdapters.length);
for (ParamAdaption singleAdapter : singleAdapters) {
String prm = singleAdapter.getControlledParam();
if (prm != null) {
@ -183,9 +183,7 @@ public class ParameterControlManager implements InterfaceParameterControl, Seria
setSingleAdapters(new ParamAdaption[]{pa});
} else {
ParamAdaption[] newP = new ParamAdaption[singleAdapters.length + 1];
for (int i = 0; i < singleAdapters.length; i++) {
newP[i] = singleAdapters[i];
}
System.arraycopy(singleAdapters, 0, newP, 0, singleAdapters.length);
newP[newP.length - 1] = pa;
setSingleAdapters(newP);
}
@ -210,7 +208,7 @@ public class ParameterControlManager implements InterfaceParameterControl, Seria
public static List<Object> listOfControllables(
Object target) {
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.
// if (ownParamCtrl!=null) controllables.add(ownParamCtrl);
Object[] objs = propsNamesVals.tail;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,6 @@ import eva2.tools.math.Mathematics;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Vector;
@ -52,7 +51,7 @@ public class PostProcess {
// lower limit mutation step size for HC post processing
private static double minMutationStepSize = 0.0000000000000001;
// 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 movedToPositionKey = "PostProcessingMovedTo";
@ -347,7 +346,7 @@ public class PostProcess {
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;
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;
pop.setFunctionCalls(funCallsBefore);
return new Pair<Integer, Boolean>(funCallsDone, ppRunnable.wasAborted());
return new Pair<>(funCallsDone, ppRunnable.wasAborted());
}
private static boolean checkRange(AbstractEAIndividual indy) {
@ -538,7 +537,7 @@ public class PostProcess {
pop.add(cand);
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)
*/
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;
Population subPop;
@ -906,7 +905,7 @@ public class PostProcess {
Population found = getFoundOptima(pop, mmp.getRealOptima(), 0.05, true);
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 evalCnt = 0;
while (popD.tail() > 0.001) {
@ -947,7 +946,7 @@ public class PostProcess {
clust.setFunctionCalls(evalsBefore + evalsDone);
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;
import eva2.gui.BeanInspector;
import eva2.optimization.population.InterfaceSolutionSet;
import eva2.optimization.population.PopulationInterface;
import eva2.problems.InterfaceOptimizationProblem;
@ -129,7 +128,7 @@ public abstract class PopulationMeasureTerminator implements InterfaceTerminator
* @return
*/
protected String getTerminationMessage() {
StringBuffer sb = new StringBuffer(getMeasureName());
StringBuilder sb = new StringBuilder(getMeasureName());
// if (convergenceCondition.isSelectedString("Relative")) sb.append(" converged relatively ");
switch (changeType) {
case absoluteChange:

View File

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

View File

@ -56,7 +56,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
*/
PopulationInitMethod initMethod = PopulationInitMethod.individualDefault;
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;
transient private ArrayList<InterfacePopulationChangedEventListener> listeners = null;
@ -80,7 +80,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
/**
* 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.
@ -150,7 +150,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
this(allSolutions.getCurrentPopulation().size() + allSolutions.getSolutions().size());
LOGGER.log(Level.FINER, "New population has been created.");
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++) {
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) {
this(targetSize);
this.setSeedCardinality(new Pair<Integer, Integer>(binCard, binStdDev));
this.setSeedCardinality(new Pair<>(binCard, binStdDev));
this.setInitMethod(PopulationInitMethod.binCardinality);
}
@ -231,7 +231,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
listeners = null;
}
if (population.additionalPopData != null) {
additionalPopData = new HashMap<String, Object>();
additionalPopData = new HashMap<>();
Set<String> keys = additionalPopData.keySet();
for (String key : keys) {
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) {
if (additionalPopData == null) {
additionalPopData = new HashMap<String, Object>();
additionalPopData = new HashMap<>();
}
additionalPopData.put(key, value);
}
@ -364,7 +364,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
* been inited by a problem
*/
public void init() {
this.historyList = new LinkedList<AbstractEAIndividual>();
this.historyList = new LinkedList<>();
this.generationCount = 0;
this.functionCallCount = 0;
double[] popSeed = null;
@ -749,7 +749,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
if (ea != null) {
if (listeners == null) {
listeners = new ArrayList<InterfacePopulationChangedEventListener>(3);
listeners = new ArrayList<>(3);
}
if (!listeners.contains(ea)) {
listeners.add(ea);
@ -836,11 +836,11 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
* @return
*/
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++) {
int nextIndex = indexByPosition(i + 1, getEAIndividual(i));
if (nextIndex >= 0) {
dupes.add(new Pair<Integer, Integer>(i, nextIndex));
dupes.add(new Pair<>(i, nextIndex));
}
}
return dupes;
@ -1288,16 +1288,16 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
*/
protected ArrayList<AbstractEAIndividual> sortBy(Comparator<Object> comp) {
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++) {
AbstractEAIndividual indy = getEAIndividual(i);
if (indy != null) {
sQueue.add(indy);
}
}
ArrayList<AbstractEAIndividual> sArr = new ArrayList<AbstractEAIndividual>(this.size());
ArrayList<AbstractEAIndividual> sArr = new ArrayList<>(this.size());
AbstractEAIndividual indy;
while ((indy = sQueue.poll()) != null) {
sArr.add(indy);
@ -2040,7 +2040,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
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();
ArrayList<Double> distances = null;
if (calcVariance) {
distances = new ArrayList<Double>(size());
distances = new ArrayList<>(size());
}
double sum = 0;
double d = 0;

View File

@ -3,7 +3,6 @@ package eva2.optimization.stat;
import eva2.gui.BeanInspector;
import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.individuals.IndividualInterface;
import eva2.optimization.operator.distancemetric.InterfaceDistanceMetric;
import eva2.optimization.population.Population;
import eva2.optimization.population.PopulationInterface;
import eva2.problems.InterfaceAdditionalPopulationInformer;
@ -110,13 +109,13 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
convergenceCnt = 0;
optRunsPerformed = 0;
iterationCounter = 0;
textListeners = new ArrayList<InterfaceTextListener>();
textListeners = new ArrayList<>();
}
@Override
public void addDataListener(InterfaceStatisticsListener l) {
if (dataListeners == null) {
dataListeners = new LinkedList<InterfaceStatisticsListener>();
dataListeners = new LinkedList<>();
}
if (l != null && !dataListeners.contains(l)) {
dataListeners.add(l);
@ -142,7 +141,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
private void fireDataListenersFinalize() {
if (dataListeners != null) {
LinkedList<InterfaceStatisticsListener> toRemove = new LinkedList<InterfaceStatisticsListener>();
LinkedList<InterfaceStatisticsListener> toRemove = new LinkedList<>();
for (InterfaceStatisticsListener l : dataListeners) {
boolean rm = l.notifyMultiRunFinished(currentStatHeader, finalObjectData);
if (rm) {
@ -277,12 +276,12 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
bestFeasibleAllRuns = null;
// meanBestOfRunFitness = null;
// meanBestFeasibleFit = null;
runBestFeasibleList = new ArrayList<IndividualInterface>();
runBestFitList = new ArrayList<IndividualInterface>();
runBestFeasibleList = new ArrayList<>();
runBestFitList = new ArrayList<>();
// if (refineMultiRuns) meanCollection = new ArrayList<double[][]>();
// else meanCollection = null;
if (refineMultiRuns) {
sumDataCollection = new ArrayList<Double[]>();
sumDataCollection = new ArrayList<>();
} else {
sumDataCollection = null;
}
@ -393,7 +392,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
}
}
if (finalObjectData == null) {
finalObjectData = new ArrayList<Object[]>();
finalObjectData = new ArrayList<>();
}
finalObjectData.add(currentStatObjectData);
@ -571,7 +570,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
// String header = getOutputHeader(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('\n');
sbuf.append(StringTools.concatValues(vals, textFieldDelimiter));
@ -610,7 +609,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
}
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++) {
dblAList.add(list.get(i).getFitness());
}
@ -702,7 +701,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @return
*/
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()));
if (informerList != null) {
headlineFields.addAll(getAdditionalHeaderMetaInfo(informerList, null));
@ -718,8 +717,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @return
*/
protected List<String> getOutputMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList) {
ArrayList<String> infoStrings = new ArrayList<String>(5);
ArrayList<String> addStrings = new ArrayList<String>(5);
ArrayList<String> infoStrings = new ArrayList<>(5);
ArrayList<String> addStrings = new ArrayList<>(5);
infoStrings.addAll(Arrays.asList(getSimpleOutputMetaInfo()));
if (informerList != null) {
getAdditionalHeaderMetaInfo(informerList, addStrings);
@ -745,7 +744,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
protected String[] getSimpleOutputHeader() {
// collect the full header by using the entries of the GraphSelectionEnum
GraphSelectionEnum[] vals = GraphSelectionEnum.values();
ArrayList<String> headerEntries = new ArrayList<String>();
ArrayList<String> headerEntries = new ArrayList<>();
headerEntries.add("FunctionCalls");
for (GraphSelectionEnum val : vals) {
if (isRequestedField(val)) {
@ -765,7 +764,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
*/
protected String[] getSimpleOutputMetaInfo() {
GraphSelectionEnum[] vals = GraphSelectionEnum.values();
ArrayList<String> headerInfo = new ArrayList<String>();
ArrayList<String> headerInfo = new ArrayList<>();
headerInfo.add("The number of function evaluations");
for (int i = 0; i < vals.length; i++) {
if (isRequestedField(vals[i])) {
@ -872,7 +871,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @see #getOutputHeaderFieldNames(java.util.List) (List)
*/
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()));
if (informerList != null) {
for (InterfaceAdditionalPopulationInformer informer : informerList) {
@ -906,7 +905,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @return
*/
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)) {
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);
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,
StatsOnSingleDataSetEnum[] singleStats,
StatsOnTwoSampledDataEnum[] twoSampledStats) {
ArrayList<OptimizationJob> jobsToWorkWith = new ArrayList<OptimizationJob>();
ArrayList<OptimizationJob> jobsToWorkWith = new ArrayList<>();
for (int i = 0; i < jobList.length; i++) {
// remove jobs which are not finished or not selected
if (jobList[i] != null && (Mathematics.contains(selectedIndices, i)) && (jobList[i].isFinishedAndComplete())) {
@ -299,10 +299,10 @@ public class EvAStatisticalEvaluation {
* @return
*/
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) {
if (lSoFar == null) {
lSoFar = new LinkedList<String>();
lSoFar = new LinkedList<>();
for (String f : j.getFieldHeaders()) {
lSoFar.add(f);
}
@ -313,7 +313,7 @@ public class EvAStatisticalEvaluation {
}
}
lSoFar = tmpL;
tmpL = new LinkedList<String>();
tmpL = new LinkedList<>();
}
}
return lSoFar;

View File

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

View File

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

View File

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

View File

@ -206,8 +206,8 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
public void plotSpecificData(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informer) {
double[] specificData = pop.getSpecificData();
int calls = pop.getFunctionCalls();
ArrayList<String[]> description = new ArrayList<String[]>();
ArrayList<String> temp = new ArrayList<String>();
ArrayList<String[]> description = new ArrayList<>();
ArrayList<String> temp = new ArrayList<>();
String[] ss = pop.getSpecificDataNames();
for (int i = 0; i < ss.length; i++) {
if (ss[i].lastIndexOf("*") == -1) {
@ -216,7 +216,7 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
String[] line = new String[temp.size()];
temp.toArray(line);
description.add(line);
temp = new ArrayList<String>();
temp = new ArrayList<>();
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
// 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
int[][] s = new int[mainSwarmSize][mainSwarmSize];
@ -215,7 +215,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi
initSTo(0);
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
*/
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) {
Population pop = setOfSubswarms.get(i);
@ -521,7 +521,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi
List<Set<String>> connectedComps = nicheGraph.getConnectedComponents();
Population tmpPop = new Population(), newMainPop = new Population();
Vector<Population> setOfSubswarms = new Vector<Population>();
Vector<Population> setOfSubswarms = new Vector<>();
boolean reinitSuperfl = true;
for (Set<String> connSet : connectedComps) {

View File

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

View File

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

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