GP area view should now work better
This commit is contained in:
		@@ -4,7 +4,7 @@ package eva2;
 | 
			
		||||
 * Main product and version information strings.
 | 
			
		||||
 * 
 | 
			
		||||
 * --- Changelog
 | 
			
		||||
 * 2.035: Minor bugfix.
 | 
			
		||||
 * 2.035: Reactivated some of the model-based functionality within the GO framework. Minor bugfixes.
 | 
			
		||||
 * 2.034: Adding a generic parameter control method for optimizers, currently used by PSO to adapt inertness depending
 | 
			
		||||
 * 			on EvaluationTerminator or GenerationTerminator instances defining the number of function evaluations.
 | 
			
		||||
 * 			The new package is eva2.server.go.operators.paramcontrol.
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ import eva2.server.go.individuals.codings.gp.AbstractGPNode;
 | 
			
		||||
import eva2.server.go.individuals.codings.gp.GPArea;
 | 
			
		||||
import eva2.tools.EVAHELP;
 | 
			
		||||
 | 
			
		||||
import java.beans.PropertyChangeEvent;
 | 
			
		||||
import java.beans.PropertyEditorSupport;
 | 
			
		||||
import java.beans.PropertyEditor;
 | 
			
		||||
import java.beans.PropertyChangeListener;
 | 
			
		||||
@@ -24,7 +25,7 @@ import java.util.ArrayList;
 | 
			
		||||
 * Time: 11:41:01
 | 
			
		||||
 * To change this template use Options | File Templates.
 | 
			
		||||
 */
 | 
			
		||||
