Free cookie consent management tool by TermsFeed Policy Generator

Changeset 432 for trunk/sources


Ignore:
Timestamp:
08/03/08 23:53:44 (16 years ago)
Author:
gkronber
Message:
  • removed the button and methods for manual recalculation of min tree bounds introduced with r423 because it soon won't be needed anymore
  • GPOperatorGroup adds event-handlers to SubOperatorTypeConstraints on the operators added to the library to automatically update min tree size and height when any of them is changed.

(ticket #225)

Location:
trunk/sources/HeuristicLab.StructureIdentification
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/GPOperatorGroup.cs

    r431 r432  
    3232namespace HeuristicLab.StructureIdentification {
    3333  public class GPOperatorGroup : OperatorGroup {
    34     public GPOperatorGroup()
    35       : base() {
    36     }
    37 
    38     public override void AddOperator(IOperator op) {
    39       base.AddOperator(op);
    40 
    41       var localVariableInfos = op.VariableInfos.Where(f => f.Local);
    42 
    43       if(op.GetVariable(GPOperatorLibrary.MIN_TREE_HEIGHT) == null) {
    44         op.AddVariable(new Variable(GPOperatorLibrary.MIN_TREE_HEIGHT, new IntData(-1)));
    45       }
    46       if(op.GetVariable(GPOperatorLibrary.MIN_TREE_SIZE) == null) {
    47         op.AddVariable(new Variable(GPOperatorLibrary.MIN_TREE_SIZE, new IntData(-1)));
    48       }
    49       if(op.GetVariable(GPOperatorLibrary.TICKETS) == null) {
    50         op.AddVariable(new Variable(GPOperatorLibrary.TICKETS, new DoubleData(1.0)));
    51       }
    52       OnOperatorAdded(op);
    53     }
    54 
    55 
    5634    private Dictionary<IOperator, int> minTreeHeight = new Dictionary<IOperator, int>();
    5735    private Dictionary<IOperator, int> minTreeSize = new Dictionary<IOperator, int>();
    5836    private SubOperatorsConstraintAnalyser constraintAnalyser = new SubOperatorsConstraintAnalyser();
     37
     38    public GPOperatorGroup()
     39      : base() {
     40    }
     41
     42    public override void AddOperator(IOperator op) {
     43      base.AddOperator(op);
     44      var localVariableInfos = op.VariableInfos.Where(f => f.Local);
     45
     46      if(op.GetVariable(GPOperatorLibrary.MIN_TREE_HEIGHT) == null) {
     47        op.AddVariable(new Variable(GPOperatorLibrary.MIN_TREE_HEIGHT, new IntData(-1)));
     48      }
     49      if(op.GetVariable(GPOperatorLibrary.MIN_TREE_SIZE) == null) {
     50        op.AddVariable(new Variable(GPOperatorLibrary.MIN_TREE_SIZE, new IntData(-1)));
     51      }
     52      if(op.GetVariable(GPOperatorLibrary.TICKETS) == null) {
     53        op.AddVariable(new Variable(GPOperatorLibrary.TICKETS, new DoubleData(1.0)));
     54      }
     55      foreach(IConstraint c in op.Constraints) {
     56        if(c is SubOperatorTypeConstraint || c is AllSubOperatorsTypeConstraint) c.Changed += new EventHandler(UpdateTreeBounds);
     57      }
     58      OnOperatorAdded(op);
     59    }
     60
     61    void UpdateTreeBounds(object sender, EventArgs e) {
     62      RecalculateMinimalTreeBounds();
     63    }
    5964
    6065    private void RecalculateMinimalTreeBounds() {
     
    108113    }
    109114
    110 
    111115    private int RecalculateMinimalTreeHeight(IOperator op) {
    112116      // check for memoized value
     
    176180      op.RemoveVariable(GPOperatorLibrary.MIN_TREE_HEIGHT);
    177181      op.RemoveVariable(GPOperatorLibrary.TICKETS);
     182      foreach(IConstraint c in op.Constraints) {
     183        if(c is SubOperatorTypeConstraint || c is AllSubOperatorsTypeConstraint) c.Changed -= new EventHandler(UpdateTreeBounds);
     184      }
    178185      OnOperatorRemoved(op);
    179186    }
     
    196203      }
    197204    }
    198 
    199     internal void Prepare() {
    200       RecalculateMinimalTreeBounds();
    201     }
    202205  }
    203206
  • trunk/sources/HeuristicLab.StructureIdentification/GPOperatorLibrary.cs

    r431 r432  
    8383
    8484    #endregion
    85 
    86     internal void Prepare() {
    87       GPOperatorGroup.Prepare();
    88     }
    8985  }
    9086}
  • trunk/sources/HeuristicLab.StructureIdentification/GPOperatorLibraryEditor.Designer.cs

    r423 r432  
    5656      this.mutationListView = new System.Windows.Forms.ListView();
    5757      this.mutationVariableView = new HeuristicLab.Core.VariableView();
    58       this.preprocessButton = new System.Windows.Forms.Button();
    5958      this.tabControl.SuspendLayout();
    6059      this.operatorLibraryTabPage.SuspendLayout();
     
    9493      // operatorLibraryTabPage
    9594      //
    96       this.operatorLibraryTabPage.Controls.Add(this.preprocessButton);
    9795      this.operatorLibraryTabPage.Controls.Add(this.operatorLibraryEditor);
    9896      this.operatorLibraryTabPage.Location = new System.Drawing.Point(4, 22);
     
    202200      this.mutationVariableView.TabIndex = 0;
    203201      this.mutationVariableView.Variable = null;
    204       //
    205       // preprocessButton
    206       //
    207       this.preprocessButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    208       this.preprocessButton.Location = new System.Drawing.Point(440, 509);
    209       this.preprocessButton.Name = "preprocessButton";
    210       this.preprocessButton.Size = new System.Drawing.Size(75, 23);
    211       this.preprocessButton.TabIndex = 1;
    212       this.preprocessButton.Text = "Prepare";
    213       this.preprocessButton.UseVisualStyleBackColor = true;
    214       this.preprocessButton.Click += new System.EventHandler(this.preprocessButton_Click);
    215202      //
    216203      // GPOperatorLibraryEditor
     
    248235    private System.Windows.Forms.ListView initListView;
    249236    private System.Windows.Forms.ListView mutationListView;
    250     private System.Windows.Forms.Button preprocessButton;
    251237  }
    252238}
  • trunk/sources/HeuristicLab.StructureIdentification/GPOperatorLibraryEditor.cs

    r429 r432  
    151151      }
    152152    }
    153 
    154     private void preprocessButton_Click(object sender, EventArgs e) {
    155       ((GPOperatorLibrary)OperatorLibrary).Prepare();
    156     }
    157153  }
    158154}
Note: See TracChangeset for help on using the changeset viewer.