Some cosmetics, e.g. to older MOCCO classes
This commit is contained in:
		@@ -4,6 +4,16 @@ package eva2;
 | 
			
		||||
 * Main product and version information strings.
 | 
			
		||||
 * 
 | 
			
		||||
 * --- Changelog
 | 
			
		||||
 * 2.033: There was an interesting problem with the Matlab-Interface, which just hung up after extensive optimization
 | 
			
		||||
 * 			loops, yet only if Matlab was started without X-forwarding (which is necessary for qsub, e.g.).
 | 
			
		||||
 * 			Debugging was tedious, since the debugging using System.out. itself caused threading deadlocks. The 
 | 
			
		||||
 * 			problem showed up to be with System.out itself. Whatever Matlab does with that stream, it does it differently
 | 
			
		||||
 * 			depending on the X-forwarding option. More specifically, the text written to System.out when X-forwarding
 | 
			
		||||
 * 			is not available seems to never show up (as opposed to being printed to the console when X-forwarding is on)
 | 
			
		||||
 * 			and silently fill up the JVM-memory. I havent the faintest idea why there havnt been OutOfMemory exceptions
 | 
			
		||||
 * 			earlier or whether and how the deadlocks have to do with it. 
 | 
			
		||||
 * 			The ingeniuos solution was: dont print anything to System.out, which is now done at verbosity 0.
 | 
			
		||||
 * 2.032: Some cosmetics, e.g. to AbstractEAIndividualComparator and older MOCCO classes. 
 | 
			
		||||
 * 2.031: Some updates to the OptimizerFactory. Review of the MatlabInterface with adding an own options structure.
 | 
			
		||||
 * 			Better access to the EvAClient, which now may have a RemoteStateListener added monitoring the optimization run.
 | 
			
		||||
 * 2.030: Added an EnumEditor to access enums easily through the GUI, which will replace SelectedTags sometimes.
 | 
			
		||||
 
 | 
			
		||||
