New @Hidden annotation to permanently hide properties from the UI.
refs #13
This commit is contained in:
parent
24597ad01b
commit
668dcb6974
@ -13,6 +13,8 @@ import eva2.optimization.operator.mutation.InterfaceMutation;
|
||||
import eva2.optimization.operator.mutation.MutateDefault;
|
||||
import eva2.optimization.operator.selection.InterfaceSelection;
|
||||
import eva2.optimization.operator.selection.SelectXProbRouletteWheel;
|
||||
import eva2.optimization.operator.terminators.CombinedTerminator;
|
||||
import eva2.optimization.operator.terminators.FitnessValueTerminator;
|
||||
import eva2.optimization.population.Population;
|
||||
import eva2.problems.AbstractProblemDouble;
|
||||
import eva2.problems.AbstractProblemDoubleOffset;
|
||||
@ -27,6 +29,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@ -310,15 +313,19 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
this.seed = Long.parseLong(commandLine.getOptionValue("seed"));
|
||||
}
|
||||
|
||||
if (commandLine.hasOption("problem")) {
|
||||
String problemName = commandLine.getOptionValue("problem");
|
||||
setProblemFromName(problemName);
|
||||
}
|
||||
|
||||
if (commandLine.hasOption("dim")) {
|
||||
this.dimension = Integer.parseInt(commandLine.getOptionValue("dim"));
|
||||
}
|
||||
this.problem.setProblemDimension(this.dimension);
|
||||
|
||||
if (commandLine.hasOption("problem")) {
|
||||
String problemName = commandLine.getOptionValue("problem");
|
||||
setProblemFromName(problemName);
|
||||
this.problem.setProblemDimension(this.dimension);
|
||||
} else {
|
||||
LOGGER.severe("No problem specified. Please specify a problem with '--problem'.");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
if (commandLine.hasOption("mutator")) {
|
||||
String mutatorName = commandLine.getOptionValue("mutator");
|
||||
@ -599,7 +606,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
setCECDefaults(this.problem);
|
||||
//setCECDefaults(this.problem);
|
||||
}
|
||||
|
||||
private void setCECDefaults(AbstractProblemDouble problem) {
|
||||
@ -634,7 +641,8 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
for(int i = 0; i < this.numberOfRuns; i++) {
|
||||
// Terminate after 10000 function evaluations OR after reaching a fitness < 0.1
|
||||
OptimizerFactory.setEvaluationTerminator(500000);
|
||||
//OptimizerFactory.addTerminator(new FitnessValueTerminator(new double[]{0.00001}), CombinedTerminator.OR);
|
||||
//OptimizerFactory.setTerminator(new FitnessValueTerminator(new double[]{0.0001}));
|
||||
OptimizerFactory.addTerminator(new FitnessValueTerminator(new double[]{0.0001}), CombinedTerminator.OR);
|
||||
|
||||
LOGGER.log(Level.INFO, "Running {0}", optimizer.getName());
|
||||
|
||||
|
@ -4,6 +4,7 @@ import eva2.gui.editor.GenericObjectEditor;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import eva2.tools.EVAHELP;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
@ -15,6 +16,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.beans.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.EventObject;
|
||||
@ -377,10 +379,17 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
}
|
||||
Method getter = props[i].getReadMethod();
|
||||
Method setter = props[i].getWriteMethod();
|
||||
|
||||
// Only display read/write properties.
|
||||
if (onlySetAndGettable && (getter == null || setter == null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Never show property if the @Hidden annotation is present
|
||||
if (setter != null && setter.isAnnotationPresent(Hidden.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Object args[] = {};
|
||||
Object value = null;
|
||||
try {
|
||||
|
@ -13,6 +13,7 @@ import eva2.optimization.population.Population;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.math.RNG;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -63,6 +64,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
return individualIndex;
|
||||
}
|
||||
|
||||
@Hidden
|
||||
public void setIndividualIndex(int index) {
|
||||
this.individualIndex = index;
|
||||
}
|
||||
@ -415,6 +417,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
*
|
||||
* @param age The new age.
|
||||
*/
|
||||
@Hidden
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
@ -480,6 +483,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
return this.isMarked;
|
||||
}
|
||||
|
||||
@Hidden
|
||||
public void setMarked(boolean t) {
|
||||
this.isMarked = t;
|
||||
}
|
||||
@ -547,6 +551,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
* @param fitness The new fitness array
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setFitness(double[] fitness) {
|
||||
this.fitness = fitness;
|
||||
}
|
||||
@ -781,6 +786,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
*
|
||||
* @param sel The new selection probability array
|
||||
*/
|
||||
@Hidden
|
||||
public void setSelectionProbability(double[] sel) {
|
||||
this.selectionProbability = sel;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import eva2.tools.EVAERROR;
|
||||
import eva2.tools.math.Mathematics;
|
||||
import eva2.tools.math.RNG;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
/**
|
||||
* This individual uses a real-valued genotype to code for double values.
|
||||
@ -153,6 +154,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
* @param range The new range for the double data.
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setDoubleRange(double[][] range) {
|
||||
if (range.length != this.range.length) {
|
||||
System.out.println("Warning: Trying to set a range of length " + range.length + " to a vector of length "
|
||||
@ -321,6 +323,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
* @param b The new genotype of the Individual
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setDGenotype(double[] b) {
|
||||
this.genotype = b;
|
||||
this.phenotype = null; // mark it as invalid
|
||||
|
@ -6,6 +6,7 @@ import eva2.optimization.population.Population;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
@ -239,6 +240,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
* @param range The new range for the double data.
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setDoubleRange(double[][] range) {
|
||||
this.doubleIndividual.setDoubleRange(range);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package eva2.optimization.strategies;
|
||||
|
||||
import eva2.gui.editor.GenericObjectEditor;
|
||||
import eva2.optimization.go.InterfacePopulationChangedEventListener;
|
||||
import eva2.optimization.population.Population;
|
||||
import eva2.problems.F1Problem;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.util.annotation.Hidden;
|
||||
import eva2.util.annotation.Parameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -67,9 +67,9 @@ public abstract class AbstractOptimizer implements InterfaceOptimizer {
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "problem", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
16
src/eva2/util/annotation/Hidden.java
Normal file
16
src/eva2/util/annotation/Hidden.java
Normal file
@ -0,0 +1,16 @@
|
||||
package eva2.util.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation used to permanently hide properties in the UI.
|
||||
*
|
||||
* Add the @Hidden annotation to any setter method and it will be hidden
|
||||
* from the user.
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Hidden { }
|
Loading…
x
Reference in New Issue
Block a user