public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor {
 | 
			
		||||
public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor, PropertyChangeListener {
 | 
			
		||||
 | 
			
		||||
    /** Handles property change notification */
 | 
			
		||||
    private PropertyChangeSupport   m_Support = new PropertyChangeSupport(this);
 | 
			
		||||
@@ -71,7 +72,8 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
 | 
			
		||||
     */
 | 
			
		||||
    protected abstract boolean isElementAllowed(int i);
 | 
			
		||||
    
 | 
			
		||||
    /** The object may have changed update the editor.
 | 
			
		||||
    /** 
 | 
			
		||||
     * The object may have changed update the editor. This notifies change listeners automatically.
 | 
			
		||||
     */
 | 
			
		||||
    private void updateEditor() {
 | 
			
		||||
        if (this.m_NodePanel != null) {
 | 
			
		||||
@@ -82,7 +84,7 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
 | 
			
		||||
                 this.m_BlackCheck[i] = new JCheckBox(getElementName(i), isElementAllowed(i));
 | 
			
		||||
                 this.m_BlackCheck[i].addActionListener(new ActionListener() {
 | 
			
		||||
                    public void actionPerformed(ActionEvent ev) {
 | 
			
		||||
                        performOnAction();
 | 
			
		||||
                        if (performOnAction()) m_Support.firePropertyChange("AbstractListSelectionEditor", null, this);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                this.m_NodePanel.add(this.m_BlackCheck[i]);
 | 
			
		||||
@@ -91,12 +93,14 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** 
 | 
			
		||||
     * Perform actions when the selection state changes.
 | 
			
		||||
     * Perform actions when the selection state changes. Return true if there was an actual change.
 | 
			
		||||
     */
 | 
			
		||||
    protected abstract void performOnAction();
 | 
			
		||||
    protected abstract boolean performOnAction();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the base object, return true on success.
 | 
			
		||||
     * Set the base object, return true on success. Make sure that the editor instance is 
 | 
			
		||||
     * added as a listener to the object (if supported). 
 | 
			
		||||
     * 
 | 
			
		||||
     * @param o
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
@@ -180,4 +184,8 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
 | 
			
		||||
        if (this.m_CustomEditor == null) this.initCustomEditor();
 | 
			
		||||
        return m_CustomEditor;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void propertyChange(PropertyChangeEvent evt) {
 | 
			
		||||
    	m_Support.firePropertyChange("AbstractListSelectionEditor", null, this);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -35,7 +35,7 @@ public class GenericAreaEditor extends AbstractListSelectionEditor {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void performOnAction() {
 | 
			
		||||
	protected boolean performOnAction() {
 | 
			
		||||
		/** This method checks the current BlackList and compiles it
 | 
			
		||||
		 * to a new ReducedList.
 | 
			
		||||
		 */
 | 
			
		||||
@@ -43,19 +43,19 @@ public class GenericAreaEditor extends AbstractListSelectionEditor {
 | 
			
		||||
			this.m_AreaObject.setBlackListElement(i, this.m_BlackCheck[i].isSelected());
 | 
			
		||||
		}
 | 
			
		||||
		this.m_AreaObject.compileReducedList();
 | 
			
		||||
		return true; 
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected boolean setObject(Object o) {
 | 
			
		||||
        if (o instanceof GPArea) {
 | 
			
		||||
            this.m_AreaObject = (GPArea) o;
 | 
			
		||||
            m_AreaObject.addPropertyChangeListener(this);
 | 
			
		||||
            return true;
 | 
			
		||||
        } else return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    /** Retruns the current object.
 | 
			
		||||
     * @return the current object
 | 
			
		||||
     */
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
    public Object getValue() {
 | 
			
		||||
        return this.m_AreaObject;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -27,16 +27,22 @@ public class GenericObjectListSelectionEditor extends AbstractListSelectionEdito
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void performOnAction() {
 | 
			
		||||
	protected boolean performOnAction() {
 | 
			
		||||
		boolean changed=false;
 | 
			
		||||
		for (int i = 0; i < this.m_BlackCheck.length; i++) {
 | 
			
		||||
			objList.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
 | 
			
		||||
			if (objList.isSelected(i)!=this.m_BlackCheck[i].isSelected()) {
 | 
			
		||||
				objList.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
 | 
			
		||||
				changed=true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return changed;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected boolean setObject(Object o) {
 | 
			
		||||
        if (o instanceof PropertySelectableList) {
 | 
			
		||||
            this.objList = (PropertySelectableList) o;
 | 
			
		||||
            objList.addPropertyChangeListener(this);
 | 
			
		||||
            return true;
 | 
			
		||||
        } else return false;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,65 +1,66 @@
 | 
			
		||||
package eva2.gui;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
 | 
			
		||||
import eva2.server.go.individuals.codings.gp.AbstractGPNode;
 | 
			
		||||
import eva2.server.go.individuals.codings.gp.GPArea;
 | 
			
		||||
 | 
			
		||||
import java.beans.PropertyEditor;
 | 
			
		||||
import java.beans.PropertyChangeSupport;
 | 
			
		||||
import java.beans.PropertyChangeListener;
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import java.awt.event.ActionListener;
 | 
			
		||||
import java.awt.event.ActionEvent;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODO this should be redundant with the new GenericObjectListEditor.
 | 
			
		||||
 * 
 | 
			
		||||
 * Created by IntelliJ IDEA.
 | 
			
		||||
 * User: streiche
 | 
			
		||||
 * Date: 23.03.2004
 | 
			
		||||
 * Time: 15:03:29
 | 
			
		||||
 * To change this template use File | Settings | File Templates.
 | 
			
		||||
 */
 | 
			
		||||
public class GenericStringListSelectionEditor extends AbstractListSelectionEditor {
 | 
			
		||||
    private PropertyStringList              m_List;
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected int getElementCount() {
 | 
			
		||||
		return m_List.getStrings().length;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected String getElementName(int i) {
 | 
			
		||||
		return m_List.getStrings()[i];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected boolean isElementAllowed(int i) {
 | 
			
		||||
		return this.m_List.getSelection()[i];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void performOnAction() {
 | 
			
		||||
		for (int i = 0; i < this.m_BlackCheck.length; i++) {
 | 
			
		||||
			this.m_List.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected boolean setObject(Object o) {
 | 
			
		||||
		if (o instanceof PropertyStringList) {
 | 
			
		||||
            this.m_List = (PropertyStringList) o;
 | 
			
		||||
            return true;
 | 
			
		||||
        } else return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    /** Retruns the current object.
 | 
			
		||||
     * @return the current object
 | 
			
		||||
     */
 | 
			
		||||
    public Object getValue() {
 | 
			
		||||
        return this.m_List;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
//package eva2.gui;
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
//import javax.swing.*;
 | 
			
		||||
//
 | 
			
		||||
//import eva2.server.go.individuals.codings.gp.AbstractGPNode;
 | 
			
		||||
//import eva2.server.go.individuals.codings.gp.GPArea;
 | 
			
		||||
//
 | 
			
		||||
//import java.beans.PropertyEditor;
 | 
			
		||||
//import java.beans.PropertyChangeSupport;
 | 
			
		||||
//import java.beans.PropertyChangeListener;
 | 
			
		||||
//import java.awt.*;
 | 
			
		||||
//import java.awt.event.ActionListener;
 | 
			
		||||
//import java.awt.event.ActionEvent;
 | 
			
		||||
//import java.util.ArrayList;
 | 
			
		||||
//
 | 
			
		||||
///**
 | 
			
		||||
// * TODO this should be redundant with the new GenericObjectListEditor.
 | 
			
		||||
// * 
 | 
			
		||||
// * Created by IntelliJ IDEA.
 | 
			
		||||
// * User: streiche
 | 
			
		||||
// * Date: 23.03.2004
 | 
			
		||||
// * Time: 15:03:29
 | 
			
		||||
// * To change this template use File | Settings | File Templates.
 | 
			
		||||
// */
 | 
			
		||||
//public class GenericStringListSelectionEditor extends AbstractListSelectionEditor {
 | 
			
		||||
//    private PropertyStringList              m_List;
 | 
			
		||||
//
 | 
			
		||||
//	@Override
 | 
			
		||||
//	protected int getElementCount() {
 | 
			
		||||
//		return m_List.getStrings().length;
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	@Override
 | 
			
		||||
//	protected String getElementName(int i) {
 | 
			
		||||
//		return m_List.getStrings()[i];
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	@Override
 | 
			
		||||
//	protected boolean isElementAllowed(int i) {
 | 
			
		||||
//		return this.m_List.getSelection()[i];
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	@Override
 | 
			
		||||
//	protected boolean performOnAction() {
 | 
			
		||||
//		for (int i = 0; i < this.m_BlackCheck.length; i++) {
 | 
			
		||||
//			this.m_List.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
 | 
			
		||||
//		}
 | 
			
		||||
//		return true;
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//	@Override
 | 
			
		||||
//	protected boolean setObject(Object o) {
 | 
			
		||||
//		if (o instanceof PropertyStringList) {
 | 
			
		||||
//            this.m_List = (PropertyStringList) o;
 | 
			
		||||
//            return true;
 | 
			
		||||
//        } else return false;
 | 
			
		||||
//	}
 | 
			
		||||
//
 | 
			
		||||
//    /** Retruns the current object.
 | 
			
		||||
//     * @return the current object
 | 
			
		||||
//     */
 | 
			
		||||
//    public Object getValue() {
 | 
			
		||||
//        return this.m_List;
 | 
			
		||||
//    }
 | 
			
		||||
//}
 | 
			
		||||
@@ -169,7 +169,7 @@ public class PropertyEditorProvider {
 | 
			
		||||
        PropertyEditorManager.registerEditor(PropertyEpsilonThreshold.class     , GenericEpsilonThresholdEditor.class);
 | 
			
		||||
        PropertyEditorManager.registerEditor(PropertyEpsilonConstraint.class    , GenericEpsilonConstraintEditor.class);
 | 
			
		||||
        PropertyEditorManager.registerEditor(PropertyWeightedLPTchebycheff.class, GenericWeigthedLPTchebycheffEditor.class);
 | 
			
		||||
        PropertyEditorManager.registerEditor(PropertyStringList.class           , GenericStringListSelectionEditor.class);
 | 
			
		||||
//        PropertyEditorManager.registerEditor(PropertyStringList.class           , GenericStringListSelectionEditor.class);
 | 
			
		||||
        PropertyEditorManager.registerEditor(PropertyFilePath.class             , GenericFilePathEditor.class);
 | 
			
		||||
        PropertyEditorManager.registerEditor(PropertyRemoteServers.class        , GenericRemoteServersEditor.class);
 | 
			
		||||
        PropertyEditorManager.registerEditor(PropertyOptimizationObjectives.class  , GenericOptimizationObjectivesEditor.class);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,8 @@
 | 
			
		||||
package eva2.gui;
 | 
			
		||||
 | 
			
		||||
import java.beans.PropertyChangeListener;
 | 
			
		||||
import java.beans.PropertyChangeSupport;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by IntelliJ IDEA.
 | 
			
		||||
 * User: streiche
 | 
			
		||||
@@ -11,6 +14,7 @@ public class PropertySelectableList implements java.io.Serializable {
 | 
			
		||||
 | 
			
		||||
    private Object[]     m_Objects;
 | 
			
		||||
    private boolean[]    m_Selection;
 | 
			
		||||
	private PropertyChangeSupport m_Support;
 | 
			
		||||
 | 
			
		||||
    public PropertySelectableList() {
 | 
			
		||||
    }
 | 
			
		||||
@@ -33,6 +37,7 @@ public class PropertySelectableList implements java.io.Serializable {
 | 
			
		||||
    public void setObjects(Object[] o) {
 | 
			
		||||
        this.m_Objects = o;
 | 
			
		||||
        this.m_Selection = new boolean[o.length];
 | 
			
		||||
        m_Support.firePropertyChange("PropertySelectableList", null, this);
 | 
			
		||||
    }
 | 
			
		||||
    public Object[] getStrings() {
 | 
			
		||||
        return this.m_Objects;
 | 
			
		||||
@@ -40,6 +45,7 @@ public class PropertySelectableList implements java.io.Serializable {
 | 
			
		||||
 | 
			
		||||
    public void setSelection(boolean[] selection) {
 | 
			
		||||
        this.m_Selection = selection;
 | 
			
		||||
		m_Support.firePropertyChange("PropertySelectableList", null, this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean[] getSelection() {
 | 
			
		||||
@@ -47,7 +53,10 @@ public class PropertySelectableList implements java.io.Serializable {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSelectionForElement(int index, boolean b) {
 | 
			
		||||
        this.m_Selection[index] = b;
 | 
			
		||||
    	if (m_Selection[index]!=b) {
 | 
			
		||||
    		this.m_Selection[index] = b;
 | 
			
		||||
    		m_Support.firePropertyChange("PropertySelectableList", null, this);
 | 
			
		||||
    	}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int size() {
 | 
			
		||||
@@ -66,5 +75,14 @@ public class PropertySelectableList implements java.io.Serializable {
 | 
			
		||||
	public void clear() {
 | 
			
		||||
		m_Objects=null;
 | 
			
		||||
		m_Selection=null;
 | 
			
		||||
		m_Support.firePropertyChange("PropertySelectableList", null, this);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
    public void addPropertyChangeListener(PropertyChangeListener l) {
 | 
			
		||||
        m_Support.addPropertyChangeListener(l);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void removePropertyChangeListener(PropertyChangeListener l) {
 | 
			
		||||
        m_Support.removePropertyChangeListener(l);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,49 +1,49 @@
 | 
			
		||||
package eva2.gui;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by IntelliJ IDEA.
 | 
			
		||||
 * User: streiche
 | 
			
		||||
 * Date: 23.03.2004
 | 
			
		||||
 * Time: 15:04:05
 | 
			
		||||
 * To change this template use File | Settings | File Templates.
 | 
			
		||||
 */
 | 
			
		||||
public class PropertyStringList implements java.io.Serializable {
 | 
			
		||||
 | 
			
		||||
    public String[]     m_Strings;
 | 
			
		||||
    public boolean[]    m_Selection;
 | 
			
		||||
 | 
			
		||||
    public PropertyStringList() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    public PropertyStringList(PropertyStringList b) {
 | 
			
		||||
        if (b.m_Strings != null) {
 | 
			
		||||
            this.m_Strings = new String[b.m_Strings.length];
 | 
			
		||||
            System.arraycopy(b.m_Strings, 0, this.m_Strings, 0, this.m_Strings.length);
 | 
			
		||||
        }
 | 
			
		||||
        if (b.m_Selection != null) {
 | 
			
		||||
            this.m_Selection = new boolean[b.m_Selection.length];
 | 
			
		||||
            System.arraycopy(b.m_Selection, 0, this.m_Selection, 0, this.m_Selection.length);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public Object clone() {
 | 
			
		||||
        return (Object) new PropertyStringList(this);
 | 
			
		||||
    }
 | 
			
		||||
    public void setStrings(String[] strings) {
 | 
			
		||||
        this.m_Strings = strings;
 | 
			
		||||
        this.m_Selection = new boolean[this.m_Strings.length];
 | 
			
		||||
    }
 | 
			
		||||
    public String[] getStrings() {
 | 
			
		||||
        return this.m_Strings;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSelection(boolean[] selection) {
 | 
			
		||||
        this.m_Selection = selection;
 | 
			
		||||
    }
 | 
			
		||||
    public boolean[] getSelection() {
 | 
			
		||||
        return this.m_Selection;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSelectionForElement(int index, boolean b) {
 | 
			
		||||
        this.m_Selection[index] = b;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
//package eva2.gui;
 | 
			
		||||
//
 | 
			
		||||
///**
 | 
			
		||||
// * Created by IntelliJ IDEA.
 | 
			
		||||
// * User: streiche
 | 
			
		||||
// * Date: 23.03.2004
 | 
			
		||||
// * Time: 15:04:05
 | 
			
		||||
// * To change this template use File | Settings | File Templates.
 | 
			
		||||
// */
 | 
			
		||||
//public class PropertyStringList implements java.io.Serializable {
 | 
			
		||||
//
 | 
			
		||||
//    public String[]     m_Strings;
 | 
			
		||||
//    public boolean[]    m_Selection;
 | 
			
		||||
//
 | 
			
		||||
//    public PropertyStringList() {
 | 
			
		||||
//
 | 
			
		||||
//    }
 | 
			
		||||
//    public PropertyStringList(PropertyStringList b) {
 | 
			
		||||
//        if (b.m_Strings != null) {
 | 
			
		||||
//            this.m_Strings = new String[b.m_Strings.length];
 | 
			
		||||
//            System.arraycopy(b.m_Strings, 0, this.m_Strings, 0, this.m_Strings.length);
 | 
			
		||||
//        }
 | 
			
		||||
//        if (b.m_Selection != null) {
 | 
			
		||||
//            this.m_Selection = new boolean[b.m_Selection.length];
 | 
			
		||||
//            System.arraycopy(b.m_Selection, 0, this.m_Selection, 0, this.m_Selection.length);
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
//    public Object clone() {
 | 
			
		||||
//        return (Object) new PropertyStringList(this);
 | 
			
		||||
//    }
 | 
			
		||||
//    public void setStrings(String[] strings) {
 | 
			
		||||
//        this.m_Strings = strings;
 | 
			
		||||
//        this.m_Selection = new boolean[this.m_Strings.length];
 | 
			
		||||
//    }
 | 
			
		||||
//    public String[] getStrings() {
 | 
			
		||||
//        return this.m_Strings;
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    public void setSelection(boolean[] selection) {
 | 
			
		||||
//        this.m_Selection = selection;
 | 
			
		||||
//    }
 | 
			
		||||
//    public boolean[] getSelection() {
 | 
			
		||||
//        return this.m_Selection;
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    public void setSelectionForElement(int index, boolean b) {
 | 
			
		||||
//        this.m_Selection[index] = b;
 | 
			
		||||
//    }
 | 
			
		||||
//}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package eva2.server.go.individuals.codings.gp;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.beans.PropertyChangeListener;
 | 
			
		||||
import java.beans.PropertyChangeSupport;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
import wsi.ra.math.RNG;
 | 
			
		||||
@@ -14,7 +16,9 @@ import wsi.ra.math.RNG;
 | 
			
		||||
 * To change this template use Options | File Templates.
 | 
			
		||||
 */
 | 
			
		||||
public class GPArea implements java.io.Serializable {
 | 
			
		||||
 | 
			
		||||
    /** Handles property change notification */
 | 
			
		||||
    private transient PropertyChangeSupport   m_Support = new PropertyChangeSupport(this);
 | 
			
		||||
    
 | 
			
		||||
    private ArrayList       m_CompleteList  = new ArrayList();
 | 
			
		||||
    private ArrayList       m_ReducedList   = new ArrayList();
 | 
			
		||||
    private ArrayList       m_BlackList     = new ArrayList();
 | 
			
		||||
@@ -92,6 +96,7 @@ public class GPArea implements java.io.Serializable {
 | 
			
		||||
     */
 | 
			
		||||
    public void SetCompleteList(ArrayList a) {
 | 
			
		||||
        this.m_CompleteList = a;
 | 
			
		||||
	    m_Support.firePropertyChange("GPArea", null, this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method compiles the Complete List to the allowed list using the BlackList
 | 
			
		||||
@@ -103,6 +108,7 @@ public class GPArea implements java.io.Serializable {
 | 
			
		||||
                this.m_ReducedList.add(this.m_CompleteList.get(i));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
	    m_Support.firePropertyChange("GPArea", null, this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** This method allows you to fetch a random node of a given arity
 | 
			
		||||
@@ -138,4 +144,21 @@ public class GPArea implements java.io.Serializable {
 | 
			
		||||
	public boolean isEmpty() {
 | 
			
		||||
		return (m_CompleteList==null) || (m_CompleteList.size()==0);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void clear() {
 | 
			
		||||
	    m_CompleteList  = new ArrayList();
 | 
			
		||||
	    m_ReducedList   = new ArrayList();
 | 
			
		||||
	    m_BlackList     = new ArrayList();
 | 
			
		||||
	    m_Support.firePropertyChange("GPArea", null, this);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
    public void addPropertyChangeListener(PropertyChangeListener l) {
 | 
			
		||||
        m_Support.addPropertyChangeListener(l);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    public void removePropertyChangeListener(PropertyChangeListener l) {
 | 
			
		||||
        m_Support.removePropertyChangeListener(l);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -96,30 +96,36 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
 | 
			
		||||
    /** This method inits the Problem to log multiruns
 | 
			
		||||
     */
 | 
			
		||||
    public void initProblem() {
 | 
			
		||||
        this.compileArea();
 | 
			
		||||
        if (m_TargetFunction == null) m_TargetFunction = new RFKoza_GPI_10_2();
 | 
			
		||||
        this.m_OverallBest  = null;
 | 
			
		||||
        this.m_C            = new double[this.m_NumberOfConstants];
 | 
			
		||||
        for (int i = 0; i < this.m_C.length; i++) this.m_C[i] = RNG.randomDouble(-10, 10);
 | 
			
		||||
    }
 | 
			
		||||
        this.compileArea();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    /** This method compiles the area
 | 
			
		||||
    /**
 | 
			
		||||
     * This method compiles the area
 | 
			
		||||
     */
 | 
			
		||||
    private void compileArea() {
 | 
			
		||||
        this.m_GPArea = new GPArea();
 | 
			
		||||
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeAdd());
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeSub());
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeDiv());
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeMult());
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeSin(), false);
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeCos(), false);
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeExp(), false);
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodePow2(), false);
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodePow3(), false);
 | 
			
		||||
        this.m_GPArea.add2CompleteList(new GPNodeSqrt(), false);
 | 
			
		||||
        for (int i = 0; i < this.m_X.length; i++) this.m_GPArea.add2CompleteList(new GPNodeInput("X"+i));
 | 
			
		||||
        for (int i = 0; i < this.m_C.length; i++) this.m_GPArea.add2CompleteList(new GPNodeInput("C"+i));
 | 
			
		||||
    	// unfortunately this must be cloned or the GUI wont update.
 | 
			
		||||
//    	if (m_GPArea==null) 
 | 
			
		||||
    		m_GPArea = new GPArea();
 | 
			
		||||
//    	else m_GPArea = (GPArea)m_GPArea.clone();
 | 
			
		||||
    	
 | 
			
		||||
    	if (m_GPArea.isEmpty()) {
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeAdd());
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeSub());
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeDiv());
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeMult());
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeSin(), false);
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeCos(), false);
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeExp(), false);
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodePow2(), false);
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodePow3(), false);
 | 
			
		||||
	        this.m_GPArea.add2CompleteList(new GPNodeSqrt(), false);
 | 
			
		||||
	        for (int i = 0; i < this.m_X.length; i++) this.m_GPArea.add2CompleteList(new GPNodeInput("X"+i));
 | 
			
		||||
	        for (int i = 0; i < this.m_C.length; i++) this.m_GPArea.add2CompleteList(new GPNodeInput("C"+i));
 | 
			
		||||
    	}
 | 
			
		||||
        this.m_GPArea.compileReducedList();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -192,7 +198,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
 | 
			
		||||
 | 
			
		||||
    /** 
 | 
			
		||||
     * This method evaluates a single individual and sets the fitness values
 | 
			
		||||
     * @param individual    The individual that is to be evalutated
 | 
			
		||||
     * @param individual    The individual that is to be evaluated
 | 
			
		||||
     */
 | 
			
		||||
    public void evaluate(AbstractEAIndividual individual) {
 | 
			
		||||
        InterfaceProgram            program;
 | 
			
		||||
@@ -330,8 +336,8 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
 | 
			
		||||
     */
 | 
			
		||||
    public void setNumberOfConstants(int b) {
 | 
			
		||||
        this.m_NumberOfConstants = b;
 | 
			
		||||
        m_GPArea.clear();
 | 
			
		||||
        this.initProblem();
 | 
			
		||||
        this.compileArea();
 | 
			
		||||
    }
 | 
			
		||||
    public int getNumberOfConstants() {
 | 
			
		||||
        return this.m_NumberOfConstants;
 | 
			
		||||
@@ -365,6 +371,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
 | 
			
		||||
        ((InterfaceDataTypeProgram)this.m_Template).SetFunctionArea(tmpArea);
 | 
			
		||||
    }
 | 
			
		||||
    public GPArea getArea() {
 | 
			
		||||
    	if (m_GPArea==null) initProblem();
 | 
			
		||||
        return this.m_GPArea;
 | 
			
		||||
    }
 | 
			
		||||
    public String areaTipText() {
 | 
			
		||||
@@ -396,6 +403,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
 | 
			
		||||
        this.m_TargetFunction = b;
 | 
			
		||||
    }
 | 
			
		||||
    public InterfaceRegressionFunction getTargetFunction() {
 | 
			
		||||
    	if (m_TargetFunction==null) initProblem();
 | 
			
		||||
        return this.m_TargetFunction;
 | 
			
		||||
    }
 | 
			
		||||
    public String targetFunctionTipText() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user