@@ -594,6 +594,43 @@ public class BeanInspector {
 | 
			
		||||
		return value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Try to get an object member value.
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param obj
 | 
			
		||||
	 * @param mem
 | 
			
		||||
	 * @return the value if successful, else null
 | 
			
		||||
	 */
 | 
			
		||||
	public static Object getMem(Object obj, String mem) {
 | 
			
		||||
		BeanInfo bi;    
 | 
			
		||||
		try {
 | 
			
		||||
			bi      = Introspector.getBeanInfo(obj.getClass());
 | 
			
		||||
		} catch(IntrospectionException e) {
 | 
			
		||||
			e.printStackTrace();
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		PropertyDescriptor[] 	m_Properties = bi.getPropertyDescriptors();
 | 
			
		||||
		Method getter = null;
 | 
			
		||||
		for (int i = 0; i < m_Properties.length; i++) {
 | 
			
		||||
			if (m_Properties[i].getDisplayName().equals(mem)) {
 | 
			
		||||
				getter  = m_Properties[i].getReadMethod();
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (getter != null) {
 | 
			
		||||
			try {
 | 
			
		||||
				return getter.invoke(obj, (Object[]) null);
 | 
			
		||||
			} catch (Exception e) {
 | 
			
		||||
				System.err.println("Exception in invoking setter: "+e.getMessage());
 | 
			
		||||
				return null;
 | 
			
		||||
			} 
 | 
			
		||||
		} else {
 | 
			
		||||
			System.err.println("Getter method for " + mem + " not found!");
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Try to set an object member to a given value.
 | 
			
		||||
	 * Returns true if successful, else false. The types are adapted as generally as possible,
 | 
			
		||||
 
 | 
			
		||||
@@ -567,7 +567,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true, if the first fitness vector dominates the second one in every component.
 | 
			
		||||
     * Returns true if the first fitness vector dominates the second one in every component.
 | 
			
		||||
     * Symmetric case: if the vectors are equal, true is returned.
 | 
			
		||||
     * 
 | 
			
		||||
     * @param fit1 first fitness vector to look at
 | 
			
		||||
@@ -585,7 +585,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true, if the first fitness vector truly dominates the second one in every component.
 | 
			
		||||
     * Returns true if the first fitness vector truly dominates the second one in every component.
 | 
			
		||||
     * 
 | 
			
		||||
     * @param fit1 first fitness vector to look at
 | 
			
		||||
     * @param fit2 second fitness vector to look at
 | 
			
		||||
@@ -605,7 +605,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
 | 
			
		||||
     * Note this is dominance! If the individuals are not comparable this method will
 | 
			
		||||
     * return false!
 | 
			
		||||
     * @param indy      The individual to compare to.
 | 
			
		||||
     * @return True if better false else
 | 
			
		||||
     * @return True if the own fitness dominates the other indy's
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isDominatingDebConstraints(AbstractEAIndividual indy) {
 | 
			
		||||
        double[]    tmpFitness  = indy.getFitness();
 | 
			
		||||
@@ -956,10 +956,18 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
 | 
			
		||||
    	return isDominatingFitnessNotEqual(m_Fitness, otherFitness);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * @return true if the own fitness dominates otherFitness.
 | 
			
		||||
     * @see #isDominatingFitness(double[], double[])
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isDominant(double[] otherFitness) {
 | 
			
		||||
    	return isDominatingFitness(m_Fitness, otherFitness);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * @return true if the individual dominates the given one.
 | 
			
		||||
     * @see #isDominatingDebConstraints(AbstractEAIndividual)
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isDominant(IndividualInterface indy) {
 | 
			
		||||
    	return isDominatingDebConstraints((AbstractEAIndividual)indy);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -7,11 +7,15 @@ import java.util.Comparator;
 | 
			
		||||
 * The default version calls isDominatingDebConstraints() of the AbstractEAIndividual
 | 
			
		||||
 * class and assigns -1 if first is dominant, 1 if second is dominant, 0 if the two ind.s
 | 
			
		||||
 * are not comparable.
 | 
			
		||||
 * By default, the dominance criterion is used on fitness vectors.
 | 
			
		||||
 * If a specific criterion i is set, the comparison is based only on the i-th 
 | 
			
		||||
 * entry of the fitness vector.
 | 
			
		||||
 * As an alternative, a data key String may be set which is then used to request a data
 | 
			
		||||
 * object from the individuals. The objects are interpreted as fitness vectors (double[]) and
 | 
			
		||||
 * the comparison is based on those. This may be used to access alternative (e.g. older or
 | 
			
		||||
 * best-so-far fitness values) for individual comparison.
 | 
			
		||||
 *
 | 
			
		||||
 * @see #AbstractEAIndividual().isDominatingFitness(double[], double[])
 | 
			
		||||
 * @author mkron
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
@@ -19,6 +23,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object> {
 | 
			
		||||
 | 
			
		||||
	// flag whether a data field should be used.
 | 
			
		||||
	String indyDataKey = null;
 | 
			
		||||
	int fitCriterion = -1;
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Comparator implementation which compares two individuals based on their fitness.
 | 
			
		||||
@@ -28,7 +33,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object> {
 | 
			
		||||
	 *
 | 
			
		||||
	 */
 | 
			
		||||
	public AbstractEAIndividualComparator() {
 | 
			
		||||
		indyDataKey = null;
 | 
			
		||||
		this(null, -1);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
@@ -41,9 +46,32 @@ public class AbstractEAIndividualComparator implements Comparator<Object> {
 | 
			
		||||
	 * @param indyDataKey
 | 
			
		||||
	 */
 | 
			
		||||
	public AbstractEAIndividualComparator(String indyDataKey) {
 | 
			
		||||
		this.indyDataKey = indyDataKey;		
 | 
			
		||||
		this(indyDataKey, -1);		
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Constructor for a specific fitness criterion in the multiobjective case. 
 | 
			
		||||
	 * For comparison, only the given fitness criterion is used if it is >= 0.
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param fitnessCriterion
 | 
			
		||||
	 */
 | 
			
		||||
	public AbstractEAIndividualComparator(int fitnessCriterion) {
 | 
			
		||||
		this(null, fitnessCriterion);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Generic constructor.
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @see #AbstractEAIndividualComparator(int)
 | 
			
		||||
	 * @see #AbstractEAIndividualComparator(String)
 | 
			
		||||
	 * @param indyDataKey
 | 
			
		||||
	 * @param fitnessCriterion
 | 
			
		||||
	 */
 | 
			
		||||
	public AbstractEAIndividualComparator(String indDataKey, int fitnessCriterion) {
 | 
			
		||||
		indyDataKey = indDataKey;
 | 
			
		||||
		fitCriterion = fitnessCriterion;	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public AbstractEAIndividualComparator(AbstractEAIndividualComparator other) {
 | 
			
		||||
		indyDataKey = other.indyDataKey;
 | 
			
		||||
	}
 | 
			
		||||
@@ -58,7 +86,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object> {
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param o1 the first AbstractEAIndividual to compare
 | 
			
		||||
	 * @param o2 the second AbstractEAIndividual to compare
 | 
			
		||||
	 * @return -1 if the first is dominant, 1 if the second is dominant, else 0
 | 
			
		||||
	 * @return -1 if the first is dominant, 1 if the second is dominant, otherwise 0
 | 
			
		||||
	 */
 | 
			
		||||
	public int compare(Object o1, Object o2) {
 | 
			
		||||
		boolean o1domO2, o2domO1;
 | 
			
		||||
@@ -66,11 +94,21 @@ public class AbstractEAIndividualComparator implements Comparator<Object> {
 | 
			
		||||
		if (indyDataKey != null) {
 | 
			
		||||
			double[] fit1 = (double[])((AbstractEAIndividual)o1).getData(indyDataKey);
 | 
			
		||||
			double[] fit2 = (double[])((AbstractEAIndividual)o2).getData(indyDataKey);
 | 
			
		||||
			o1domO2 = AbstractEAIndividual.isDominatingFitness(fit1, fit2);
 | 
			
		||||
			o2domO1 = AbstractEAIndividual.isDominatingFitness(fit2, fit1);
 | 
			
		||||
			if (fitCriterion < 0) {
 | 
			
		||||
				o1domO2 = AbstractEAIndividual.isDominatingFitness(fit1, fit2);
 | 
			
		||||
				o2domO1 = AbstractEAIndividual.isDominatingFitness(fit2, fit1);
 | 
			
		||||
			} else {
 | 
			
		||||
				if (fit1[fitCriterion] == fit2[fitCriterion]) return 0;
 | 
			
		||||
				else return (fit1[fitCriterion] < fit2[fitCriterion]) ? -1 : 1;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			o1domO2 = ((AbstractEAIndividual) o1).isDominatingDebConstraints((AbstractEAIndividual) o2);
 | 
			
		||||
			o2domO1 = ((AbstractEAIndividual) o2).isDominatingDebConstraints((AbstractEAIndividual) o1);
 | 
			
		||||
			if (fitCriterion < 0) {
 | 
			
		||||
				o1domO2 = ((AbstractEAIndividual) o1).isDominatingDebConstraints((AbstractEAIndividual) o2);
 | 
			
		||||
				o2domO1 = ((AbstractEAIndividual) o2).isDominatingDebConstraints((AbstractEAIndividual) o1);
 | 
			
		||||
			} else {
 | 
			
		||||
				if (((AbstractEAIndividual) o1).getFitness()[fitCriterion] == ((AbstractEAIndividual) o2).getFitness()[fitCriterion]) return 0;
 | 
			
		||||
				return (((AbstractEAIndividual) o1).getFitness()[fitCriterion] < ((AbstractEAIndividual) o2).getFitness()[fitCriterion]) ? -1 : 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (o1domO2 ^ o2domO1) return (o1domO2 ? -1 : 1);
 | 
			
		||||
		else return 0; // these are not comparable
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceP
 | 
			
		||||
        
 | 
			
		||||
        Class[] altern = null;
 | 
			
		||||
		try {
 | 
			
		||||
			altern = ReflectPackage.getAssignableClassesInPackage("eva2.server.oa.go.OptimizationProblems", Class.forName("eva2.server.oa.go.OptimizationProblems.InterfaceMultiObjectiveDeNovoProblem"), true, true);
 | 
			
		||||
			altern = ReflectPackage.getAssignableClassesInPackage("eva2.server.go.problems", Class.forName("eva2.server.go.problems.InterfaceMultiObjectiveDeNovoProblem"), true, true);
 | 
			
		||||
		} catch (ClassNotFoundException e) {
 | 
			
		||||
			// TODO Auto-generated catch block
 | 
			
		||||
			e.printStackTrace();
 | 
			
		||||
 
 | 
			
		||||
@@ -321,122 +321,6 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
//    private void updateHistory() {
 | 
			
		||||
//        this.m_History.removeAll();
 | 
			
		||||
//        this.m_History.setLayout(new GridBagLayout());
 | 
			
		||||
//        this.m_JLIternations    = new JLabel[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//        this.m_JLIterSize       = new JLabel[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//        this.m_JCUse            = new JCheckBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//        this.m_JCShow           = new JCheckBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//        this.m_JColor           = new JComboBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//        GridBagConstraints gbc = new GridBagConstraints();
 | 
			
		||||
//        gbc.anchor      = GridBagConstraints.WEST;
 | 
			
		||||
//        gbc.fill        = GridBagConstraints.BOTH;
 | 
			
		||||
//        gbc.gridx       = 0;
 | 
			
		||||
//        gbc.gridy       = 0;
 | 
			
		||||
//        gbc.weightx     = 1;
 | 
			
		||||
//        this.m_History.add(new JLabel("Iteration"), gbc);
 | 
			
		||||
//        gbc.gridx       = 1;
 | 
			
		||||
//        gbc.gridy       = 0;
 | 
			
		||||
//        this.m_History.add(new JLabel("Size"), gbc);
 | 
			
		||||
//        gbc.gridx       = 2;
 | 
			
		||||
//        gbc.gridy       = 0;
 | 
			
		||||
//        this.m_History.add(new JLabel("Use"), gbc);
 | 
			
		||||
//        gbc.gridx       = 3;
 | 
			
		||||
//        gbc.gridy       = 0;
 | 
			
		||||
//        this.m_History.add(new JLabel("Show"), gbc);
 | 
			
		||||
//        gbc.gridx       = 4;
 | 
			
		||||
//        gbc.gridy       = 0;
 | 
			
		||||
//        this.m_History.add(new JLabel("Color"), gbc);
 | 
			
		||||
//        for (int i = 0; i < this.m_MOCCO.m_State.m_PopulationHistory.length; i++) {
 | 
			
		||||
//            gbc.gridx       = 0;
 | 
			
		||||
//            gbc.gridy       = i+1;
 | 
			
		||||
//            this.m_History.add(new JLabel((i+0)+"."), gbc);
 | 
			
		||||
//            gbc.gridx       = 1;
 | 
			
		||||
//            gbc.gridy       = i+1;
 | 
			
		||||
//            this.m_History.add(new JLabel(this.m_MOCCO.m_State.m_PopulationHistory[i].size()+""), gbc);
 | 
			
		||||
//            gbc.gridx       = 2;
 | 
			
		||||
//            gbc.gridy       = i+1;
 | 
			
		||||
//            this.m_JCUse[i] = new JCheckBox();
 | 
			
		||||
//            this.m_JCUse[i].setSelected(this.m_MOCCO.m_State.m_Use[i]);
 | 
			
		||||
//            this.m_JCUse[i].addActionListener(useModeChanged);
 | 
			
		||||
//            this.m_History.add(this.m_JCUse[i], gbc);
 | 
			
		||||
//            gbc.gridx       = 3;
 | 
			
		||||
//            gbc.gridy       = i+1;
 | 
			
		||||
//            this.m_JCShow[i] = new JCheckBox();
 | 
			
		||||
//            this.m_JCShow[i].setSelected(this.m_MOCCO.m_State.m_Show[i]);
 | 
			
		||||
//            this.m_JCShow[i].addActionListener(showModeChanged);
 | 
			
		||||
//            this.m_History.add(this.m_JCShow[i], gbc);
 | 
			
		||||
//            gbc.gridx       = 4;
 | 
			
		||||
//            gbc.gridy       = i+1;
 | 
			
		||||
//            this.m_JColor[i] = this.getComboBox(i);
 | 
			
		||||
//            this.m_JColor[i].addActionListener(colorModeChanged);
 | 
			
		||||
//            this.m_History.add(this.m_JColor[i], gbc);
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    ActionListener useModeChanged = new ActionListener() {
 | 
			
		||||
//        public void actionPerformed(ActionEvent event) {
 | 
			
		||||
//            for (int i = 0; i < m_JCUse.length; i++) {
 | 
			
		||||
//                m_MOCCO.m_State.m_Use[i] = m_JCUse[i].isSelected();
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//    };
 | 
			
		||||
//    ActionListener showModeChanged = new ActionListener() {
 | 
			
		||||
//        public void actionPerformed(ActionEvent event) {
 | 
			
		||||
//            for (int i = 0; i < m_JCShow.length; i++) {
 | 
			
		||||
//                m_MOCCO.m_State.m_Show[i] = m_JCShow[i].isSelected();
 | 
			
		||||
//            }
 | 
			
		||||
//            m_View.updateView();
 | 
			
		||||
//        }
 | 
			
		||||
//    };
 | 
			
		||||
//    ActionListener colorModeChanged = new ActionListener() {
 | 
			
		||||
//        public void actionPerformed(ActionEvent event) {
 | 
			
		||||
//            for (int i = 0; i < m_JColor.length; i++) {
 | 
			
		||||
//                m_MOCCO.m_State.m_Color[i] = getColor(m_JColor[i].getSelectedIndex());
 | 
			
		||||
//            }
 | 
			
		||||
//            m_View.updateView();
 | 
			
		||||
//        }
 | 
			
		||||
//    };
 | 
			
		||||
//
 | 
			
		||||
//    private JComboBox getComboBox(int index) {
 | 
			
		||||
//        String[] colors = {"RED", "BLUE", "GREEN", "CYAN", "MAGENTA", "ORANGE"};
 | 
			
		||||
//        JComboBox result;
 | 
			
		||||
//        result = new JComboBox(colors);
 | 
			
		||||
//        int color = 0;
 | 
			
		||||
//        if (this.m_MOCCO.m_State.m_Color[index] == Color.RED)     color = 0;
 | 
			
		||||
//        if (this.m_MOCCO.m_State.m_Color[index] == Color.BLUE)    color = 1;
 | 
			
		||||
//        if (this.m_MOCCO.m_State.m_Color[index] == Color.GREEN)   color = 2;
 | 
			
		||||
//        if (this.m_MOCCO.m_State.m_Color[index] == Color.CYAN)    color = 3;
 | 
			
		||||
//        if (this.m_MOCCO.m_State.m_Color[index] == Color.MAGENTA) color = 4;
 | 
			
		||||
//        if (this.m_MOCCO.m_State.m_Color[index] == Color.ORANGE)  color = 5;
 | 
			
		||||
//        result.setSelectedIndex(color);
 | 
			
		||||
//        return result;
 | 
			
		||||
//    }
 | 
			
		||||
//    public Color getColor(int i) {
 | 
			
		||||
//        switch (i)  {
 | 
			
		||||
//            case 0 : {
 | 
			
		||||
//                return Color.RED;
 | 
			
		||||
//            }
 | 
			
		||||
//            case 1 : {
 | 
			
		||||
//                return Color.BLUE;
 | 
			
		||||
//            }
 | 
			
		||||
//            case 2 : {
 | 
			
		||||
//                return Color.GREEN;
 | 
			
		||||
//            }
 | 
			
		||||
//            case 3 : {
 | 
			
		||||
//                return Color.CYAN;
 | 
			
		||||
//            }
 | 
			
		||||
//            case 4 : {
 | 
			
		||||
//                return Color.MAGENTA;
 | 
			
		||||
//            }
 | 
			
		||||
//            case 5 : {
 | 
			
		||||
//                return Color.ORANGE;
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//        return Color.BLACK;
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    public void problemChanged(boolean t) {
 | 
			
		||||
        this.m_MOCCO.m_State.makeFitnessCache(t);
 | 
			
		||||
        //this.updateHistory();
 | 
			
		||||
@@ -614,4 +498,120 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
 | 
			
		||||
        this.m_View.updateView();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
//  private void updateHistory() {
 | 
			
		||||
//      this.m_History.removeAll();
 | 
			
		||||
//      this.m_History.setLayout(new GridBagLayout());
 | 
			
		||||
//      this.m_JLIternations    = new JLabel[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//      this.m_JLIterSize       = new JLabel[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//      this.m_JCUse            = new JCheckBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//      this.m_JCShow           = new JCheckBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//      this.m_JColor           = new JComboBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
 | 
			
		||||
//      GridBagConstraints gbc = new GridBagConstraints();
 | 
			
		||||
//      gbc.anchor      = GridBagConstraints.WEST;
 | 
			
		||||
//      gbc.fill        = GridBagConstraints.BOTH;
 | 
			
		||||
//      gbc.gridx       = 0;
 | 
			
		||||
//      gbc.gridy       = 0;
 | 
			
		||||
//      gbc.weightx     = 1;
 | 
			
		||||
//      this.m_History.add(new JLabel("Iteration"), gbc);
 | 
			
		||||
//      gbc.gridx       = 1;
 | 
			
		||||
//      gbc.gridy       = 0;
 | 
			
		||||
//      this.m_History.add(new JLabel("Size"), gbc);
 | 
			
		||||
//      gbc.gridx       = 2;
 | 
			
		||||
//      gbc.gridy       = 0;
 | 
			
		||||
//      this.m_History.add(new JLabel("Use"), gbc);
 | 
			
		||||
//      gbc.gridx       = 3;
 | 
			
		||||
//      gbc.gridy       = 0;
 | 
			
		||||
//      this.m_History.add(new JLabel("Show"), gbc);
 | 
			
		||||
//      gbc.gridx       = 4;
 | 
			
		||||
//      gbc.gridy       = 0;
 | 
			
		||||
//      this.m_History.add(new JLabel("Color"), gbc);
 | 
			
		||||
//      for (int i = 0; i < this.m_MOCCO.m_State.m_PopulationHistory.length; i++) {
 | 
			
		||||
//          gbc.gridx       = 0;
 | 
			
		||||
//          gbc.gridy       = i+1;
 | 
			
		||||
//          this.m_History.add(new JLabel((i+0)+"."), gbc);
 | 
			
		||||
//          gbc.gridx       = 1;
 | 
			
		||||
//          gbc.gridy       = i+1;
 | 
			
		||||
//          this.m_History.add(new JLabel(this.m_MOCCO.m_State.m_PopulationHistory[i].size()+""), gbc);
 | 
			
		||||
//          gbc.gridx       = 2;
 | 
			
		||||
//          gbc.gridy       = i+1;
 | 
			
		||||
//          this.m_JCUse[i] = new JCheckBox();
 | 
			
		||||
//          this.m_JCUse[i].setSelected(this.m_MOCCO.m_State.m_Use[i]);
 | 
			
		||||
//          this.m_JCUse[i].addActionListener(useModeChanged);
 | 
			
		||||
//          this.m_History.add(this.m_JCUse[i], gbc);
 | 
			
		||||
//          gbc.gridx       = 3;
 | 
			
		||||
//          gbc.gridy       = i+1;
 | 
			
		||||
//          this.m_JCShow[i] = new JCheckBox();
 | 
			
		||||
//          this.m_JCShow[i].setSelected(this.m_MOCCO.m_State.m_Show[i]);
 | 
			
		||||
//          this.m_JCShow[i].addActionListener(showModeChanged);
 | 
			
		||||
//          this.m_History.add(this.m_JCShow[i], gbc);
 | 
			
		||||
//          gbc.gridx       = 4;
 | 
			
		||||
//          gbc.gridy       = i+1;
 | 
			
		||||
//          this.m_JColor[i] = this.getComboBox(i);
 | 
			
		||||
//          this.m_JColor[i].addActionListener(colorModeChanged);
 | 
			
		||||
//          this.m_History.add(this.m_JColor[i], gbc);
 | 
			
		||||
//      }
 | 
			
		||||
//  }
 | 
			
		||||
//
 | 
			
		||||
//  ActionListener useModeChanged = new ActionListener() {
 | 
			
		||||
//      public void actionPerformed(ActionEvent event) {
 | 
			
		||||
//          for (int i = 0; i < m_JCUse.length; i++) {
 | 
			
		||||
//              m_MOCCO.m_State.m_Use[i] = m_JCUse[i].isSelected();
 | 
			
		||||
//          }
 | 
			
		||||
//      }
 | 
			
		||||
//  };
 | 
			
		||||
//  ActionListener showModeChanged = new ActionListener() {
 | 
			
		||||
//      public void actionPerformed(ActionEvent event) {
 | 
			
		||||
//          for (int i = 0; i < m_JCShow.length; i++) {
 | 
			
		||||
//              m_MOCCO.m_State.m_Show[i] = m_JCShow[i].isSelected();
 | 
			
		||||
//          }
 | 
			
		||||
//          m_View.updateView();
 | 
			
		||||
//      }
 | 
			
		||||
//  };
 | 
			
		||||
//  ActionListener colorModeChanged = new ActionListener() {
 | 
			
		||||
//      public void actionPerformed(ActionEvent event) {
 | 
			
		||||
//          for (int i = 0; i < m_JColor.length; i++) {
 | 
			
		||||
//              m_MOCCO.m_State.m_Color[i] = getColor(m_JColor[i].getSelectedIndex());
 | 
			
		||||
//          }
 | 
			
		||||
//          m_View.updateView();
 | 
			
		||||
//      }
 | 
			
		||||
//  };
 | 
			
		||||
//
 | 
			
		||||
//  private JComboBox getComboBox(int index) {
 | 
			
		||||
//      String[] colors = {"RED", "BLUE", "GREEN", "CYAN", "MAGENTA", "ORANGE"};
 | 
			
		||||
//      JComboBox result;
 | 
			
		||||
//      result = new JComboBox(colors);
 | 
			
		||||
//      int color = 0;
 | 
			
		||||
//      if (this.m_MOCCO.m_State.m_Color[index] == Color.RED)     color = 0;
 | 
			
		||||
//      if (this.m_MOCCO.m_State.m_Color[index] == Color.BLUE)    color = 1;
 | 
			
		||||
//      if (this.m_MOCCO.m_State.m_Color[index] == Color.GREEN)   color = 2;
 | 
			
		||||
//      if (this.m_MOCCO.m_State.m_Color[index] == Color.CYAN)    color = 3;
 | 
			
		||||
//      if (this.m_MOCCO.m_State.m_Color[index] == Color.MAGENTA) color = 4;
 | 
			
		||||
//      if (this.m_MOCCO.m_State.m_Color[index] == Color.ORANGE)  color = 5;
 | 
			
		||||
//      result.setSelectedIndex(color);
 | 
			
		||||
//      return result;
 | 
			
		||||
//  }
 | 
			
		||||
//  public Color getColor(int i) {
 | 
			
		||||
//      switch (i)  {
 | 
			
		||||
//          case 0 : {
 | 
			
		||||
//              return Color.RED;
 | 
			
		||||
//          }
 | 
			
		||||
//          case 1 : {
 | 
			
		||||
//              return Color.BLUE;
 | 
			
		||||
//          }
 | 
			
		||||
//          case 2 : {
 | 
			
		||||
//              return Color.GREEN;
 | 
			
		||||
//          }
 | 
			
		||||
//          case 3 : {
 | 
			
		||||
//              return Color.CYAN;
 | 
			
		||||
//          }
 | 
			
		||||
//          case 4 : {
 | 
			
		||||
//              return Color.MAGENTA;
 | 
			
		||||
//          }
 | 
			
		||||
//          case 5 : {
 | 
			
		||||
//              return Color.ORANGE;
 | 
			
		||||
//          }
 | 
			
		||||
//      }
 | 
			
		||||
//      return Color.BLACK;
 | 
			
		||||
//  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -612,7 +612,7 @@ public class PostProcess {
 | 
			
		||||
			
 | 
			
		||||
			prob.evaluate(subPop);
 | 
			
		||||
			stepsPerf += subPop.size();
 | 
			
		||||
			subPop.add(candidates.getEAIndividual(i));
 | 
			
		||||
			subPop.add(candidates.getEAIndividual(i).clone());
 | 
			
		||||
			nmPops.add(subPop);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
@@ -636,9 +636,11 @@ public class PostProcess {
 | 
			
		||||
			case cmaES: stepsPerf += PostProcess.processWithCMA(subPop, prob, term, subPop.size()-1); 
 | 
			
		||||
			break;
 | 
			
		||||
			}
 | 
			
		||||
//			if (TRACE) System.out.println("*** after: " + subPop.getBestEAIndividual().getStringRepresentation());
 | 
			
		||||
			if (checkRange(subPop.getBestEAIndividual())) {
 | 
			
		||||
				// and replace corresponding individual (should usually be better)
 | 
			
		||||
				if (subPop.getBestEAIndividual().isDominant(candidates.getEAIndividual(i))) {
 | 
			
		||||
//				if (subPop.getBestEAIndividual().isDominant(candidates.getEAIndividual(i))) { // TODO Multiobjective???
 | 
			
		||||
				if (subPop.getBestEAIndividual().getFitness(0)<candidates.getEAIndividual(i).getFitness(0)) {
 | 
			
		||||
//					System.out.println("moved by "+ PhenotypeMetric.dist(candidates.getEAIndividual(i), subPop.getBestEAIndividual()));
 | 
			
		||||
					subPop.getBestEAIndividual().putData("PostProcessingMovedBy", new Double(PhenotypeMetric.dist(candidates.getEAIndividual(i), subPop.getBestEAIndividual())));
 | 
			
		||||
					candidates.set(i, subPop.getBestEAIndividual());
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,17 @@
 | 
			
		||||
package eva2.server.go.problems;
 | 
			
		||||
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
import java.awt.Color;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
import javax.swing.JFrame;
 | 
			
		||||
 | 
			
		||||
import wsi.ra.chart2d.DPoint;
 | 
			
		||||
import eva2.gui.Chart2DDPointIconCircle;
 | 
			
		||||
import eva2.gui.Chart2DDPointIconText;
 | 
			
		||||
import eva2.gui.GraphPointSet;
 | 
			
		||||
import eva2.gui.Plot;
 | 
			
		||||
import eva2.server.go.individuals.AbstractEAIndividual;
 | 
			
		||||
import eva2.server.go.individuals.ESIndividualDoubleData;
 | 
			
		||||
import eva2.server.go.operators.archiving.ArchivingAllDominating;
 | 
			
		||||
import eva2.server.go.operators.archiving.ArchivingNSGA;
 | 
			
		||||
import eva2.server.go.operators.moso.InterfaceMOSOConverter;
 | 
			
		||||
@@ -13,12 +20,6 @@ import eva2.server.go.operators.paretofrontmetrics.InterfaceParetoFrontMetric;
 | 
			
		||||
import eva2.server.go.operators.paretofrontmetrics.MetricS;
 | 
			
		||||
import eva2.server.go.populations.Population;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
 | 
			
		||||
import wsi.ra.chart2d.DPointIcon;
 | 
			
		||||
import wsi.ra.chart2d.DPoint;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by IntelliJ IDEA.
 | 
			
		||||
 * User: streiche
 | 
			
		||||
@@ -33,15 +34,46 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
    transient protected Population              m_ParetoFront       = new Population();
 | 
			
		||||
    public    ArrayList                         m_AreaConst4Parallelization = new ArrayList();
 | 
			
		||||
    protected int                               m_OutputDimension   = 2;
 | 
			
		||||
    double			m_borderLow = 0;
 | 
			
		||||
    double			m_borderHigh = 5;
 | 
			
		||||
    
 | 
			
		||||
    transient protected   double[][]         	m_Border;
 | 
			
		||||
    transient protected Plot  					m_Plot;
 | 
			
		||||
    transient protected JFrame             		m_Result;
 | 
			
		||||
    private transient boolean                	m_Show              = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * TODO
 | 
			
		||||
    public AbstractMultiObjectiveOptimizationProblem(double borderHigh) {
 | 
			
		||||
    	super();
 | 
			
		||||
    	m_borderHigh=borderHigh;
 | 
			
		||||
        this.m_Template         = new ESIndividualDoubleData();
 | 
			
		||||
        initBorder();
 | 
			
		||||
        if (this.m_Show) this.initProblemFrame();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public AbstractMultiObjectiveOptimizationProblem() {
 | 
			
		||||
    	this(5.);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method allows you to toggle pareto-front visualisation on and off.
 | 
			
		||||
     * @param b     True if the pareto-front is to be shown.
 | 
			
		||||
     */
 | 
			
		||||
    public    double[][]                        m_Border;
 | 
			
		||||
    transient protected eva2.gui.Plot        m_Plot;
 | 
			
		||||
    transient protected JFrame                  m_Result;
 | 
			
		||||
    transient boolean                           m_Show              = false;
 | 
			
		||||
 | 
			
		||||
    public void setShowParetoFront(boolean b) {
 | 
			
		||||
        this.m_Show = b;
 | 
			
		||||
        if (this.m_Show) this.initProblemFrame();
 | 
			
		||||
        else if (this.m_Plot != null) {
 | 
			
		||||
            this.m_Plot.dispose();
 | 
			
		||||
            this.m_Plot = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean isShowParetoFront() {
 | 
			
		||||
        return this.m_Show;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public String showParetoFrontTipText() {
 | 
			
		||||
        return "Toggles the pareto-front visualisation.";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /** This method returns a deep clone of the problem.
 | 
			
		||||
     * @return  the clone
 | 
			
		||||
     */
 | 
			
		||||
@@ -53,30 +85,38 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
     * problem frame (i'll provide a default implementation here.
 | 
			
		||||
     */
 | 
			
		||||
    public void initProblem() {
 | 
			
		||||
        this.m_Border = new double[2][2];
 | 
			
		||||
        for (int i = 0; i < this.m_Border.length; i++) {
 | 
			
		||||
            this.m_Border[i][0] = 0;
 | 
			
		||||
            this.m_Border[i][1] = 5;
 | 
			
		||||
        }
 | 
			
		||||
        initBorder();
 | 
			
		||||
        this.m_ParetoFront = new Population();
 | 
			
		||||
        if (this.m_Show) this.initProblemFrame();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    protected void initBorder() {
 | 
			
		||||
    	initBorder(m_borderLow, m_borderHigh);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    protected void initBorder(double lower, double upper) {
 | 
			
		||||
        if (this.m_Border == null) this.m_Border = new double[2][2];
 | 
			
		||||
        for (int i = 0; i < this.m_Border.length; i++) {
 | 
			
		||||
            this.m_Border[i][0] = lower;
 | 
			
		||||
            this.m_Border[i][1] = upper;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method checks whether the problem has truely evaluated
 | 
			
		||||
     * to a multiobjective problem
 | 
			
		||||
     * @return true if all individuals are multiobjective
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isPopulationMultiObjective(Population pop) {
 | 
			
		||||
    public static boolean isPopulationMultiObjective(Population pop) {
 | 
			
		||||
        if (pop == null) return false;
 | 
			
		||||
        if (pop.size() == 0) return false;
 | 
			
		||||
        int best = pop.getBestFitness().length, tmp;
 | 
			
		||||
        int bestFitLen = pop.getBestFitness().length, tmpFitLen;
 | 
			
		||||
        for (int i = 0; i < pop.size(); i++) {
 | 
			
		||||
            tmp = ((AbstractEAIndividual)pop.get(i)).getFitness().length;
 | 
			
		||||
            if (tmp <= 1) {
 | 
			
		||||
            tmpFitLen = ((AbstractEAIndividual)pop.get(i)).getFitness().length;
 | 
			
		||||
            if (tmpFitLen <= 1) {
 | 
			
		||||
                //System.out.println("There is a single objective individual in the population!");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            if (tmp != best) {
 | 
			
		||||
            if (tmpFitLen != bestFitLen) {
 | 
			
		||||
                //System.out.println("Not all individual have equal length fitness!");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
@@ -129,7 +169,11 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
 | 
			
		||||
        evaluatePopulationEnd(population); // refactored by MK
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    public void evaluatePopulationStart(Population population) {
 | 
			
		||||
    	if (this.m_Show && (this.m_Plot==null)) this.initProblemFrame();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void evaluatePopulationEnd(Population population) {
 | 
			
		||||
        // So what is the problem:
 | 
			
		||||
        // on the one hand i want to log the pareto-front in the
 | 
			
		||||
@@ -140,35 +184,48 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
        // could be pretty many
 | 
			
		||||
 | 
			
		||||
        // currently the problem should be multi-criteria
 | 
			
		||||
        // log the pareto-front
 | 
			
		||||
        if (this.isPopulationMultiObjective(population)) {
 | 
			
		||||
            if (this.m_ParetoFront == null) this.m_ParetoFront = new Population();
 | 
			
		||||
            if (this.m_ParetoFront.getArchive() == null) {
 | 
			
		||||
                Population archive = new Population();
 | 
			
		||||
                archive.setPopulationSize(100);
 | 
			
		||||
                this.m_ParetoFront.SetArchive(archive);
 | 
			
		||||
            }
 | 
			
		||||
            this.m_ParetoFront.addPopulation((Population) population.getClone());
 | 
			
		||||
            ArchivingNSGA archiving = new ArchivingNSGA();
 | 
			
		||||
            archiving.addElementsToArchive(this.m_ParetoFront);
 | 
			
		||||
            this.m_ParetoFront = this.m_ParetoFront.getArchive();
 | 
			
		||||
        }
 | 
			
		||||
    	logPopToParetoFront(m_ParetoFront, population);
 | 
			
		||||
 | 
			
		||||
        // Sometimes you want to transform a multiobjective optimization problem
 | 
			
		||||
        // into a single objective one, this way single objective optimization
 | 
			
		||||
        // algorithms can be applied more easily
 | 
			
		||||
        this.m_MOSOConverter.convertMultiObjective2SingleObjective(population);
 | 
			
		||||
 | 
			
		||||
        if (this.m_Show) this.drawProblem(population);
 | 
			
		||||
        if (this.m_Show) {
 | 
			
		||||
        	if (m_Plot.isValid()) AbstractMultiObjectiveOptimizationProblem.drawProblem(population, m_Plot, this);	
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Unite the given population with the given pareto front and replace pFront with the new pareto front.
 | 
			
		||||
     * This variant uses ArchivingNSGA 
 | 
			
		||||
     * @param pFront
 | 
			
		||||
     * @param pop
 | 
			
		||||
     */
 | 
			
		||||
	public static void logPopToParetoFront(Population pFront, Population pop) {
 | 
			
		||||
		// log the pareto-front
 | 
			
		||||
        if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(pop)) {
 | 
			
		||||
            if (pFront == null) System.err.println("Error, give at least an empty population as initial pareto front");
 | 
			
		||||
            if (pFront.getArchive() == null) {
 | 
			
		||||
            	pFront.SetArchive(new Population(100));
 | 
			
		||||
            }
 | 
			
		||||
            Population tmpPop=new Population(pop.size());
 | 
			
		||||
            tmpPop.addPopulation(pop);
 | 
			
		||||
            tmpPop.addPopulation(pFront);
 | 
			
		||||
            ArchivingNSGA archiving = new ArchivingNSGA();
 | 
			
		||||
            archiving.addElementsToArchive(tmpPop);
 | 
			
		||||
            pFront.clear();
 | 
			
		||||
            pFront.addPopulation(tmpPop.getArchive());
 | 
			
		||||
        }
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
   /** This method will init the problem specific visualisation of the problem
 | 
			
		||||
     */
 | 
			
		||||
    public void initProblemFrame() {
 | 
			
		||||
        double[] tmpD = new double[2];
 | 
			
		||||
        tmpD[0] = 0;
 | 
			
		||||
        tmpD[1] = 0;
 | 
			
		||||
        if (this.m_Plot == null) m_Plot = new eva2.gui.Plot("Multiobjective Optimization", "Y1", "Y2", tmpD, tmpD);
 | 
			
		||||
        if (this.m_Plot == null) m_Plot = new Plot("Multiobjective Optimization", "Y1", "Y2", tmpD, tmpD);
 | 
			
		||||
 | 
			
		||||
        // plot init stuff
 | 
			
		||||
        this.initAdditionalData(this.m_Plot, 10);
 | 
			
		||||
@@ -178,17 +235,56 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
     * @param plot      The plot where you can draw your stuff.
 | 
			
		||||
     * @param index     The first index where you can draw your stuff
 | 
			
		||||
     */
 | 
			
		||||
    public void initAdditionalData(eva2.gui.Plot plot, int index) {
 | 
			
		||||
    public void initAdditionalData(Plot plot, int index) {
 | 
			
		||||
        // for example plot the current population
 | 
			
		||||
        plot.clearGraph(index);
 | 
			
		||||
        plot.setUnconnectedPoint(0, 0, index);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method will draw the current state of the optimization process
 | 
			
		||||
     * @param pFront     The current population
 | 
			
		||||
     */
 | 
			
		||||
    public static void drawProblem(Population pFront, Population archive, Plot plot) {
 | 
			
		||||
    	ArchivingAllDominating  tmpArch = new ArchivingAllDominating();
 | 
			
		||||
//  	Population              tmpPop = null;
 | 
			
		||||
 | 
			
		||||
    	// i want to plot the pareto front for MOEA and other strategies
 | 
			
		||||
    	// but i have to differentiate between the case where
 | 
			
		||||
    	// there is a true MOEA at work and where the
 | 
			
		||||
    	// MOOpt was converted into a SOOpt
 | 
			
		||||
    	if (pFront != null && (plot != null)) {
 | 
			
		||||
    		// i got either a multiobjective population or a multiobjective local population
 | 
			
		||||
    		plot.clearAll();
 | 
			
		||||
    		tmpArch.plotParetoFront(pFront, plot);
 | 
			
		||||
    		if (archive != null) {
 | 
			
		||||
    			GraphPointSet   mySet = new GraphPointSet(10, plot.getFunctionArea());
 | 
			
		||||
    			DPoint          myPoint;
 | 
			
		||||
    			Chart2DDPointIconCircle      icon;
 | 
			
		||||
    			double[]        tmpD;
 | 
			
		||||
    			mySet.setConnectedMode(false);
 | 
			
		||||
    			for (int i = 0; i < archive.size(); i++) {
 | 
			
		||||
    				icon    = new Chart2DDPointIconCircle();
 | 
			
		||||
    				tmpD    = ((AbstractEAIndividual)archive.get(i)).getFitness();
 | 
			
		||||
    				myPoint = new DPoint(tmpD[0], tmpD[1]);
 | 
			
		||||
    				if (((AbstractEAIndividual)archive.get(i)).getConstraintViolation() > 0) {
 | 
			
		||||
    					icon.setBorderColor(Color.RED);
 | 
			
		||||
    					icon.setFillColor(Color.RED);
 | 
			
		||||
    				} else {
 | 
			
		||||
    					icon.setBorderColor(Color.BLACK);
 | 
			
		||||
    					icon.setFillColor(Color.BLACK);
 | 
			
		||||
    				}
 | 
			
		||||
    				myPoint.setIcon(icon);
 | 
			
		||||
    				mySet.addDPoint(myPoint);
 | 
			
		||||
    			}
 | 
			
		||||
    		}
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /** 
 | 
			
		||||
     * This method will draw the current state of the optimization process
 | 
			
		||||
     * @param p     The current population
 | 
			
		||||
     */
 | 
			
		||||
    public void drawProblem(Population p) {
 | 
			
		||||
 | 
			
		||||
    public static void drawProblem(Population p, Plot plot, AbstractMultiObjectiveOptimizationProblem moProblem) {
 | 
			
		||||
        ArchivingAllDominating  tmpArch = new ArchivingAllDominating();
 | 
			
		||||
        Population              tmpPop = null;
 | 
			
		||||
 | 
			
		||||
@@ -198,9 +294,9 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
            // but i have to differentiate between the case where
 | 
			
		||||
            // there is a true MOEA at work and where the
 | 
			
		||||
            // MOOpt was converted into a SOOpt
 | 
			
		||||
            if (this.isPopulationMultiObjective(p)) {
 | 
			
		||||
            if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(p)) {
 | 
			
		||||
                // in this case i have to use my local archive
 | 
			
		||||
                tmpPop = this.m_ParetoFront;
 | 
			
		||||
                tmpPop = moProblem.m_ParetoFront;
 | 
			
		||||
            } else {
 | 
			
		||||
                // in this case i use the population of the optimizer
 | 
			
		||||
                // and eventually the pop.archive if there is one
 | 
			
		||||
@@ -210,54 +306,79 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
                tmpArch.addElementsToArchive(tmpPop);
 | 
			
		||||
                tmpPop = tmpPop.getArchive();
 | 
			
		||||
            }
 | 
			
		||||
            if (tmpPop != null) {
 | 
			
		||||
                // i got either a multiobjective population or a multiobjective local population
 | 
			
		||||
                this.m_Plot.clearAll();
 | 
			
		||||
                tmpArch.plotParetoFront(tmpPop, this.m_Plot);
 | 
			
		||||
                if ((true) && (p.getArchive() != null)) {
 | 
			
		||||
                    GraphPointSet   mySet = new GraphPointSet(10, this.m_Plot.getFunctionArea());
 | 
			
		||||
                    DPoint          myPoint;
 | 
			
		||||
                    Chart2DDPointIconCircle      icon;
 | 
			
		||||
                    double[]        tmpD;
 | 
			
		||||
                    mySet.setConnectedMode(false);
 | 
			
		||||
                    tmpPop = p.getArchive();
 | 
			
		||||
                    for (int i = 0; i < tmpPop.size(); i++) {
 | 
			
		||||
                        icon    = new Chart2DDPointIconCircle();
 | 
			
		||||
                        tmpD    = ((AbstractEAIndividual)tmpPop.get(i)).getFitness();
 | 
			
		||||
                        myPoint = new DPoint(tmpD[0], tmpD[1]);
 | 
			
		||||
                        if (((AbstractEAIndividual)tmpPop.get(i)).getConstraintViolation() > 0) {
 | 
			
		||||
                            icon.setBorderColor(Color.RED);
 | 
			
		||||
                            icon.setFillColor(Color.RED);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            icon.setBorderColor(Color.BLACK);
 | 
			
		||||
                            icon.setFillColor(Color.BLACK);
 | 
			
		||||
                        }
 | 
			
		||||
                        myPoint.setIcon(icon);
 | 
			
		||||
                        mySet.addDPoint(myPoint);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
//                // in this case i got a single objective optimization problem
 | 
			
		||||
//                if (this.m_Plot != null) this.m_Plot.dispose();
 | 
			
		||||
//                if (this.m_Result == null) {
 | 
			
		||||
//                    this.m_Result = new JFrame();
 | 
			
		||||
//                    this.m_Result.addWindowListener(new WindowAdapter() {
 | 
			
		||||
//                        public void windowClosing(WindowEvent ev) {
 | 
			
		||||
//                            System.gc();
 | 
			
		||||
//                        }
 | 
			
		||||
//                    });
 | 
			
		||||
//                }
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            if (tmpPop != null) drawProblem(tmpPop, p.getArchive(), plot);
 | 
			
		||||
            // else : in this case i got a single objective optimization problem
 | 
			
		||||
            // draw additional data
 | 
			
		||||
            this.drawAdditionalData(this.m_Plot, p, 10);
 | 
			
		||||
            moProblem.drawAdditionalData(plot, p, 10);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
//    /** This method will draw the current state of the optimization process
 | 
			
		||||
//     * @param p     The current population
 | 
			
		||||
//     */
 | 
			
		||||
//    public static void drawProblem(Population p, Plot plot, AbstractMultiObjectiveOptimizationProblem moProblem) {
 | 
			
		||||
//        ArchivingAllDominating  tmpArch = new ArchivingAllDominating();
 | 
			
		||||
//        Population              tmpPop = null;
 | 
			
		||||
//
 | 
			
		||||
//        if (p.getGeneration() > 2) {
 | 
			
		||||
////            m_Plot = new eva2.gui.Plot("Multiobjective Optimization", "Y1", "Y2");
 | 
			
		||||
//            // i want to plot the pareto front for MOEA and other strategies
 | 
			
		||||
//            // but i have to differentiate between the case where
 | 
			
		||||
//            // there is a true MOEA at work and where the
 | 
			
		||||
//            // MOOpt was converted into a SOOpt
 | 
			
		||||
//            if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(p)) {
 | 
			
		||||
//                // in this case i have to use my local archive
 | 
			
		||||
//                tmpPop = moProblem.m_ParetoFront;
 | 
			
		||||
//            } else {
 | 
			
		||||
//                // in this case i use the population of the optimizer
 | 
			
		||||
//                // and eventually the pop.archive if there is one
 | 
			
		||||
//                tmpPop = new Population();
 | 
			
		||||
//                tmpPop.addPopulation(p);
 | 
			
		||||
//                if (p.getArchive() != null) tmpPop.addPopulation(p.getArchive());
 | 
			
		||||
//                tmpArch.addElementsToArchive(tmpPop);
 | 
			
		||||
//                tmpPop = tmpPop.getArchive();
 | 
			
		||||
//            }
 | 
			
		||||
//            if (tmpPop != null) {
 | 
			
		||||
//                // i got either a multiobjective population or a multiobjective local population
 | 
			
		||||
//            	plot.clearAll();
 | 
			
		||||
//                tmpArch.plotParetoFront(tmpPop, plot);
 | 
			
		||||
//                if ((true) && (p.getArchive() != null)) {
 | 
			
		||||
//                    GraphPointSet   mySet = new GraphPointSet(10, plot.getFunctionArea());
 | 
			
		||||
//                    DPoint          myPoint;
 | 
			
		||||
//                    Chart2DDPointIconCircle      icon;
 | 
			
		||||
//                    double[]        tmpD;
 | 
			
		||||
//                    mySet.setConnectedMode(false);
 | 
			
		||||
//                    tmpPop = p.getArchive();
 | 
			
		||||
//                    for (int i = 0; i < tmpPop.size(); i++) {
 | 
			
		||||
//                        icon    = new Chart2DDPointIconCircle();
 | 
			
		||||
//                        tmpD    = ((AbstractEAIndividual)tmpPop.get(i)).getFitness();
 | 
			
		||||
//                        myPoint = new DPoint(tmpD[0], tmpD[1]);
 | 
			
		||||
//                        if (((AbstractEAIndividual)tmpPop.get(i)).getConstraintViolation() > 0) {
 | 
			
		||||
//                            icon.setBorderColor(Color.RED);
 | 
			
		||||
//                            icon.setFillColor(Color.RED);
 | 
			
		||||
//                        } else {
 | 
			
		||||
//                            icon.setBorderColor(Color.BLACK);
 | 
			
		||||
//                            icon.setFillColor(Color.BLACK);
 | 
			
		||||
//                        }
 | 
			
		||||
//                        myPoint.setIcon(icon);
 | 
			
		||||
//                        mySet.addDPoint(myPoint);
 | 
			
		||||
//                    }
 | 
			
		||||
//                }
 | 
			
		||||
//            } else {
 | 
			
		||||
////                // in this case i got a single objective optimization problem
 | 
			
		||||
//            }
 | 
			
		||||
//            // draw additional data
 | 
			
		||||
//            moProblem.drawAdditionalData(plot, p, 10);
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    /** This method will plot a reference solutions or something like it
 | 
			
		||||
    /** 
 | 
			
		||||
     * This method will plot a reference solutions or something like it
 | 
			
		||||
     * @param plot      The plot where you can draw your stuff.
 | 
			
		||||
     * @param index     The first index where you can draw your stuff
 | 
			
		||||
     */
 | 
			
		||||
    public void drawAdditionalData(eva2.gui.Plot plot, Population pop, int index) {
 | 
			
		||||
    public void drawAdditionalData(Plot plot, Population pop, int index) {
 | 
			
		||||
        double[] tmpFitness;
 | 
			
		||||
        // for example plot the current population
 | 
			
		||||
        plot.clearGraph(index);
 | 
			
		||||
@@ -270,6 +391,86 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
 | 
			
		||||
        plot.setUnconnectedPoint(this.m_Border[0][0], this.m_Border[1][0], index);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Plot the given population to a MO-plot with red dots for constraint violations and blue otherwise.
 | 
			
		||||
     * The given border is used to set plot limits but may be null.
 | 
			
		||||
     * 
 | 
			
		||||
     * @param plot
 | 
			
		||||
     * @param pop
 | 
			
		||||
     * @param border
 | 
			
		||||
     * @param index
 | 
			
		||||
     */
 | 
			
		||||
	public static void drawWithConstraints(Plot plot, Population pop, double[][] border, int index) {
 | 
			
		||||
        // for example plot the current population
 | 
			
		||||
    	double[][]      trueFitness, moFitness;
 | 
			
		||||
    	double[]        constraint;
 | 
			
		||||
 | 
			
		||||
    	GraphPointSet mySet = new GraphPointSet(index, plot.getFunctionArea());
 | 
			
		||||
    	DPoint          myPoint;
 | 
			
		||||
    	double          tmp1;
 | 
			
		||||
    	
 | 
			
		||||
    	trueFitness = new double[pop.size()][];
 | 
			
		||||
    	constraint = new double[pop.size()];
 | 
			
		||||
    	if (((AbstractEAIndividual)pop.get(0)).hasData("MOFitness")) {
 | 
			
		||||
    		moFitness   = new double[pop.size()][];
 | 
			
		||||
    	} else moFitness = null;
 | 
			
		||||
    	for (int i = 0; i < pop.size(); i++) {
 | 
			
		||||
    		constraint[i]   = ((AbstractEAIndividual)pop.get(i)).getConstraintViolation();
 | 
			
		||||
    		trueFitness[i]  = ((AbstractEAIndividual)pop.get(i)).getFitness();
 | 
			
		||||
    		if (moFitness != null) moFitness[i]    = (double[])((AbstractEAIndividual)pop.get(i)).getData("MOFitness");
 | 
			
		||||
    	}
 | 
			
		||||
    	mySet.setConnectedMode(false);
 | 
			
		||||
    	for (int i = 0; i < trueFitness.length; i++) {
 | 
			
		||||
    		if (moFitness != null) {
 | 
			
		||||
    			// moso is active
 | 
			
		||||
    			if (checkValidAt(moFitness, i)) {
 | 
			
		||||
    				myPoint = new DPoint(moFitness[i][0], moFitness[i][1]);
 | 
			
		||||
    				tmp1 = Math.round(trueFitness[i][0] *100)/100.0;
 | 
			
		||||
    				addPoint(constraint, mySet, myPoint, i, ""+tmp1);
 | 
			
		||||
    			}
 | 
			
		||||
    		} else {
 | 
			
		||||
    			// no moso is active
 | 
			
		||||
    			if (checkValidAt(trueFitness, i)) {
 | 
			
		||||
    				myPoint = new DPoint(trueFitness[i][0], trueFitness[i][1]);
 | 
			
		||||
    				addPoint(constraint, mySet, myPoint, i, "");
 | 
			
		||||
    			}
 | 
			
		||||
    		}
 | 
			
		||||
    	}
 | 
			
		||||
    	if (border!= null) {
 | 
			
		||||
    		plot.setUnconnectedPoint(border[0][1], border[1][1], index+1);
 | 
			
		||||
    		plot.setUnconnectedPoint(border[0][0], border[1][0], index+1);
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Check whether the given fitness array contains valid double values at position i.
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param fitArray
 | 
			
		||||
	 * @param i
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	private static boolean checkValidAt(double[][] fitArray, int i) {
 | 
			
		||||
		return !(new Double(fitArray[i][0]).isNaN()) && !(new Double(fitArray[i][1]).isNaN()) &&
 | 
			
		||||
				!(new Double(fitArray[i][0]).isInfinite()) && !(new Double(fitArray[i][1]).isInfinite());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private static void addPoint(double[] constraint, GraphPointSet mySet,
 | 
			
		||||
			DPoint myPoint, int i, String text) {
 | 
			
		||||
		Chart2DDPointIconCircle icon;
 | 
			
		||||
		Chart2DDPointIconText tmp = new Chart2DDPointIconText(text);
 | 
			
		||||
		icon = new Chart2DDPointIconCircle();
 | 
			
		||||
		if (constraint[i] > 0) {
 | 
			
		||||
			icon.setBorderColor(Color.RED);
 | 
			
		||||
			icon.setFillColor(Color.RED);
 | 
			
		||||
		} else {
 | 
			
		||||
			icon.setBorderColor(Color.BLUE);
 | 
			
		||||
			icon.setFillColor(Color.BLUE);
 | 
			
		||||
		}
 | 
			
		||||
		tmp.setIcon(icon);
 | 
			
		||||
		myPoint.setIcon(tmp);
 | 
			
		||||
		mySet.addDPoint(myPoint);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
    /** This method returns a double value that will be displayed in a fitness
 | 
			
		||||
     * plot. A fitness that is to be minimized with a global min of zero
 | 
			
		||||
     * would be best, since log y can be used. But the value can depend on the problem.
 | 
			
		||||
 
 | 
			
		||||
@@ -203,6 +203,10 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
 | 
			
		||||
    	return m_Template;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public String individualTemplateTipText() {
 | 
			
		||||
    	return "Choose the individual representation to use.";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * This method extracts the individuals from a given population that are assumed to correspond to local or global optima.
 | 
			
		||||
     * Similar individuals are clustered together with a density based clustering method
 | 
			
		||||
 
 | 
			
		||||
@@ -144,7 +144,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the lower bound of the double range in the given dimension. Override
 | 
			
		||||
     * this to implement non-symmetric ranges. User setDefaultRange for symmetric ranges.
 | 
			
		||||
     * this to implement non-symmetric ranges. Use setDefaultRange for symmetric ranges.
 | 
			
		||||
     * 
 | 
			
		||||
     * @see makeRange()
 | 
			
		||||
     * @see getRangeUpperBound(int dim)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,24 +1,24 @@
 | 
			
		||||
package eva2.server.go.problems;
 | 
			
		||||
 | 
			
		||||
import wsi.ra.chart2d.DPoint;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.awt.Color;
 | 
			
		||||
import java.io.BufferedWriter;
 | 
			
		||||
import java.io.FileWriter;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
import wsi.ra.chart2d.DPoint;
 | 
			
		||||
import wsi.ra.math.RNG;
 | 
			
		||||
import eva2.gui.Chart2DDPointIconCircle;
 | 
			
		||||
import eva2.gui.Chart2DDPointIconText;
 | 
			
		||||
import eva2.gui.GraphPointSet;
 | 
			
		||||
import eva2.gui.Plot;
 | 
			
		||||
import eva2.gui.PropertyFilePath;
 | 
			
		||||
import eva2.server.go.individuals.AbstractEAIndividual;
 | 
			
		||||
import eva2.server.go.individuals.ESIndividualDoubleData;
 | 
			
		||||
import eva2.server.go.individuals.InterfaceDataTypeDouble;
 | 
			
		||||
import eva2.server.go.operators.constraint.InterfaceConstraint;
 | 
			
		||||
import eva2.server.go.operators.moso.InterfaceMOSOConverter;
 | 
			
		||||
import eva2.server.go.operators.paretofrontmetrics.InterfaceParetoFrontMetric;
 | 
			
		||||
import eva2.server.go.populations.Population;
 | 
			
		||||
import eva2.server.go.strategies.InterfaceOptimizer;
 | 
			
		||||
import wsi.ra.math.RNG;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by IntelliJ IDEA.
 | 
			
		||||
@@ -36,18 +36,16 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
 | 
			
		||||
    protected double                    m_YOffSet           = 0.0;
 | 
			
		||||
    protected boolean                   m_ApplyConstraints  = false;
 | 
			
		||||
 | 
			
		||||
    transient private GraphPointSet     mySet;
 | 
			
		||||
 | 
			
		||||
//    transient private GraphPointSet     mySet;
 | 
			
		||||
    
 | 
			
		||||
    public TF1Problem() {
 | 
			
		||||
        this.m_Template         = new ESIndividualDoubleData();
 | 
			
		||||
        this.m_Border = new double[2][2];
 | 
			
		||||
        for (int i = 0; i < this.m_Border.length; i++) {
 | 
			
		||||
            this.m_Border[i][0] = 0;
 | 
			
		||||
            this.m_Border[i][1] = 1;
 | 
			
		||||
        }
 | 
			
		||||
        if (this.m_Show) this.initProblemFrame();
 | 
			
		||||
    	super(1.);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    public TF1Problem(double borderHigh) {
 | 
			
		||||
    	super(borderHigh);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public TF1Problem(TF1Problem b) {
 | 
			
		||||
        //AbstractOptimizationProblem
 | 
			
		||||
        if (b.m_Template != null)
 | 
			
		||||
@@ -88,18 +86,6 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
 | 
			
		||||
        return (Object) new TF1Problem(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method inits the Problem to log multiruns
 | 
			
		||||
     */
 | 
			
		||||
    public void initProblem() {
 | 
			
		||||
        this.m_Border = new double[2][2];
 | 
			
		||||
        for (int i = 0; i < this.m_Border.length; i++) {
 | 
			
		||||
            this.m_Border[i][0] = 0;
 | 
			
		||||
            this.m_Border[i][1] = 1;
 | 
			
		||||
        }
 | 
			
		||||
        this.m_ParetoFront = new Population();
 | 
			
		||||
        if (this.m_Show) this.initProblemFrame();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method inits a given population
 | 
			
		||||
     * @param population    The populations that is to be inited
 | 
			
		||||
     */
 | 
			
		||||
@@ -107,11 +93,7 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
 | 
			
		||||
        AbstractEAIndividual tmpIndy;
 | 
			
		||||
        this.m_ParetoFront = new Population();
 | 
			
		||||
 | 
			
		||||
        double[][] newRange = new double[this.m_ProblemDimension][2];
 | 
			
		||||
        for (int i = 0; i < this.m_ProblemDimension; i++) {
 | 
			
		||||
            newRange[i][0] = 0;
 | 
			
		||||
            newRange[i][1] = 1;
 | 
			
		||||
        }
 | 
			
		||||
        double[][] newRange = makeRange();
 | 
			
		||||
 | 
			
		||||
        population.clear();
 | 
			
		||||
 | 
			
		||||
@@ -125,8 +107,20 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
 | 
			
		||||
        // population init must be last
 | 
			
		||||
        // it set's fitcalls and generation to zero
 | 
			
		||||
        population.init();
 | 
			
		||||
        if (this.m_Show) this.initProblemFrame();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
	protected double[][] makeRange() {
 | 
			
		||||
		return makeRange(0, 1);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	protected double[][] makeRange(double lower, double upper) {
 | 
			
		||||
		double[][] newRange = new double[this.m_ProblemDimension][2];
 | 
			
		||||
        for (int i = 0; i < this.m_ProblemDimension; i++) {
 | 
			
		||||
            newRange[i][0] = lower;
 | 
			
		||||
            newRange[i][1] = upper;
 | 
			
		||||
        }
 | 
			
		||||
		return newRange;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    /** This method evaluate a single individual and sets the fitness values
 | 
			
		||||
     * @param individual    The individual that is to be evalutated
 | 
			
		||||
@@ -194,89 +188,9 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method will plot a reference solutions or something like it
 | 
			
		||||
     * @param plot      The plot where you can draw your stuff.
 | 
			
		||||
     * @param index     The first index where you can draw your stuff
 | 
			
		||||
     */
 | 
			
		||||
    public void drawAdditionalData(eva2.gui.Plot plot, Population pop, int index) {
 | 
			
		||||
        double[] tmpFitness;
 | 
			
		||||
        // for example plot the current population
 | 
			
		||||
        //plot.clearGraph(index);
 | 
			
		||||
        if (true) {
 | 
			
		||||
            double[][]      trueFitness, moFitness;
 | 
			
		||||
            double[]        constraint;
 | 
			
		||||
            if (mySet == null) mySet = new GraphPointSet(index, this.m_Plot.getFunctionArea());
 | 
			
		||||
            mySet.removeAllPoints();
 | 
			
		||||
            mySet = new GraphPointSet(index, this.m_Plot.getFunctionArea());
 | 
			
		||||
            DPoint          myPoint;
 | 
			
		||||
            double          tmp1, tmp2;
 | 
			
		||||
            Chart2DDPointIconText tmp;
 | 
			
		||||
            Chart2DDPointIconCircle icon;
 | 
			
		||||
            trueFitness = new double[pop.size()][];
 | 
			
		||||
            constraint = new double[pop.size()];
 | 
			
		||||
            if (((AbstractEAIndividual)pop.get(0)).getData("MOFitness") != null) {
 | 
			
		||||
                moFitness   = new double[pop.size()][];
 | 
			
		||||
            }
 | 
			
		||||
            else moFitness = null;
 | 
			
		||||
            for (int i = 0; i < pop.size(); i++) {
 | 
			
		||||
                constraint[i]   = ((AbstractEAIndividual)pop.get(i)).getConstraintViolation();
 | 
			
		||||
                trueFitness[i]  = ((AbstractEAIndividual)pop.get(i)).getFitness();
 | 
			
		||||
                if (moFitness != null) moFitness[i]    = (double[])((AbstractEAIndividual)pop.get(i)).getData("MOFitness");
 | 
			
		||||
            }
 | 
			
		||||
            mySet.setConnectedMode(false);
 | 
			
		||||
            for (int i = 0; i < trueFitness.length; i++) {
 | 
			
		||||
                if (moFitness != null) {
 | 
			
		||||
                    // moso is active
 | 
			
		||||
                    if (!(new Double(moFitness[i][0]).isNaN()) && !(new Double(moFitness[i][1]).isNaN()) &&
 | 
			
		||||
                                !(new Double(moFitness[i][0]).isInfinite()) && !(new Double(moFitness[i][1]).isInfinite())) {
 | 
			
		||||
                        myPoint = new DPoint(moFitness[i][0], moFitness[i][1]);
 | 
			
		||||
                        tmp1 = Math.round(trueFitness[i][0] *100)/100.0;
 | 
			
		||||
                        tmp = new Chart2DDPointIconText(""+tmp1);
 | 
			
		||||
                        icon = new Chart2DDPointIconCircle();
 | 
			
		||||
                        if (constraint[i] > 0) {
 | 
			
		||||
                            icon.setBorderColor(Color.RED);
 | 
			
		||||
                            icon.setFillColor(Color.RED);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            icon.setBorderColor(Color.BLACK);
 | 
			
		||||
                            icon.setFillColor(Color.BLACK);
 | 
			
		||||
                        }
 | 
			
		||||
                        tmp.setIcon(icon);
 | 
			
		||||
                        myPoint.setIcon(tmp);
 | 
			
		||||
                        mySet.addDPoint(myPoint);
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    // no moso is active
 | 
			
		||||
                    if (!(new Double(trueFitness[i][0]).isNaN()) && !(new Double(trueFitness[i][1]).isNaN()) &&
 | 
			
		||||
                        !(new Double(trueFitness[i][0]).isInfinite()) && !(new Double(trueFitness[i][1]).isInfinite())) {
 | 
			
		||||
                        myPoint = new DPoint(trueFitness[i][0], trueFitness[i][1]);
 | 
			
		||||
                        tmp = new Chart2DDPointIconText("");
 | 
			
		||||
                        icon = new Chart2DDPointIconCircle();
 | 
			
		||||
                        if (constraint[i] > 0) {
 | 
			
		||||
                            icon.setBorderColor(Color.RED);
 | 
			
		||||
                            icon.setFillColor(Color.RED);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            icon.setBorderColor(Color.BLACK);
 | 
			
		||||
                            icon.setFillColor(Color.BLACK);
 | 
			
		||||
                        }
 | 
			
		||||
                        tmp.setIcon(icon);
 | 
			
		||||
                        myPoint.setIcon(tmp);
 | 
			
		||||
                        mySet.addDPoint(myPoint);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
//        for (int i = 0; i < pop.size(); i++) {
 | 
			
		||||
//            tmpFitness = ((AbstractEAIndividual)pop.get(i)).getFitness();
 | 
			
		||||
//            if (tmpFitness.length <= 1) tmpFitness = (double[])((AbstractEAIndividual)pop.get(i)).getData("MOFitness");
 | 
			
		||||
//            if (!(new Double(tmpFitness[0]).isNaN()) && !(new Double(tmpFitness[1]).isNaN()) &&
 | 
			
		||||
//                !(new Double(tmpFitness[0]).isInfinite()) && !(new Double(tmpFitness[1]).isInfinite()))
 | 
			
		||||
//                plot.setUnconnectedPoint(tmpFitness[0], tmpFitness[1], index);
 | 
			
		||||
//            else System.out.println("Index "+i+":("+tmpFitness[0]+"/"+tmpFitness[1]+")");
 | 
			
		||||
//        }
 | 
			
		||||
//        System.out.println(".");
 | 
			
		||||
        plot.setUnconnectedPoint(this.m_Border[0][1], this.m_Border[1][1], index+1);
 | 
			
		||||
        plot.setUnconnectedPoint(this.m_Border[0][0], this.m_Border[1][0], index+1);
 | 
			
		||||
    }
 | 
			
		||||
    public void drawAdditionalData(Plot plot, Population pop, int index) {
 | 
			
		||||
		AbstractMultiObjectiveOptimizationProblem.drawWithConstraints(plot, pop, m_Border, index);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    /** This method returns a string describing the optimization problem.
 | 
			
		||||
     * @param opt       The Optimizer that is used or had been used.
 | 
			
		||||
@@ -426,24 +340,6 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
 | 
			
		||||
        return (InterfaceDataTypeDouble)this.m_Template;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method allows you to toggle pareto-front visualisation on and off.
 | 
			
		||||
     * @param b     True if the pareto-front is to be shown.
 | 
			
		||||
     */
 | 
			
		||||
    public void setShowParetoFront(boolean b) {
 | 
			
		||||
        this.m_Show = b;
 | 
			
		||||
        if (this.m_Show) this.initProblemFrame();
 | 
			
		||||
        else if (this.m_Plot != null) {
 | 
			
		||||
            this.m_Plot.dispose();
 | 
			
		||||
            this.m_Plot = null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public boolean getShowParetoFront() {
 | 
			
		||||
        return this.m_Show;
 | 
			
		||||
    }
 | 
			
		||||
    public String showParetoFrontTipText() {
 | 
			
		||||
        return "Toggles the pareto-front visualisation.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method allows you to set a Multiobjective to
 | 
			
		||||
     * Singleobjective converter if you choose to.
 | 
			
		||||
     * @param b     The new MO2SO converter.
 | 
			
		||||
 
 | 
			
		||||
@@ -46,9 +46,10 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
 | 
			
		||||
	protected double[] currentBestFit;
 | 
			
		||||
	protected double[] meanFitness;
 | 
			
		||||
	protected double[] currentWorstFit;
 | 
			
		||||
	protected double[] meanBestOfRunFitness;
 | 
			
		||||
	protected double avgPopDist;
 | 
			
		||||
	protected double maxPopDist;
 | 
			
		||||
	protected IndividualInterface bestCurrentIndividual, bestIndividualAllover;
 | 
			
		||||
	protected IndividualInterface bestCurrentIndividual, bestRunIndividual, bestIndividualAllover;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	private ArrayList<InterfaceTextListener> textListeners;
 | 
			
		||||
@@ -118,11 +119,13 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
 | 
			
		||||
			convergenceCnt = 0;
 | 
			
		||||
			if (saveParams) m_StatsParams.saveInstance();
 | 
			
		||||
			initOutput(infoString);
 | 
			
		||||
			bestCurrentIndividual = null;
 | 
			
		||||
			bestIndividualAllover = null;
 | 
			
		||||
			meanBestOfRunFitness = null;
 | 
			
		||||
			if (refineMultiRuns) meanCollection = new ArrayList<double[][]>();
 | 
			
		||||
			else meanCollection = null;
 | 
			
		||||
		}
 | 
			
		||||
		bestCurrentIndividual = null;
 | 
			
		||||
		bestRunIndividual = null;
 | 
			
		||||
		runIterCnt = 0;
 | 
			
		||||
    	if (printRunIntroVerbosity()) printToTextListener("\n****** Multirun "+runNumber);
 | 
			
		||||
    	if (params != null) {
 | 
			
		||||
@@ -150,13 +153,21 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
 | 
			
		||||
			if (Mathematics.norm(bestCurrentIndividual.getFitness()) < this.m_StatsParams.getConvergenceRateThreshold()) {
 | 
			
		||||
				convergenceCnt++;
 | 
			
		||||
			}
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener(" Run best individual	: " + BeanInspector.toString(bestCurrentIndividual) + "\n");
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener("	run solution data	: " + AbstractEAIndividual.getDefaultDataString(bestCurrentIndividual) + "\n");
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener("	run solution fit	: " + BeanInspector.toString(bestCurrentIndividual.getFitness()) + "\n");
 | 
			
		||||
		}
 | 
			
		||||
		if (currentBestFit!= null) {
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener(" Last best individual	: " + BeanInspector.toString(bestCurrentIndividual) + "\n");
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener("	Last solution data	: " + AbstractEAIndividual.getDefaultDataString(bestCurrentIndividual) + "\n");
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener("	Last solution fit	: " + BeanInspector.toString(bestCurrentIndividual.getFitness()) + "\n");
 | 
			
		||||
		}		
 | 
			
		||||
		if (bestRunIndividual != null) {
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener("  Run best individual	: " + BeanInspector.toString(bestRunIndividual) + "\n");
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener("	Run solution data	: " + AbstractEAIndividual.getDefaultDataString(bestRunIndividual) + "\n");
 | 
			
		||||
			if (printRunStoppedVerbosity()) printToTextListener("	Run solution fit	: " + BeanInspector.toString(bestRunIndividual.getFitness()) + "\n");
 | 
			
		||||
			if (meanBestOfRunFitness==null) {
 | 
			
		||||
				meanBestOfRunFitness=bestRunIndividual.getFitness().clone();
 | 
			
		||||
			} else addMean(meanBestOfRunFitness, bestRunIndividual.getFitness());
 | 
			
		||||
		}
 | 
			
		||||
//		if (currentBestFit!= null) {
 | 
			
		||||
//			if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
 | 
			
		||||
//		}
 | 
			
		||||
		if (optRunsPerformed == m_StatsParams.getMultiRuns()) finalizeOutput();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -171,6 +182,12 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
 | 
			
		||||
			for (int i=0; i<meanCollection.size(); i++) divideMean(meanCollection.get(i), optRunsPerformed);
 | 
			
		||||
			if (printFinalVerbosity()) printToTextListener(refineToText(meanCollection, showAvgIntervals));
 | 
			
		||||
		}
 | 
			
		||||
		if ((meanBestOfRunFitness!=null) && (optRunsPerformed>1)) {
 | 
			
		||||
			Mathematics.svDiv((double)optRunsPerformed, meanBestOfRunFitness, meanBestOfRunFitness);
 | 
			
		||||
			if (printFinalVerbosity()) {
 | 
			
		||||
				printToTextListener(" Averaged best run fitness: " + BeanInspector.toString(meanBestOfRunFitness)+"\n");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (TRACE)
 | 
			
		||||
			System.out.println("End of run");
 | 
			
		||||
		if (resultOut != null) {
 | 
			
		||||
@@ -327,9 +344,11 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
 | 
			
		||||
		bestCurrentIndividual = pop.getBestIndividual().getClone();
 | 
			
		||||
		if ((bestIndividualAllover == null) || (secondIsBetter(bestIndividualAllover, bestCurrentIndividual))) {
 | 
			
		||||
			bestIndividualAllover = bestCurrentIndividual;
 | 
			
		||||
//			printToTextListener("new best found!, last was " + BeanInspector.toString(bestIndivdualAllover) + "\n");
 | 
			
		||||
//			printToTextListener("new best found!, last was " + BeanInspector.toString(bestIndividualAllover) + "\n");
 | 
			
		||||
		}
 | 
			
		||||
		if ((bestRunIndividual==null) || (secondIsBetter(bestRunIndividual, bestCurrentIndividual))) {
 | 
			
		||||
			bestRunIndividual=bestCurrentIndividual;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
//		IndividualInterface WorstInd = Pop.getWorstIndividual();
 | 
			
		||||
		if (bestCurrentIndividual == null) {
 | 
			
		||||
			System.err.println("createNextGenerationPerformed BestInd==null");
 | 
			
		||||
@@ -429,7 +448,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
 | 
			
		||||
		if (indy1 == null) return true;
 | 
			
		||||
		if (indy2 == null) return false;
 | 
			
		||||
		if (indy1 instanceof AbstractEAIndividual) return ((AbstractEAIndividual)indy2).isDominatingDebConstraints((AbstractEAIndividual)indy1);
 | 
			
		||||
		return (indy1.isDominant(indy2));
 | 
			
		||||
		return (indy2.isDominant(indy1));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public double[] getBestFitness() {
 | 
			
		||||
@@ -440,6 +459,10 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
 | 
			
		||||
		return bestIndividualAllover;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public IndividualInterface getRunBestSolution() {
 | 
			
		||||
		return bestRunIndividual;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public int getFitnessCalls() {
 | 
			
		||||
		return functionCalls;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,7 @@ public interface InterfaceStatistics {
 | 
			
		||||
	public void createNextGenerationPerformed(PopulationInterface Pop, List<InterfaceAdditionalPopulationInformer> informerList);
 | 
			
		||||
	public void createNextGenerationPerformed(double[] bestfit,double[] worstfit,int calls);
 | 
			
		||||
	public InterfaceStatisticsParameter getStatisticsParameter(); // called from moduleadapter
 | 
			
		||||
	public IndividualInterface getRunBestSolution(); // return the best fitness of the last run (may not be equal to the last population)
 | 
			
		||||
	public IndividualInterface getBestSolution(); // returns the best overall solution
 | 
			
		||||
	public double[] getBestFitness(); // returns the best overall fitness
 | 
			
		||||
}
 | 
			
		||||
@@ -17,7 +17,7 @@ import eva2.server.go.problems.InterfaceAdditionalPopulationInformer;
 | 
			
		||||
public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListener {
 | 
			
		||||
	boolean consoleOut = false;
 | 
			
		||||
	StatsParameter sParams = null;
 | 
			
		||||
	AbstractEAIndividual bestCurrentIndividual, bestIndividualAllover;
 | 
			
		||||
	AbstractEAIndividual bestCurrentIndividual, bestRunIndy, bestIndividualAllover;
 | 
			
		||||
	
 | 
			
		||||
	public StatisticsDummy() {
 | 
			
		||||
		bestIndividualAllover = null;
 | 
			
		||||
@@ -39,6 +39,9 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
 | 
			
		||||
	public void createNextGenerationPerformed(PopulationInterface pop,
 | 
			
		||||
			List<InterfaceAdditionalPopulationInformer> informerList) {
 | 
			
		||||
		bestCurrentIndividual = (AbstractEAIndividual)pop.getBestIndividual();
 | 
			
		||||
		if ((bestIndividualAllover == null) || (AbstractStatistics.secondIsBetter(bestIndividualAllover, bestCurrentIndividual))) {
 | 
			
		||||
			bestIndividualAllover = bestCurrentIndividual;
 | 
			
		||||
		}		
 | 
			
		||||
		if ((bestIndividualAllover == null) || (AbstractStatistics.secondIsBetter(bestIndividualAllover, bestCurrentIndividual))) {
 | 
			
		||||
			bestIndividualAllover = bestCurrentIndividual;
 | 
			
		||||
		}
 | 
			
		||||
@@ -56,7 +59,11 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
 | 
			
		||||
	public IndividualInterface getBestSolution() {
 | 
			
		||||
		return bestIndividualAllover;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	public IndividualInterface getRunBestSolution() {
 | 
			
		||||
		return bestRunIndy;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public InterfaceStatisticsParameter getStatisticsParameter() {
 | 
			
		||||
		return sParams;
 | 
			
		||||
	}
 | 
			
		||||
@@ -72,7 +79,8 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
 | 
			
		||||
 | 
			
		||||
	public void startOptPerformed(String InfoString, int runnumber,
 | 
			
		||||
			Object params) {
 | 
			
		||||
		bestIndividualAllover = null;
 | 
			
		||||
		if (runnumber==0) bestIndividualAllover = null;
 | 
			
		||||
		bestRunIndy = null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void stopOptPerformed(boolean normal, String stopMessage) {}
 | 
			
		||||
 
 | 
			
		||||
@@ -220,7 +220,7 @@ public class MultirunRefiner {
 | 
			
		||||
        int         numExp = 0, iteration = 0, lineCnt = 0;
 | 
			
		||||
        ArrayList<double[]>   result = new ArrayList<double[]>();
 | 
			
		||||
        String line;
 | 
			
		||||
        String runHeader = "Fit.-calls 	 Best 	 Mean 	 Worst 	 Solution";
 | 
			
		||||
        String runHeader = "Fun.calls 	 Best 	 Mean 	 Worst 	 Solution";
 | 
			
		||||
        String runFinalizer = " Best solution: ";
 | 
			
		||||
        boolean readRun = false;
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user