Changeset 1003


Ignore:
Timestamp:
12/17/08 14:29:53 (11 years ago)
Author:
gkronber
Message:

worked on CEDMA console and problem importer. #419 (Refactor CEDMA plugins)

Location:
branches/CEDMA-Refactoring-Ticket419
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.cs

    r988 r1003  
    5151      base.UpdateControls();
    5252      editorGroupBox.Controls.Clear();
    53       editorGroupBox.Enabled = false;
    5453      Control problemControl = (Control)DataSet.Problem.CreateView();
    5554      problemControl.Dock = DockStyle.Fill;
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Problem.cs

    r992 r1003  
    4949    public int TrainingSamplesStart {
    5050      get { return trainingSamplesStart; }
     51      set { trainingSamplesStart = value; }
    5152    }
    5253
     
    5455    public int TrainingSamplesEnd {
    5556      get { return trainingSamplesEnd; }
     57      set { trainingSamplesEnd = value; }
    5658    }
    5759
     
    8385
    8486    private List<int> allowedInputVariables;
     87    public List<int> AllowedInputVariables {
     88      get { return allowedInputVariables; }
     89    }
     90
    8591    private List<int> allowedTargetVariables;
    86 
    87     private List<int> minTimeOffsets;
    88     private List<int> maxTimeOffsets;
     92    public List<int> AllowedTargetVariables {
     93      get { return allowedTargetVariables; }
     94    }
    8995
    9096    private bool autoRegressive;
     
    104110    public Problem()
    105111      : base() {
     112      dataset = new DataAnalysis.Dataset();
     113      allowedInputVariables = new List<int>();
     114      allowedTargetVariables = new List<int>();
     115    }
     116
     117    public override IView CreateView() {
     118      return new ProblemView(this);
    106119    }
    107120  }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.Designer.cs

    r992 r1003  
    6161      this.inputsGroupBox = new System.Windows.Forms.GroupBox();
    6262      this.partitioningGroupBox = new System.Windows.Forms.GroupBox();
     63      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    6364      this.targetsGroupBox.SuspendLayout();
    6465      this.inputsGroupBox.SuspendLayout();
     
    7475      this.importButton.Text = "Import";
    7576      this.importButton.UseVisualStyleBackColor = true;
     77      this.importButton.Click += new System.EventHandler(this.importButton_Click);
    7678      //
    7779      // textBox1
     
    154156      this.datasetView.Location = new System.Drawing.Point(3, 32);
    155157      this.datasetView.Name = "datasetView";
    156       this.datasetView.Size = new System.Drawing.Size(326, 221);
     158      this.datasetView.Size = new System.Drawing.Size(326, 230);
    157159      this.datasetView.TabIndex = 17;
    158160      //
     
    181183      // autoregressiveCheckBox
    182184      //
     185      this.autoregressiveCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    183186      this.autoregressiveCheckBox.AutoSize = true;
    184187      this.autoregressiveCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
    185       this.autoregressiveCheckBox.Location = new System.Drawing.Point(3, 471);
     188      this.autoregressiveCheckBox.Location = new System.Drawing.Point(3, 480);
    186189      this.autoregressiveCheckBox.Name = "autoregressiveCheckBox";
    187190      this.autoregressiveCheckBox.Size = new System.Drawing.Size(102, 17);
     
    192195      // targetsGroupBox
    193196      //
     197      this.targetsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    194198      this.targetsGroupBox.Controls.Add(this.targetsListBox);
    195       this.targetsGroupBox.Location = new System.Drawing.Point(3, 365);
     199      this.targetsGroupBox.Location = new System.Drawing.Point(3, 374);
    196200      this.targetsGroupBox.Name = "targetsGroupBox";
    197201      this.targetsGroupBox.Size = new System.Drawing.Size(167, 100);
     
    202206      // inputsGroupBox
    203207      //
     208      this.inputsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    204209      this.inputsGroupBox.Controls.Add(this.inputsListBox);
    205       this.inputsGroupBox.Location = new System.Drawing.Point(176, 365);
     210      this.inputsGroupBox.Location = new System.Drawing.Point(176, 374);
    206211      this.inputsGroupBox.Name = "inputsGroupBox";
    207212      this.inputsGroupBox.Size = new System.Drawing.Size(153, 100);
     
    212217      // partitioningGroupBox
    213218      //
     219      this.partitioningGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    214220      this.partitioningGroupBox.Controls.Add(this.textBox2);
    215221      this.partitioningGroupBox.Controls.Add(this.trainingLabel);
     
    221227      this.partitioningGroupBox.Controls.Add(this.textBox6);
    222228      this.partitioningGroupBox.Controls.Add(this.testLabel);
    223       this.partitioningGroupBox.Location = new System.Drawing.Point(3, 259);
     229      this.partitioningGroupBox.Location = new System.Drawing.Point(3, 268);
    224230      this.partitioningGroupBox.Name = "partitioningGroupBox";
    225231      this.partitioningGroupBox.Size = new System.Drawing.Size(326, 100);
     
    227233      this.partitioningGroupBox.TabStop = false;
    228234      this.partitioningGroupBox.Text = "Data set partitions:";
     235      //
     236      // openFileDialog
     237      //
     238      this.openFileDialog.DefaultExt = "txt";
     239      this.openFileDialog.FileName = "txt";
     240      this.openFileDialog.Filter = "Text files|*.txt|All files|*.*";
     241      this.openFileDialog.Title = "Import data set from file";
    229242      //
    230243      // ProblemView
     
    239252      this.Controls.Add(this.importButton);
    240253      this.Name = "ProblemView";
    241       this.Size = new System.Drawing.Size(337, 569);
     254      this.Size = new System.Drawing.Size(337, 500);
    242255      this.targetsGroupBox.ResumeLayout(false);
    243256      this.inputsGroupBox.ResumeLayout(false);
     
    268281    private System.Windows.Forms.GroupBox inputsGroupBox;
    269282    private System.Windows.Forms.GroupBox partitioningGroupBox;
     283    private System.Windows.Forms.OpenFileDialog openFileDialog;
    270284  }
    271285}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.cs

    r992 r1003  
    2929using System.Windows.Forms;
    3030using HeuristicLab.Core;
     31using HeuristicLab.DataAnalysis;
    3132
    3233namespace HeuristicLab.CEDMA.Core {
     
    3839      InitializeComponent();
    3940    }
     41
     42    protected override void UpdateControls() {
     43      base.UpdateControls();
     44      // TASK update text-boxes and datasetview
     45    }
     46
     47    private void importButton_Click(object sender, EventArgs e) {
     48      if(openFileDialog.ShowDialog(this) == DialogResult.OK) {
     49        DatasetParser parser = new DatasetParser();
     50        bool success = false;
     51        try {
     52          try {
     53            parser.Import(openFileDialog.FileName, true);
     54            success = true;
     55          } catch(DataFormatException ex) {
     56            ShowWarningMessageBox(ex);
     57            // not possible to parse strictly => clear and try to parse non-strict
     58            parser.Reset();
     59            parser.Import(openFileDialog.FileName, false);
     60            success = true;
     61          }
     62        } catch(DataFormatException ex) {
     63          // if the non-strict parsing also failed then show the exception
     64          ShowErrorMessageBox(ex);
     65        }
     66        if(success) {
     67          Dataset dataset = (Dataset)problem.DataSet;
     68          dataset.Rows = parser.Rows;
     69          dataset.Columns = parser.Columns;
     70          dataset.VariableNames = parser.VariableNames;
     71          dataset.Name = parser.ProblemName;
     72          dataset.Samples = new double[dataset.Rows * dataset.Columns];
     73          Array.Copy(parser.Samples, dataset.Samples, dataset.Columns * dataset.Rows);
     74          problem.TrainingSamplesStart = parser.TrainingSamplesStart;
     75          problem.ValidationSamplesEnd = parser.TrainingSamplesStart;
     76          problem.TrainingSamplesEnd = parser.TrainingSamplesEnd;
     77          problem.ValidationSamplesStart = parser.ValidationSamplesStart;
     78          problem.ValidationSamplesEnd = parser.ValidationSamplesEnd;
     79          problem.TestSamplesStart = parser.TestSamplesStart;
     80          problem.TestSamplesEnd = parser.TestSamplesEnd;
     81          problem.AllowedTargetVariables.Add(parser.TargetVariable);
     82
     83          List<int> nonInputVariables = parser.NonInputVariables;
     84          for(int i = 0; i < dataset.Columns; i++) {
     85            if(!nonInputVariables.Contains(i)) problem.AllowedInputVariables.Add(i);
     86          }
     87          Refresh();
     88        }
     89      }
     90
     91    }
     92    private void ShowWarningMessageBox(Exception ex) {
     93      MessageBox.Show(ex.Message,
     94                      "Warning - " + ex.GetType().Name,
     95                      MessageBoxButtons.OK,
     96                      MessageBoxIcon.Warning);
     97    }
     98    private void ShowErrorMessageBox(Exception ex) {
     99      MessageBox.Show(BuildErrorMessage(ex),
     100                      "Error - " + ex.GetType().Name,
     101                      MessageBoxButtons.OK,
     102                      MessageBoxIcon.Error);
     103    }
     104    private string BuildErrorMessage(Exception ex) {
     105      StringBuilder sb = new StringBuilder();
     106      sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     107
     108      while(ex.InnerException != null) {
     109        ex = ex.InnerException;
     110        sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     111      }
     112      return sb.ToString();
     113    }
    40114  }
    41115}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.resx

    r992 r1003  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
    120123</root>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/ServerForm.designer.cs

    r378 r1003  
    4747      this.addressTextBox = new System.Windows.Forms.TextBox();
    4848      this.externalAddressLabel = new System.Windows.Forms.Label();
    49       this.activeAgentsLabel = new System.Windows.Forms.Label();
    50       this.activeAgentsTextBox = new System.Windows.Forms.TextBox();
    5149      this.gridAddressLabel = new System.Windows.Forms.Label();
    5250      this.gridAddress = new System.Windows.Forms.TextBox();
     
    7068      this.externalAddressLabel.TabIndex = 3;
    7169      this.externalAddressLabel.Text = "&Address:";
    72       //
    73       // activeAgentsLabel
    74       //
    75       this.activeAgentsLabel.AutoSize = true;
    76       this.activeAgentsLabel.Location = new System.Drawing.Point(12, 61);
    77       this.activeAgentsLabel.Name = "activeAgentsLabel";
    78       this.activeAgentsLabel.Size = new System.Drawing.Size(75, 13);
    79       this.activeAgentsLabel.TabIndex = 7;
    80       this.activeAgentsLabel.Text = "A&ctive agents:";
    81       //
    82       // activeAgentsTextBox
    83       //
    84       this.activeAgentsTextBox.Location = new System.Drawing.Point(106, 58);
    85       this.activeAgentsTextBox.Name = "activeAgentsTextBox";
    86       this.activeAgentsTextBox.ReadOnly = true;
    87       this.activeAgentsTextBox.Size = new System.Drawing.Size(90, 20);
    88       this.activeAgentsTextBox.TabIndex = 6;
    89       this.activeAgentsTextBox.Text = "0";
    90       this.activeAgentsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
    9170      //
    9271      // gridAddressLabel
     
    124103      this.Controls.Add(this.gridAddressLabel);
    125104      this.Controls.Add(this.gridAddress);
    126       this.Controls.Add(this.activeAgentsLabel);
    127       this.Controls.Add(this.activeAgentsTextBox);
    128105      this.Controls.Add(this.externalAddressLabel);
    129106      this.Controls.Add(this.addressTextBox);
    130107      this.Name = "ServerForm";
    131       this.Text = "Agent Server";
     108      this.Text = "CEDMA Server";
    132109      this.ResumeLayout(false);
    133110      this.PerformLayout();
     
    139116    private System.Windows.Forms.TextBox addressTextBox;
    140117    private System.Windows.Forms.Label externalAddressLabel;
    141     private System.Windows.Forms.Label activeAgentsLabel;
    142     private System.Windows.Forms.TextBox activeAgentsTextBox;
    143118    private System.Windows.Forms.Label gridAddressLabel;
    144119    private System.Windows.Forms.TextBox gridAddress;
Note: See TracChangeset for help on using the changeset viewer.