Free cookie consent management tool by TermsFeed Policy Generator

Changeset 278


Ignore:
Timestamp:
05/30/08 13:08:42 (16 years ago)
Author:
gkronber
Message:

merged changesets r166 r168 r195:196 r209 from the trunk into the stable branch

Location:
branches/3.0/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/sources/HeuristicLab.Core/VariablesScopeView.Designer.cs

    r2 r278  
    7070                  | System.Windows.Forms.AnchorStyles.Left)
    7171                  | System.Windows.Forms.AnchorStyles.Right)));
     72      this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
    7273      this.splitContainer1.Location = new System.Drawing.Point(0, 0);
    7374      this.splitContainer1.Name = "splitContainer1";
  • branches/3.0/sources/HeuristicLab.DataAnalysis/Dataset.cs

    r132 r278  
    3939    private double[] samples;
    4040    private int rows;
     41    Dictionary<int, Dictionary<int, double>>[] cachedMeans;
     42    Dictionary<int, Dictionary<int, double>>[] cachedRanges;
    4143
    4244    public int Rows {
     
    5052      set { columns = value; }
    5153    }
    52     private Dictionary<int, double[]>[] ranges;
    53     private Dictionary<int, double[]>[] means;
    5454
    5555    public double GetValue(int i, int j) {
     
    9494      // keep a means and ranges dictionary for each column (possible target variable) of the dataset.
    9595
    96       means = new Dictionary<int, double[]>[columns];
    97       ranges = new Dictionary<int, double[]>[columns];
     96      cachedMeans = new Dictionary<int, Dictionary<int, double>>[columns];
     97      cachedRanges = new Dictionary<int, Dictionary<int, double>>[columns];
    9898
    9999      for(int i = 0; i < columns; i++) {
    100         means[i] = new Dictionary<int, double[]>();
    101         ranges[i] = new Dictionary<int, double[]>();
     100        cachedMeans[i] = new Dictionary<int, Dictionary<int, double>>();
     101        cachedRanges[i] = new Dictionary<int, Dictionary<int, double>>();
    102102      }
    103103    }
     
    200200    }
    201201
    202     // return value of GetMean should be memoized because it is called repeatedly in Evaluators
    203202    public double GetMean(int column, int from, int to) {
    204       Dictionary<int, double[]> columnMeans = means[column];
    205       if(columnMeans.ContainsKey(from)) {
    206         double[] fromMeans = columnMeans[from];
    207         if(fromMeans[to-from] >= 0.0) {
    208           // already calculated
    209           return fromMeans[to-from];
    210         } else {
    211           // not yet calculated => calculate
    212           fromMeans[to-from] = CalculateMean(column, from, to);
    213           return fromMeans[to-from];
    214         }
     203      if(!cachedMeans[column].ContainsKey(from) || !cachedMeans[column][from].ContainsKey(to)) {
     204        double[] values = new double[to - from + 1];
     205        for(int sample = from; sample <= to; sample++) {
     206          values[sample - from] = GetValue(sample, column);
     207        }
     208        double mean = Statistics.Mean(values);
     209        if(!cachedMeans[column].ContainsKey(from)) cachedMeans[column][from] = new Dictionary<int, double>();
     210        cachedMeans[column][from][to] = mean;
     211        return mean;
    215212      } else {
    216         // never saw this from-index => create a new array, initialize and recalculate for to-index
    217         double[] fromMeans = new double[rows - from];
    218         // fill with negative values to indicate which means have already been calculated
    219         for(int i=0;i<fromMeans.Length;i++) {fromMeans[i] = -1.0;}
    220         // store new array in the dictionary
    221         columnMeans[from] = fromMeans;
    222         // calculate for specific to-index
    223         fromMeans[to-from] = CalculateMean(column, from, to);
    224         return fromMeans[to-from];
    225       }
    226     }
    227 
    228     private double CalculateMean(int column, int from, int to) {
    229       double[] values = new double[to - from +1];
    230       for(int sample = from; sample <= to; sample++) {
    231         values[sample - from] = GetValue(sample, column);
    232       }
    233 
    234       return Statistics.Mean(values);
     213        return cachedMeans[column][from][to];
     214      }
    235215    }
    236216
     
    239219    }
    240220
    241     // return value of GetRange should be memoized because it is called repeatedly in Evaluators
    242221    public double GetRange(int column, int from, int to) {
    243       Dictionary<int, double[]> columnRanges = ranges[column];
    244       if(columnRanges.ContainsKey(from)) {
    245         double[] fromRanges = columnRanges[from];
    246         if(fromRanges[to-from] >= 0.0) {
    247           // already calculated
    248           return fromRanges[to-from];
    249         } else {
    250           // not yet calculated => calculate
    251           fromRanges[to-from] = CalculateRange(column, from, to);
    252           return fromRanges[to-from];
    253         }
     222      if(!cachedRanges[column].ContainsKey(from) || !cachedRanges[column][from].ContainsKey(to)) {
     223        double[] values = new double[to - from + 1];
     224        for(int sample = from; sample <= to; sample++) {
     225          values[sample - from] = GetValue(sample, column);
     226        }
     227        double range = Statistics.Range(values);
     228        if(!cachedRanges[column].ContainsKey(from)) cachedRanges[column][from] = new Dictionary<int, double>();
     229        cachedRanges[column][from][to] = range;
     230        return range;
    254231      } else {
    255         // never saw this from-index => create a new array, initialize and recalculate for to-index
    256         double[] fromRanges = new double[rows - from];
    257         // fill with negative values to indicate which means have already been calculated
    258         for(int i = 0; i < fromRanges.Length; i++) { fromRanges[i] = -1.0; }
    259         // store in dictionary
    260         columnRanges[from] = fromRanges;
    261         // calculate for specific to-index
    262         fromRanges[to-from] = CalculateRange(column, from, to);
    263         return fromRanges[to-from];
    264       }
    265     }
    266 
    267     private double CalculateRange(int column, int from, int to) {
    268       double[] values = new double[to - from + 1];
    269       for(int sample = from; sample <= to; sample++) {
    270         values[sample - from] = GetValue(sample, column);
    271       }
    272 
    273       return Statistics.Range(values);
     232        return cachedRanges[column][from][to];
     233      }
    274234    }
    275235  }
  • branches/3.0/sources/HeuristicLab.DataAnalysis/DatasetView.cs

    r2 r278  
    3333      set {
    3434        Item = value;
    35         Item.Changed += new EventHandler(Item_Changed);
     35        Refresh();
    3636      }
    3737    }
    3838
    39     void Item_Changed(object sender, EventArgs e) {
    40       Refresh();
    41     }
    42 
    43     public DatasetView() : base() {
     39    public DatasetView()
     40      : base() {
    4441      InitializeComponent();
    4542      openFileDialog = new OpenFileDialog();
    4643    }
    4744
    48     public DatasetView(Dataset dataset) :this() {
     45    public DatasetView(Dataset dataset)
     46      : this() {
    4947      this.Dataset = dataset;
    5048    }
     
    5250    protected override void UpdateControls() {
    5351      base.UpdateControls();
    54       if(Dataset != null) {
     52      if (Dataset != null) {
    5553        int rows = Dataset.Rows;
    5654        int columns = Dataset.Columns;
    57 
    5855        nameTextBox.Text = Dataset.Name;
    5956        rowsTextBox.Text = rows + "";
     
    6158        dataGridView.ColumnCount = columns;
    6259        dataGridView.RowCount = rows;
    63         for(int i = 0; i < rows; i++) {
    64           for(int j = 0; j < columns; j++) {
     60        for (int i = 0; i < rows; i++) {
     61          for (int j = 0; j < columns; j++) {
    6562            dataGridView.Rows[i].Cells[j].Value = Dataset.GetValue(i, j);
    6663          }
     
    8582
    8683    private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
    87       if(ValidateData((string)e.FormattedValue)) {
     84      if (ValidateData((string)e.FormattedValue)) {
    8885        SetArrayElement(e.RowIndex, e.ColumnIndex, (string)e.FormattedValue);
    8986        e.Cancel = false;
     
    9794      double result;
    9895      double.TryParse(element, out result);
    99       if(result != Dataset.GetValue(row, column)) {
     96      if (result != Dataset.GetValue(row, column)) {
    10097        Dataset.SetValue(row, column, result);
    10198        Dataset.FireChanged();
  • branches/3.0/sources/HeuristicLab.StructureIdentification/StructIdProblemInjectorView.Designer.cs

    r277 r278  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.nameLabel = new System.Windows.Forms.Label();
    48       this.nameTextBox = new System.Windows.Forms.TextBox();
    4947      this.importInstanceButton = new System.Windows.Forms.Button();
    5048      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    5149      this.tabControl = new System.Windows.Forms.TabControl();
    5250      this.dataTabPage = new System.Windows.Forms.TabPage();
    53       this.variablesLabel = new System.Windows.Forms.Label();
    54       this.variablesTextBox = new System.Windows.Forms.TextBox();
    55       this.samplesLabel = new System.Windows.Forms.Label();
    56       this.samplesTextBox = new System.Windows.Forms.TextBox();
    5751      this.variableInfosTabPage = new System.Windows.Forms.TabPage();
    5852      this.operatorBaseVariableInfosView = new HeuristicLab.Core.OperatorBaseVariableInfosView();
    5953      this.descriptionTabPage = new System.Windows.Forms.TabPage();
    6054      this.operatorBaseDescriptionView = new HeuristicLab.Core.OperatorBaseDescriptionView();
     55      this.datasetView = new HeuristicLab.DataAnalysis.DatasetView();
    6156      this.tabControl.SuspendLayout();
    6257      this.dataTabPage.SuspendLayout();
     
    6560      this.SuspendLayout();
    6661      //
    67       // nameLabel
    68       //
    69       this.nameLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
    70       this.nameLabel.AutoSize = true;
    71       this.nameLabel.Location = new System.Drawing.Point(6, 9);
    72       this.nameLabel.Name = "nameLabel";
    73       this.nameLabel.Size = new System.Drawing.Size(38, 13);
    74       this.nameLabel.TabIndex = 0;
    75       this.nameLabel.Text = "Name:";
    76       //
    77       // nameTextBox
    78       //
    79       this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
    80       this.nameTextBox.Location = new System.Drawing.Point(62, 6);
    81       this.nameTextBox.Name = "nameTextBox";
    82       this.nameTextBox.ReadOnly = true;
    83       this.nameTextBox.Size = new System.Drawing.Size(166, 20);
    84       this.nameTextBox.TabIndex = 1;
    85       //
    8662      // importInstanceButton
    8763      //
    88       this.importInstanceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
    89       this.importInstanceButton.Location = new System.Drawing.Point(6, 105);
     64      this.importInstanceButton.Location = new System.Drawing.Point(6, 6);
    9065      this.importInstanceButton.Name = "importInstanceButton";
    91       this.importInstanceButton.Size = new System.Drawing.Size(256, 21);
     66      this.importInstanceButton.Size = new System.Drawing.Size(129, 21);
    9267      this.importInstanceButton.TabIndex = 6;
    9368      this.importInstanceButton.Text = "&Import...";
     
    11186      this.tabControl.Name = "tabControl";
    11287      this.tabControl.SelectedIndex = 0;
    113       this.tabControl.Size = new System.Drawing.Size(276, 184);
     88      this.tabControl.Size = new System.Drawing.Size(507, 451);
    11489      this.tabControl.TabIndex = 0;
    11590      //
    11691      // dataTabPage
    11792      //
    118       this.dataTabPage.Controls.Add(this.variablesLabel);
    119       this.dataTabPage.Controls.Add(this.variablesTextBox);
    120       this.dataTabPage.Controls.Add(this.samplesLabel);
    121       this.dataTabPage.Controls.Add(this.samplesTextBox);
    122       this.dataTabPage.Controls.Add(this.nameLabel);
     93      this.dataTabPage.Controls.Add(this.datasetView);
    12394      this.dataTabPage.Controls.Add(this.importInstanceButton);
    124       this.dataTabPage.Controls.Add(this.nameTextBox);
    12595      this.dataTabPage.Location = new System.Drawing.Point(4, 22);
    12696      this.dataTabPage.Name = "dataTabPage";
    12797      this.dataTabPage.Padding = new System.Windows.Forms.Padding(3);
    128       this.dataTabPage.Size = new System.Drawing.Size(268, 158);
     98      this.dataTabPage.Size = new System.Drawing.Size(499, 425);
    12999      this.dataTabPage.TabIndex = 0;
    130100      this.dataTabPage.Text = "Data";
    131101      this.dataTabPage.UseVisualStyleBackColor = true;
    132       //
    133       // variablesLabel
    134       //
    135       this.variablesLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
    136       this.variablesLabel.AutoSize = true;
    137       this.variablesLabel.Location = new System.Drawing.Point(6, 61);
    138       this.variablesLabel.Name = "variablesLabel";
    139       this.variablesLabel.Size = new System.Drawing.Size(53, 13);
    140       this.variablesLabel.TabIndex = 9;
    141       this.variablesLabel.Text = "Variables:";
    142       //
    143       // variablesTextBox
    144       //
    145       this.variablesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
    146       this.variablesTextBox.Location = new System.Drawing.Point(62, 58);
    147       this.variablesTextBox.Name = "variablesTextBox";
    148       this.variablesTextBox.ReadOnly = true;
    149       this.variablesTextBox.Size = new System.Drawing.Size(81, 20);
    150       this.variablesTextBox.TabIndex = 10;
    151       //
    152       // samplesLabel
    153       //
    154       this.samplesLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
    155       this.samplesLabel.AutoSize = true;
    156       this.samplesLabel.Location = new System.Drawing.Point(6, 35);
    157       this.samplesLabel.Name = "samplesLabel";
    158       this.samplesLabel.Size = new System.Drawing.Size(50, 13);
    159       this.samplesLabel.TabIndex = 7;
    160       this.samplesLabel.Text = "Samples:";
    161       //
    162       // samplesTextBox
    163       //
    164       this.samplesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
    165       this.samplesTextBox.Location = new System.Drawing.Point(62, 32);
    166       this.samplesTextBox.Name = "samplesTextBox";
    167       this.samplesTextBox.ReadOnly = true;
    168       this.samplesTextBox.Size = new System.Drawing.Size(81, 20);
    169       this.samplesTextBox.TabIndex = 8;
    170102      //
    171103      // variableInfosTabPage
     
    175107      this.variableInfosTabPage.Name = "variableInfosTabPage";
    176108      this.variableInfosTabPage.Padding = new System.Windows.Forms.Padding(3);
    177       this.variableInfosTabPage.Size = new System.Drawing.Size(268, 158);
     109      this.variableInfosTabPage.Size = new System.Drawing.Size(499, 425);
    178110      this.variableInfosTabPage.TabIndex = 1;
    179111      this.variableInfosTabPage.Text = "Variable Infos";
     
    187119      this.operatorBaseVariableInfosView.Name = "operatorBaseVariableInfosView";
    188120      this.operatorBaseVariableInfosView.Operator = null;
    189       this.operatorBaseVariableInfosView.Size = new System.Drawing.Size(262, 152);
     121      this.operatorBaseVariableInfosView.Size = new System.Drawing.Size(493, 419);
    190122      this.operatorBaseVariableInfosView.TabIndex = 0;
    191123      //
     
    196128      this.descriptionTabPage.Name = "descriptionTabPage";
    197129      this.descriptionTabPage.Padding = new System.Windows.Forms.Padding(3);
    198       this.descriptionTabPage.Size = new System.Drawing.Size(268, 158);
     130      this.descriptionTabPage.Size = new System.Drawing.Size(499, 425);
    199131      this.descriptionTabPage.TabIndex = 2;
    200132      this.descriptionTabPage.Text = "Description";
     
    208140      this.operatorBaseDescriptionView.Name = "operatorBaseDescriptionView";
    209141      this.operatorBaseDescriptionView.Operator = null;
    210       this.operatorBaseDescriptionView.Size = new System.Drawing.Size(262, 152);
     142      this.operatorBaseDescriptionView.Size = new System.Drawing.Size(493, 419);
    211143      this.operatorBaseDescriptionView.TabIndex = 0;
     144      //
     145      // datasetView
     146      //
     147      this.datasetView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     148                  | System.Windows.Forms.AnchorStyles.Left)
     149                  | System.Windows.Forms.AnchorStyles.Right)));
     150      this.datasetView.Caption = "View";
     151      this.datasetView.Location = new System.Drawing.Point(6, 33);
     152      this.datasetView.Name = "datasetView";
     153      this.datasetView.Size = new System.Drawing.Size(487, 386);
     154      this.datasetView.TabIndex = 7;
    212155      //
    213156      // StructIdProblemInjectorView
     
    217160      this.Controls.Add(this.tabControl);
    218161      this.Name = "StructIdProblemInjectorView";
    219       this.Size = new System.Drawing.Size(276, 184);
     162      this.Size = new System.Drawing.Size(507, 451);
    220163      this.tabControl.ResumeLayout(false);
    221164      this.dataTabPage.ResumeLayout(false);
    222       this.dataTabPage.PerformLayout();
    223165      this.variableInfosTabPage.ResumeLayout(false);
    224166      this.descriptionTabPage.ResumeLayout(false);
     
    229171    #endregion
    230172
    231     private System.Windows.Forms.Label nameLabel;
    232     private System.Windows.Forms.TextBox nameTextBox;
    233173    private System.Windows.Forms.Button importInstanceButton;
    234174    private System.Windows.Forms.OpenFileDialog openFileDialog;
     
    239179    private System.Windows.Forms.TabPage descriptionTabPage;
    240180    private HeuristicLab.Core.OperatorBaseDescriptionView operatorBaseDescriptionView;
    241     private System.Windows.Forms.Label variablesLabel;
    242     private System.Windows.Forms.TextBox variablesTextBox;
    243     private System.Windows.Forms.Label samplesLabel;
    244     private System.Windows.Forms.TextBox samplesTextBox;
     181    private HeuristicLab.DataAnalysis.DatasetView datasetView;
    245182  }
    246183}
  • branches/3.0/sources/HeuristicLab.StructureIdentification/StructIdProblemInjectorView.cs

    r131 r278  
    6161      base.UpdateControls();
    6262      if (StructIdProblemInjector == null) {
    63         nameTextBox.Text = "-";
    64         variablesTextBox.Text = "-";
    65         samplesTextBox.Text = "-";
    6663        importInstanceButton.Enabled = false;
    6764      } else {
    6865        Dataset dataset = (Dataset)StructIdProblemInjector.GetVariable("Dataset").Value;
    69         nameTextBox.Text = dataset.Name;
    70         samplesTextBox.Text = dataset.Rows+"";
    71         variablesTextBox.Text = dataset.Columns+"";
     66        datasetView.Dataset = dataset;
    7267        importInstanceButton.Enabled = true;
    7368      }
  • branches/3.0/sources/HeuristicLab/MainForm.cs

    r19 r278  
    9696            PluginManager.Manager.Run(app);
    9797          });
    98           t.SetApartmentState(ApartmentState.STA);
     98          t.SetApartmentState(ApartmentState.STA); // needed for the AdvancedOptimizationFrontent
    9999          t.Start();
    100100        }
Note: See TracChangeset for help on using the changeset viewer.