Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/08/09 12:48:18 (15 years ago)
Author:
gkronber
Message:

Merged change sets from CEDMA branch to trunk:

Location:
trunk/sources/HeuristicLab.CEDMA.Core
Files:
21 deleted
3 edited
18 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Core/Console.cs

    r560 r1287  
    2929using System.ServiceModel.Description;
    3030using HeuristicLab.CEDMA.DB.Interfaces;
    31 using HeuristicLab.CEDMA.Charting;
    3231
    3332namespace HeuristicLab.CEDMA.Core {
    3433  public class Console : ItemBase, IEditable {
    35     private AgentList agentList;
    36     private ResultList resultsList;
    37     private DatabaseOperatorLibrary operatorLibary;
    38     private ChannelFactory<IDatabase> factory;
    39     private IDatabase database;
     34    private DataSetList dataSetList;
     35    private ChannelFactory<IStore> factory;
     36    private IStore store;
    4037    private string serverUri;
    4138    public string ServerUri {
     
    4340    }
    4441
    45     public IAgentList AgentList {
    46       get { return agentList; }
    47     }
    48 
    49     public ResultList ResultsList {
    50       get { return resultsList; }
    51     }
    52 
    53     public IOperatorLibrary OperatorLibrary {
    54       get { return operatorLibary; }
     42    public DataSetList DataSetList {
     43      get { return dataSetList; }
    5544    }
    5645
    5746    public Console()
    5847      : base() {
    59       agentList = new AgentList();
    60       resultsList = new ResultList();
    61       operatorLibary = new DatabaseOperatorLibrary();
     48      dataSetList = new DataSetList();
    6249    }
    6350
     
    8875    private void ResetConnection() {
    8976      NetTcpBinding binding = new NetTcpBinding();
    90       binding.MaxReceivedMessageSize = 100000000; // 100Mbytes
    91       binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars
    92       binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements;
    93       binding.Security.Mode = SecurityMode.None;
    94       factory = new ChannelFactory<IDatabase>(binding);
    95       database = factory.CreateChannel(new EndpointAddress(serverUri));
    96       agentList.Database = database;
    97       operatorLibary.Database = database;
    98 
    99       ChannelFactory<IStore> storeFactory = new ChannelFactory<IStore>(binding);
    100       IStore store = storeFactory.CreateChannel(new EndpointAddress(serverUri + "/RdfStore"));
    101       resultsList.Store = store;
     77      binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
     78      binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes
     79      binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars
     80      binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;
     81      factory = new ChannelFactory<IStore>(binding);
     82      store = factory.CreateChannel(new EndpointAddress(serverUri));
     83      dataSetList.Store = store;
    10284    }
    10385    #endregion
  • trunk/sources/HeuristicLab.CEDMA.Core/ConsoleEditor.cs

    r561 r1287  
    3636    private System.Windows.Forms.Label uriLabel;
    3737    private Button connectButton;
    38     private Button openOpLibButton;
    39     private Label label1;
    40     private Label resultsLabel;
    41     private Button openResultsButton;
    42     private Button openAgentsButton;
    43     private Label agentsLabel;
     38    private Panel serverPanel;
    4439    private Console console;
    4540
     
    4742      InitializeComponent();
    4843      this.console = console;
     44      serverPanel.Enabled = false;
    4945    }
    5046
     47    #region autogenerated code
    5148    private void InitializeComponent() {
    5249      this.uriTextBox = new System.Windows.Forms.TextBox();
    5350      this.uriLabel = new System.Windows.Forms.Label();
    5451      this.connectButton = new System.Windows.Forms.Button();
    55       this.openOpLibButton = new System.Windows.Forms.Button();
    56       this.label1 = new System.Windows.Forms.Label();
    57       this.resultsLabel = new System.Windows.Forms.Label();
    58       this.openResultsButton = new System.Windows.Forms.Button();
    59       this.openAgentsButton = new System.Windows.Forms.Button();
    60       this.agentsLabel = new System.Windows.Forms.Label();
     52      this.serverPanel = new System.Windows.Forms.Panel();
    6153      this.SuspendLayout();
    6254      //
     
    8779      this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
    8880      //
    89       // openOpLibButton
     81      // serverPanel
    9082      //
    91       this.openOpLibButton.Enabled = false;
    92       this.openOpLibButton.Location = new System.Drawing.Point(94, 85);
    93       this.openOpLibButton.Name = "openOpLibButton";
    94       this.openOpLibButton.Size = new System.Drawing.Size(75, 23);
    95       this.openOpLibButton.TabIndex = 7;
    96       this.openOpLibButton.Text = "&Open";
    97       this.openOpLibButton.UseVisualStyleBackColor = true;
    98       this.openOpLibButton.Click += new System.EventHandler(this.opLibButton_Click);
    99       //
    100       // label1
    101       //
    102       this.label1.AutoSize = true;
    103       this.label1.Location = new System.Drawing.Point(3, 90);
    104       this.label1.Name = "label1";
    105       this.label1.Size = new System.Drawing.Size(85, 13);
    106       this.label1.TabIndex = 8;
    107       this.label1.Text = "Operator Library:";
    108       //
    109       // resultsLabel
    110       //
    111       this.resultsLabel.AutoSize = true;
    112       this.resultsLabel.Location = new System.Drawing.Point(43, 61);
    113       this.resultsLabel.Name = "resultsLabel";
    114       this.resultsLabel.Size = new System.Drawing.Size(45, 13);
    115       this.resultsLabel.TabIndex = 9;
    116       this.resultsLabel.Text = "Results:";
    117       //
    118       // openResultsButton
    119       //
    120       this.openResultsButton.Enabled = false;
    121       this.openResultsButton.Location = new System.Drawing.Point(94, 56);
    122       this.openResultsButton.Name = "openResultsButton";
    123       this.openResultsButton.Size = new System.Drawing.Size(75, 23);
    124       this.openResultsButton.TabIndex = 10;
    125       this.openResultsButton.Text = "&Open";
    126       this.openResultsButton.UseVisualStyleBackColor = true;
    127       this.openResultsButton.Click += new System.EventHandler(this.openChartButton_Click);
    128       //
    129       // openAgentsButton
    130       //
    131       this.openAgentsButton.Enabled = false;
    132       this.openAgentsButton.Location = new System.Drawing.Point(94, 27);
    133       this.openAgentsButton.Name = "openAgentsButton";
    134       this.openAgentsButton.Size = new System.Drawing.Size(75, 23);
    135       this.openAgentsButton.TabIndex = 12;
    136       this.openAgentsButton.Text = "&Open";
    137       this.openAgentsButton.UseVisualStyleBackColor = true;
    138       this.openAgentsButton.Click += new System.EventHandler(this.openAgentsButton_Click);
    139       //
    140       // agentsLabel
    141       //
    142       this.agentsLabel.AutoSize = true;
    143       this.agentsLabel.Location = new System.Drawing.Point(45, 32);
    144       this.agentsLabel.Name = "agentsLabel";
    145       this.agentsLabel.Size = new System.Drawing.Size(43, 13);
    146       this.agentsLabel.TabIndex = 11;
    147       this.agentsLabel.Text = "Agents:";
     83      this.serverPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     84                  | System.Windows.Forms.AnchorStyles.Left)
     85                  | System.Windows.Forms.AnchorStyles.Right)));
     86      this.serverPanel.Location = new System.Drawing.Point(3, 29);
     87      this.serverPanel.Name = "serverPanel";
     88      this.serverPanel.Size = new System.Drawing.Size(439, 157);
     89      this.serverPanel.TabIndex = 4;
    14890      //
    14991      // ConsoleEditor
    15092      //
    15193      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    152       this.Controls.Add(this.openAgentsButton);
    153       this.Controls.Add(this.agentsLabel);
    154       this.Controls.Add(this.openResultsButton);
    155       this.Controls.Add(this.resultsLabel);
    156       this.Controls.Add(this.label1);
    157       this.Controls.Add(this.openOpLibButton);
     94      this.Controls.Add(this.serverPanel);
    15895      this.Controls.Add(this.connectButton);
    15996      this.Controls.Add(this.uriLabel);
     
    166103    }
    167104
     105    #endregion
     106
    168107    private void connectButton_Click(object sender, EventArgs e) {
    169108      try {
    170109        console.Connect(uriTextBox.Text);
    171110        connectButton.Enabled = false;
    172         openOpLibButton.Enabled = true;
    173         openAgentsButton.Enabled = true;
    174         openResultsButton.Enabled = true;
     111        serverPanel.Enabled = true;
     112        serverPanel.Controls.Clear();
     113        Control dataSetListView = (Control)console.DataSetList.CreateView();
     114        dataSetListView.Dock = DockStyle.Fill;
     115        serverPanel.Controls.Add(dataSetListView);
    175116      } catch(CommunicationException ex) {
    176117        MessageBox.Show("Exception while trying to connect to " + uriTextBox.Text + "\n" + ex.Message);
    177118      }
    178119    }
    179 
    180     private void opLibButton_Click(object sender, EventArgs e) {
    181       IOperatorLibrary opLib = console.OperatorLibrary;
    182       if(opLib != null) {
    183         IView view = opLib.CreateView();
    184         if(view != null)
    185           PluginManager.ControlManager.ShowControl(view);
    186       }
    187     }
    188 
    189     private void openChartButton_Click(object sender, EventArgs e) {
    190       PluginManager.ControlManager.ShowControl(console.ResultsList.CreateView());
    191     }
    192 
    193     private void openAgentsButton_Click(object sender, EventArgs e) {
    194       PluginManager.ControlManager.ShowControl(console.AgentList.CreateView());
    195     }
    196120  }
    197121}
  • trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs

    r957 r1287  
    3030
    3131namespace HeuristicLab.CEDMA.Core {
    32   public class DataSet {
     32  public class DataSet : IViewable {
    3333    public IStore Store { get; set; }
    34     public long Id { get; set; }
    35     public string Name { get; set; }
     34
     35    private Guid guid;
     36    public Guid Guid {
     37      get { return guid; }
     38    }
     39
     40    private string name;
     41    public string Name {
     42      get { return name; }
     43      set { name = value; }
     44    }
     45
    3646    private Problem problem;
    37 
    3847    public Problem Problem {
    39       get { return problem; }
     48      get {
     49        // lazy loading of problem from DB
     50        if (problem == null) {
     51          //var serializedDataVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("SerializedData");
     52          //var persistedData = Store.Query(
     53          //  new Statement[] { new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, serializedDataVar)});
     54          var persistedData = Store.Query(
     55            "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.PredicateSerializedData.Uri + "> ?SerializedData .");
     56          if (persistedData.Count() == 1) {
     57            Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData");
     58            this.problem = (Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)persistedLiteral.Value));
     59          } else
     60            this.problem = new Problem(); // no entry in the DB => create a new problem
     61        }
     62        return problem;
     63      }
    4064    }
    4165
    4266    public DataSet()
    4367      : base() {
    44       problem = new Problem();
     68      guid = Guid.NewGuid();
     69      name = "Data set";
    4570    }
    4671
    47     public DataSet(IStore store, long id)
     72    public DataSet(IStore store, Entity dataSetEntity)
    4873      : this() {
    4974      Store = store;
    50       Id = id;
    51     }
    52 
    53     public void Save() {
    54       throw new NotImplementedException();
     75      guid = new Guid(dataSetEntity.Uri.Remove(0, Ontology.CedmaNameSpace.Length));
     76      name = guid.ToString();
    5577    }
    5678
    5779    public void Activate() {
    58       throw new NotImplementedException();
    59     }
    60 
    61     private void UpdateDataSet(long Id, byte[] p) {
    62       throw new NotImplementedException();
     80      Entity myEntity = new Entity(Ontology.CedmaNameSpace + Guid);
     81      Store.Add(new Statement(myEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));
     82      Store.Add(new Statement(myEntity, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(PersistenceManager.SaveToGZip(problem)))));
     83      Store.Add(new Statement(myEntity, Ontology.PredicateName, new Literal(name)));
    6384    }
    6485
     
    6687      return new DataSetView(this);
    6788    }
     89
     90    internal Results GetResults() {
     91      Results results = new Results(Store);
     92      results.FilterDataSet(new Entity(Ontology.CedmaNameSpace + Guid));
     93      return results;
     94    }
    6895  }
    6996}
  • trunk/sources/HeuristicLab.CEDMA.Core/DataSetList.cs

    r957 r1287  
    4141        store = value;
    4242        Action reload = ReloadList;
    43         lock(dataSetList) {
     43        lock (dataSetList) {
    4444          dataSetList.Clear();
    4545        }
     
    5858
    5959    private void ReloadList() {
    60       throw new NotImplementedException();
    61       //foreach( a in database.GetAgents()) {
    62       //  Agent newAgent = new Agent(Database, a.Id);
    63       //  newAgent.Name = a.Name;
    64       //  newAgent.Status = a.Status;
    65       //  lock(agentList) {
    66       //    agentList.Add(newAgent);
    67       //  }
    68       //  FireChanged();
    69       //}
    70     }
    71 
    72     internal static void CreateDataSet() {
    73       throw new NotImplementedException();
     60      HeuristicLab.CEDMA.DB.Interfaces.Variable dataSetVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("DataSet");
     61      HeuristicLab.CEDMA.DB.Interfaces.Variable dataSetNameVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("Name");
     62      var bindings = store.Query(
     63        "?DataSet <"+Ontology.PredicateInstanceOf.Uri+"> <"+Ontology.TypeDataSet.Uri+"> ." + Environment.NewLine +
     64        "?DataSet <"+Ontology.PredicateName.Uri+"> ?Name .");
     65      //  new Statement[] {
     66      //    new Statement(dataSetVar, Ontology.PredicateInstanceOf, Ontology.TypeDataSet),
     67      //    new Statement(dataSetVar, Ontology.PredicateName, dataSetNameVar)
     68      //});
     69      foreach (var binding in bindings) {
     70        DataSet d = new DataSet(store, (Entity)binding.Get("DataSet"));
     71        d.Name = (string)((Literal)binding.Get("Name")).Value;
     72        lock (dataSetList) {
     73          dataSetList.Add(d);
     74        }
     75        FireChanged();
     76      }
    7477    }
    7578
    7679    public IEnumerator<DataSet> GetEnumerator() {
    7780      List<DataSet> dataSets = new List<DataSet>();
    78       lock(dataSets) {
     81      lock (dataSets) {
    7982        dataSets.AddRange(dataSetList);
    8083      }
     
    8588      return GetEnumerator();
    8689    }
     90
     91    public void Add(DataSet dataSet) {
     92      dataSetList.Add(dataSet);
     93    }
    8794  }
    8895}
  • trunk/sources/HeuristicLab.CEDMA.Core/DataSetListView.Designer.cs

    r957 r1287  
    4848    /// </summary>
    4949    private void InitializeComponent() {
    50       this.components = new System.ComponentModel.Container();
     50      this.refreshButton = new System.Windows.Forms.Button();
     51      this.addButton = new System.Windows.Forms.Button();
    5152      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    52       this.agentsGroupBox = new System.Windows.Forms.GroupBox();
    53       this.agentTreeView = new System.Windows.Forms.TreeView();
     53      this.dataSetsGroupBox = new System.Windows.Forms.GroupBox();
     54      this.dataSetsListView = new System.Windows.Forms.ListView();
    5455      this.detailsGroupBox = new System.Windows.Forms.GroupBox();
    55       this.addButton = new System.Windows.Forms.Button();
    56       this.refreshButton = new System.Windows.Forms.Button();
    57       this.entryContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    58       this.exportAllResultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5956      this.splitContainer1.Panel1.SuspendLayout();
    6057      this.splitContainer1.Panel2.SuspendLayout();
    6158      this.splitContainer1.SuspendLayout();
    62       this.agentsGroupBox.SuspendLayout();
    63       this.entryContextMenuStrip.SuspendLayout();
     59      this.dataSetsGroupBox.SuspendLayout();
    6460      this.SuspendLayout();
     61      //
     62      // refreshButton
     63      //
     64      this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     65      this.refreshButton.Location = new System.Drawing.Point(81, 161);
     66      this.refreshButton.Name = "refreshButton";
     67      this.refreshButton.Size = new System.Drawing.Size(75, 23);
     68      this.refreshButton.TabIndex = 2;
     69      this.refreshButton.Text = "&Refresh";
     70      this.refreshButton.UseVisualStyleBackColor = true;
     71      this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
     72      //
     73      // addButton
     74      //
     75      this.addButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     76      this.addButton.Location = new System.Drawing.Point(0, 161);
     77      this.addButton.Name = "addButton";
     78      this.addButton.Size = new System.Drawing.Size(75, 23);
     79      this.addButton.TabIndex = 1;
     80      this.addButton.Text = "&Add...";
     81      this.addButton.UseVisualStyleBackColor = true;
     82      this.addButton.Click += new System.EventHandler(this.addButton_Click);
    6583      //
    6684      // splitContainer1
     
    7593      // splitContainer1.Panel1
    7694      //
    77       this.splitContainer1.Panel1.Controls.Add(this.agentsGroupBox);
     95      this.splitContainer1.Panel1.Controls.Add(this.dataSetsGroupBox);
    7896      //
    7997      // splitContainer1.Panel2
     
    84102      this.splitContainer1.TabIndex = 0;
    85103      //
    86       // agentsGroupBox
     104      // dataSetsGroupBox
    87105      //
    88       this.agentsGroupBox.Controls.Add(this.agentTreeView);
    89       this.agentsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    90       this.agentsGroupBox.Location = new System.Drawing.Point(0, 0);
    91       this.agentsGroupBox.Name = "agentsGroupBox";
    92       this.agentsGroupBox.Size = new System.Drawing.Size(135, 155);
    93       this.agentsGroupBox.TabIndex = 0;
    94       this.agentsGroupBox.TabStop = false;
    95       this.agentsGroupBox.Text = "&Agents";
     106      this.dataSetsGroupBox.Controls.Add(this.dataSetsListView);
     107      this.dataSetsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     108      this.dataSetsGroupBox.Location = new System.Drawing.Point(0, 0);
     109      this.dataSetsGroupBox.Name = "dataSetsGroupBox";
     110      this.dataSetsGroupBox.Size = new System.Drawing.Size(135, 155);
     111      this.dataSetsGroupBox.TabIndex = 0;
     112      this.dataSetsGroupBox.TabStop = false;
     113      this.dataSetsGroupBox.Text = "&Data Sets";
    96114      //
    97       // agentTreeView
     115      // dataSetsListView
    98116      //
    99       this.agentTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
    100       this.agentTreeView.Location = new System.Drawing.Point(3, 16);
    101       this.agentTreeView.Name = "agentTreeView";
    102       this.agentTreeView.Size = new System.Drawing.Size(129, 136);
    103       this.agentTreeView.TabIndex = 0;
    104       this.agentTreeView.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.agentTreeView_BeforeExpand);
    105       this.agentTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.agentTreeView_AfterSelect);
     117      this.dataSetsListView.Dock = System.Windows.Forms.DockStyle.Fill;
     118      this.dataSetsListView.Location = new System.Drawing.Point(3, 16);
     119      this.dataSetsListView.MultiSelect = false;
     120      this.dataSetsListView.Name = "dataSetsListView";
     121      this.dataSetsListView.Size = new System.Drawing.Size(129, 136);
     122      this.dataSetsListView.TabIndex = 0;
     123      this.dataSetsListView.UseCompatibleStateImageBehavior = false;
     124      this.dataSetsListView.View = System.Windows.Forms.View.List;
     125      this.dataSetsListView.SelectedIndexChanged += new System.EventHandler(this.dataSetsListView_SelectedIndexChanged);
    106126      //
    107127      // detailsGroupBox
     
    115135      this.detailsGroupBox.Text = "&Details";
    116136      //
    117       // addButton
    118       //
    119       this.addButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    120       this.addButton.Location = new System.Drawing.Point(0, 161);
    121       this.addButton.Name = "addButton";
    122       this.addButton.Size = new System.Drawing.Size(75, 23);
    123       this.addButton.TabIndex = 1;
    124       this.addButton.Text = "&Add...";
    125       this.addButton.UseVisualStyleBackColor = true;
    126       this.addButton.Click += new System.EventHandler(this.addButton_Click);
    127       //
    128       // refreshButton
    129       //
    130       this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    131       this.refreshButton.Location = new System.Drawing.Point(81, 161);
    132       this.refreshButton.Name = "refreshButton";
    133       this.refreshButton.Size = new System.Drawing.Size(75, 23);
    134       this.refreshButton.TabIndex = 2;
    135       this.refreshButton.Text = "&Refresh";
    136       this.refreshButton.UseVisualStyleBackColor = true;
    137       this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
    138       //
    139       // entryContextMenuStrip
    140       //
    141       this.entryContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    142             this.exportAllResultsToolStripMenuItem});
    143       this.entryContextMenuStrip.Name = "entryContextMenuStrip";
    144       this.entryContextMenuStrip.Size = new System.Drawing.Size(166, 26);
    145       //
    146       // exportAllResultsToolStripMenuItem
    147       //
    148       this.exportAllResultsToolStripMenuItem.Name = "exportAllResultsToolStripMenuItem";
    149       this.exportAllResultsToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
    150       this.exportAllResultsToolStripMenuItem.Text = "Export all results";
    151       this.exportAllResultsToolStripMenuItem.Click += new System.EventHandler(this.exportAllResultsToolStripMenuItem_Click);
    152       //
    153       // AgentListView
     137      // DataSetListView
    154138      //
    155139      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     
    157141      this.Controls.Add(this.addButton);
    158142      this.Controls.Add(this.splitContainer1);
    159       this.Name = "AgentListView";
     143      this.Name = "DataSetListView";
    160144      this.Size = new System.Drawing.Size(276, 184);
    161145      this.splitContainer1.Panel1.ResumeLayout(false);
    162146      this.splitContainer1.Panel2.ResumeLayout(false);
    163147      this.splitContainer1.ResumeLayout(false);
    164       this.agentsGroupBox.ResumeLayout(false);
    165       this.entryContextMenuStrip.ResumeLayout(false);
     148      this.dataSetsGroupBox.ResumeLayout(false);
    166149      this.ResumeLayout(false);
    167150
     
    171154
    172155    private System.Windows.Forms.SplitContainer splitContainer1;
    173     private System.Windows.Forms.GroupBox agentsGroupBox;
     156    private System.Windows.Forms.GroupBox dataSetsGroupBox;
    174157    private System.Windows.Forms.GroupBox detailsGroupBox;
    175158    private System.Windows.Forms.Button addButton;
    176     private TreeView agentTreeView;
    177159    private Button refreshButton;
    178     private ContextMenuStrip entryContextMenuStrip;
    179     private ToolStripMenuItem exportAllResultsToolStripMenuItem;
     160    private ListView dataSetsListView;
    180161  }
    181162}
  • trunk/sources/HeuristicLab.CEDMA.Core/DataSetListView.cs

    r957 r1287  
    3131namespace HeuristicLab.CEDMA.Core {
    3232  public partial class DataSetListView : ViewBase {
    33     public DataSetList DataSetList{
     33    public DataSetList DataSetList {
    3434      get { return (DataSetList)Item; }
    3535      set { base.Item = value; }
     
    4747
    4848    void dataSetList_Changed(object sender, EventArgs e) {
    49       UpdateControls();
     49      if (InvokeRequired) Invoke((EventHandler)dataSetList_Changed, sender, e);
     50      else UpdateControls();
    5051    }
    5152
     
    5657      if(DataSetList == null) {
    5758        Caption = "Data Sets View";
    58         agentTreeView.Enabled = false;
     59        dataSetsListView.Enabled = false;
    5960      } else {
    60         agentTreeView.Enabled = true;
    61         agentTreeView.Nodes.Clear();
     61        dataSetsListView.Enabled = true;
     62        dataSetsListView.Items.Clear();
    6263        foreach(DataSet dataSet in DataSetList) {
    63           TreeNode node = new TreeNode();
     64          ListViewItem node = new ListViewItem();
    6465          node.Text = dataSet.Name;
    6566          node.Tag = dataSet;
    66           node.Nodes.Add("dummy");
    67           node.ContextMenuStrip = entryContextMenuStrip;
    68           agentTreeView.Nodes.Add(node);
     67          dataSetsListView.Items.Add(node);
    6968        }
    7069      }
     
    7372    #region Button Events
    7473    private void addButton_Click(object sender, EventArgs e) {
    75       DataSetList.CreateDataSet();
     74      DataSet dataSet = new DataSet();
     75      dataSet.Store = DataSetList.Store;
     76      DataSetList.Add(dataSet);
     77      UpdateControls();
    7678    }
    77     #endregion
    78 
    79     private void agentTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
    80       if(detailsGroupBox.Controls.Count > 0)
    81         detailsGroupBox.Controls[0].Dispose();
    82       detailsGroupBox.Controls.Clear();
    83       detailsGroupBox.Enabled = false;
    84       if(agentTreeView.SelectedNode != null) {
    85         IViewable viewable = (IViewable)agentTreeView.SelectedNode.Tag;
     79    private void dataSetsListView_SelectedIndexChanged(object sender, EventArgs e) {
     80      if(dataSetsListView.SelectedItems.Count > 0) {
     81        if(detailsGroupBox.Controls.Count > 0)
     82          detailsGroupBox.Controls[0].Dispose();
     83        detailsGroupBox.Controls.Clear();
     84        detailsGroupBox.Enabled = false;
     85        IViewable viewable = (IViewable)dataSetsListView.SelectedItems[0].Tag;
    8686        Control control = (Control)viewable.CreateView();
    8787        detailsGroupBox.Controls.Add(control);
     
    9090      }
    9191    }
     92    #endregion
     93
    9294
    9395    private void refreshButton_Click(object sender, EventArgs e) {
  • trunk/sources/HeuristicLab.CEDMA.Core/DataSetListView.resx

    r957 r1287  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
    120   <metadata name="entryContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    121     <value>17, 17</value>
    122   </metadata>
    123120</root>
  • trunk/sources/HeuristicLab.CEDMA.Core/DataSetView.Designer.cs

    r957 r1287  
    4646    private void InitializeComponent() {
    4747      this.editorGroupBox = new System.Windows.Forms.GroupBox();
    48       this.saveButton = new System.Windows.Forms.Button();
    4948      this.activateButton = new System.Windows.Forms.Button();
     49      this.resultsButton = new System.Windows.Forms.Button();
     50      this.progressBar = new System.Windows.Forms.ProgressBar();
     51      this.viewComboBox = new System.Windows.Forms.ComboBox();
    5052      this.SuspendLayout();
    5153      //
     
    5759      this.editorGroupBox.Location = new System.Drawing.Point(0, 3);
    5860      this.editorGroupBox.Name = "editorGroupBox";
    59       this.editorGroupBox.Size = new System.Drawing.Size(274, 119);
     61      this.editorGroupBox.Size = new System.Drawing.Size(381, 218);
    6062      this.editorGroupBox.TabIndex = 0;
    6163      this.editorGroupBox.TabStop = false;
    6264      this.editorGroupBox.Text = "&Editor:";
    6365      //
    64       // saveButton
    65       //
    66       this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    67       this.saveButton.Location = new System.Drawing.Point(4, 128);
    68       this.saveButton.Name = "saveButton";
    69       this.saveButton.Size = new System.Drawing.Size(75, 23);
    70       this.saveButton.TabIndex = 1;
    71       this.saveButton.Text = "&Save";
    72       this.saveButton.UseVisualStyleBackColor = true;
    73       this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
    74       //
    7566      // activateButton
    7667      //
    7768      this.activateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    78       this.activateButton.Location = new System.Drawing.Point(85, 128);
     69      this.activateButton.Location = new System.Drawing.Point(0, 227);
    7970      this.activateButton.Name = "activateButton";
    8071      this.activateButton.Size = new System.Drawing.Size(75, 23);
    8172      this.activateButton.TabIndex = 2;
    82       this.activateButton.Text = "&Start";
     73      this.activateButton.Text = "&Activate";
    8374      this.activateButton.UseVisualStyleBackColor = true;
    8475      this.activateButton.Click += new System.EventHandler(this.activateButton_Click);
    8576      //
    86       // AgentView
     77      // resultsButton
     78      //
     79      this.resultsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     80      this.resultsButton.Location = new System.Drawing.Point(130, 254);
     81      this.resultsButton.Name = "resultsButton";
     82      this.resultsButton.Size = new System.Drawing.Size(86, 23);
     83      this.resultsButton.TabIndex = 3;
     84      this.resultsButton.Text = "Show results";
     85      this.resultsButton.UseVisualStyleBackColor = true;
     86      this.resultsButton.Click += new System.EventHandler(this.resultsButton_Click);
     87      //
     88      // progressBar
     89      //
     90      this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     91                  | System.Windows.Forms.AnchorStyles.Right)));
     92      this.progressBar.Location = new System.Drawing.Point(222, 254);
     93      this.progressBar.Name = "progressBar";
     94      this.progressBar.Size = new System.Drawing.Size(156, 23);
     95      this.progressBar.TabIndex = 4;
     96      //
     97      // viewComboBox
     98      //
     99      this.viewComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     100      this.viewComboBox.FormattingEnabled = true;
     101      this.viewComboBox.Location = new System.Drawing.Point(3, 256);
     102      this.viewComboBox.Name = "viewComboBox";
     103      this.viewComboBox.Size = new System.Drawing.Size(121, 21);
     104      this.viewComboBox.TabIndex = 5;
     105      //
     106      // DataSetView
    87107      //
    88108      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    89109      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     110      this.Controls.Add(this.viewComboBox);
     111      this.Controls.Add(this.progressBar);
     112      this.Controls.Add(this.resultsButton);
    90113      this.Controls.Add(this.activateButton);
    91       this.Controls.Add(this.saveButton);
    92114      this.Controls.Add(this.editorGroupBox);
    93       this.Name = "AgentView";
    94       this.Size = new System.Drawing.Size(274, 154);
     115      this.Name = "DataSetView";
     116      this.Size = new System.Drawing.Size(381, 280);
    95117      this.ResumeLayout(false);
    96118
     
    100122
    101123    private System.Windows.Forms.GroupBox editorGroupBox;
    102     private System.Windows.Forms.Button saveButton;
    103124    private System.Windows.Forms.Button activateButton;
     125    private System.Windows.Forms.Button resultsButton;
     126    private System.Windows.Forms.ProgressBar progressBar;
     127    private System.Windows.Forms.ComboBox viewComboBox;
    104128  }
    105129}
  • trunk/sources/HeuristicLab.CEDMA.Core/DataSetView.cs

    r957 r1287  
    2525using System.Drawing;
    2626using System.Data;
     27using System.Linq;
    2728using System.Text;
    2829using System.Windows.Forms;
    2930using HeuristicLab.Core;
    3031using HeuristicLab.CEDMA.DB.Interfaces;
     32using HeuristicLab.PluginInfrastructure;
    3133
    3234namespace HeuristicLab.CEDMA.Core {
     
    3739      set { dataSet = value; }
    3840    }
    39 
     41    private Results results;
    4042    public DataSetView() {
    4143      InitializeComponent();
     
    5153      base.UpdateControls();
    5254      editorGroupBox.Controls.Clear();
    53       editorGroupBox.Enabled = false;
     55      Control problemControl = (Control)DataSet.Problem.CreateView();
     56      problemControl.Dock = DockStyle.Fill;
     57      editorGroupBox.Controls.Add(problemControl);
     58      PopulateViewComboBox();
     59      resultsButton.Enabled = viewComboBox.SelectedItem != null;
    5460    }
    5561
    56     private void saveButton_Click(object sender, EventArgs e) {
    57       DataSet.Save();
     62    private void PopulateViewComboBox() {
     63      DiscoveryService service = new DiscoveryService();
     64      IResultsViewFactory[] factories = service.GetInstances<IResultsViewFactory>();
     65      viewComboBox.DataSource = factories;
     66      viewComboBox.ValueMember = "Name";
    5867    }
    5968
     
    6271      activateButton.Enabled = false;
    6372    }
     73
     74    private void resultsButton_Click(object sender, EventArgs e) {
     75      if (results == null)
     76        ReloadResults();
     77      try {
     78        IResultsViewFactory factory = (IResultsViewFactory)viewComboBox.SelectedItem;
     79        BackgroundWorker worker = new BackgroundWorker();
     80        worker.WorkerReportsProgress = true;
     81        worker.WorkerSupportsCancellation = true;
     82        worker.ProgressChanged += delegate(object progressChangedSender, ProgressChangedEventArgs progressChangedArgs) {
     83          progressBar.Value = progressChangedArgs.ProgressPercentage;
     84        };
     85        worker.DoWork += delegate(object doWorkSender, DoWorkEventArgs doWorkArgs) {
     86          int n = results.GetEntries().Count();
     87          int i = 0;
     88          // preload list
     89          foreach (var entry in results.GetEntries()) {
     90            i++;
     91            if((((i*100) / n) % 10) == 0) worker.ReportProgress((i * 100) / n);
     92          }
     93          worker.ReportProgress(100);
     94        };
     95        resultsButton.Enabled = false;
     96        worker.RunWorkerAsync();
     97        worker.RunWorkerCompleted += delegate(object completedSender, RunWorkerCompletedEventArgs compledArgs) {
     98          resultsButton.Enabled = true;
     99          progressBar.Value = 0;
     100          IControl control = factory.CreateView(results);
     101          PluginManager.ControlManager.ShowControl(control);
     102        };
     103      }
     104      catch (Exception ex) {
     105        string text = "Couldn't load selected view: " + viewComboBox.SelectedItem + "\n" + ex.Message;
     106        MessageBox.Show(text, "Unable to create view", MessageBoxButtons.OK, MessageBoxIcon.Error);
     107      }
     108    }
     109
     110    private void ReloadResults() {
     111      results = dataSet.GetResults();
     112    }
    64113  }
    65114}
     115
  • trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj

    r852 r1287  
    7272  </ItemGroup>
    7373  <ItemGroup>
    74     <Compile Include="Agent.cs" />
    75     <Compile Include="AgentList.cs" />
     74    <Compile Include="IResultsViewFactory.cs" />
     75    <Compile Include="ResultsEntry.cs" />
     76    <Compile Include="TableResultsView.cs">
     77      <SubType>UserControl</SubType>
     78    </Compile>
     79    <Compile Include="TableResultsView.Designer.cs">
     80      <DependentUpon>TableResultsView.cs</DependentUpon>
     81    </Compile>
    7682    <Compile Include="Console.cs" />
    7783    <Compile Include="ConsoleEditor.cs">
    7884      <SubType>UserControl</SubType>
    7985    </Compile>
    80     <Compile Include="ResultTable.cs" />
    81     <Compile Include="ResultExporter.cs" />
    82     <Compile Include="DatabaseOperatorLibrary.cs" />
    83     <Compile Include="DatabaseOperatorLibraryView.cs">
     86    <Compile Include="Problem.cs" />
     87    <Compile Include="DataSet.cs" />
     88    <Compile Include="DataSetList.cs" />
     89    <Compile Include="DataSetListView.cs">
    8490      <SubType>UserControl</SubType>
    8591    </Compile>
    86     <Compile Include="DatabaseOperatorLibraryView.Designer.cs">
    87       <DependentUpon>DatabaseOperatorLibraryView.cs</DependentUpon>
     92    <Compile Include="DataSetListView.Designer.cs">
     93      <DependentUpon>DataSetListView.cs</DependentUpon>
    8894    </Compile>
    89     <Compile Include="OperatorLink.cs" />
    90     <Compile Include="OperatorLinkPatcher.cs" />
    91     <Compile Include="Result.cs" />
    92     <Compile Include="IResult.cs" />
    93     <Compile Include="HeuristicLabCedmaCorePlugin.cs" />
    94     <Compile Include="IAgent.cs" />
    95     <Compile Include="IAgentList.cs" />
    96     <Compile Include="IDatabaseItem.cs" />
    97     <Compile Include="Properties\AssemblyInfo.cs" />
    98     <Compile Include="AgentListView.cs">
     95    <Compile Include="DataSetView.cs">
    9996      <SubType>UserControl</SubType>
    10097    </Compile>
    101     <Compile Include="AgentListView.Designer.cs">
    102       <DependentUpon>AgentListView.cs</DependentUpon>
     98    <Compile Include="DataSetView.Designer.cs">
     99      <DependentUpon>DataSetView.cs</DependentUpon>
    103100    </Compile>
    104     <Compile Include="AgentView.cs">
     101    <Compile Include="HeuristicLabCedmaCorePlugin.cs" />
     102    <Compile Include="ProblemView.cs">
    105103      <SubType>UserControl</SubType>
    106104    </Compile>
    107     <Compile Include="AgentView.Designer.cs">
    108       <DependentUpon>AgentView.cs</DependentUpon>
     105    <Compile Include="ProblemView.Designer.cs">
     106      <DependentUpon>ProblemView.cs</DependentUpon>
    109107    </Compile>
     108    <Compile Include="Properties\AssemblyInfo.cs" />
     109    <Compile Include="Results.cs" />
    110110  </ItemGroup>
    111111  <ItemGroup>
     
    113113  </ItemGroup>
    114114  <ItemGroup>
    115     <ProjectReference Include="..\HeuristicLab.CEDMA.Charting\HeuristicLab.CEDMA.Charting.csproj">
    116       <Project>{1BF17271-5350-476A-8F6D-FC74FA3E82CA}</Project>
    117       <Name>HeuristicLab.CEDMA.Charting</Name>
    118     </ProjectReference>
    119115    <ProjectReference Include="..\HeuristicLab.CEDMA.DB.Interfaces\HeuristicLab.CEDMA.DB.Interfaces.csproj">
    120116      <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project>
     
    124120      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
    125121      <Name>HeuristicLab.Core</Name>
     122    </ProjectReference>
     123    <ProjectReference Include="..\HeuristicLab.DataAnalysis\HeuristicLab.DataAnalysis.csproj">
     124      <Project>{7DD3A97A-56E9-462F-90E2-A351FE7AF5C2}</Project>
     125      <Name>HeuristicLab.DataAnalysis</Name>
     126    </ProjectReference>
     127    <ProjectReference Include="..\HeuristicLab.Data\HeuristicLab.Data.csproj">
     128      <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project>
     129      <Name>HeuristicLab.Data</Name>
    126130    </ProjectReference>
    127131    <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj">
     
    135139  </ItemGroup>
    136140  <ItemGroup>
    137     <EmbeddedResource Include="AgentListView.resx">
    138       <DependentUpon>AgentListView.cs</DependentUpon>
    139       <SubType>Designer</SubType>
    140     </EmbeddedResource>
    141     <EmbeddedResource Include="AgentView.resx">
    142       <DependentUpon>AgentView.cs</DependentUpon>
    143       <SubType>Designer</SubType>
     141    <EmbeddedResource Include="TableResultsView.resx">
     142      <DependentUpon>TableResultsView.cs</DependentUpon>
    144143    </EmbeddedResource>
    145144    <EmbeddedResource Include="ConsoleEditor.resx">
     
    147146      <SubType>Designer</SubType>
    148147    </EmbeddedResource>
    149     <EmbeddedResource Include="DatabaseOperatorLibraryView.resx">
    150       <DependentUpon>DatabaseOperatorLibraryView.cs</DependentUpon>
    151       <SubType>Designer</SubType>
     148    <EmbeddedResource Include="DataSetListView.resx">
     149      <DependentUpon>DataSetListView.cs</DependentUpon>
     150    </EmbeddedResource>
     151    <EmbeddedResource Include="DataSetView.resx">
     152      <DependentUpon>DataSetView.cs</DependentUpon>
     153    </EmbeddedResource>
     154    <EmbeddedResource Include="ProblemView.resx">
     155      <DependentUpon>ProblemView.cs</DependentUpon>
    152156    </EmbeddedResource>
    153157  </ItemGroup>
  • trunk/sources/HeuristicLab.CEDMA.Core/Problem.cs

    r957 r1287  
    3030
    3131namespace HeuristicLab.CEDMA.Core {
     32
     33  public enum LearningTask {
     34    Classification,
     35    Regression,
     36    TimeSeries,
     37    Clustering
     38  }
     39
    3240  /// <summary>
    3341  /// Problem describes the data mining task.
     
    3644  ///  * regression, time-series or classification problem
    3745  /// </summary>
    38   public class Problem {
     46  public class Problem : ItemBase {
     47    private string name;
     48    public string Name {
     49      get { return name; }
     50    }
     51    private HeuristicLab.DataAnalysis.Dataset dataset;
     52    public HeuristicLab.DataAnalysis.Dataset DataSet {
     53      get { return dataset; }
     54    }
     55
     56    private int trainingSamplesStart;
     57    public int TrainingSamplesStart {
     58      get { return trainingSamplesStart; }
     59      set { trainingSamplesStart = value; }
     60    }
     61
     62    private int trainingSamplesEnd;
     63    public int TrainingSamplesEnd {
     64      get { return trainingSamplesEnd; }
     65      set { trainingSamplesEnd = value; }
     66    }
     67
     68    private int validationSamplesStart;
     69    public int ValidationSamplesStart {
     70      get { return validationSamplesStart; }
     71      set { validationSamplesStart = value; }
     72    }
     73
     74    private int validationSamplesEnd;
     75    public int ValidationSamplesEnd {
     76      get { return validationSamplesEnd; }
     77      set { validationSamplesEnd = value; }
     78    }
     79
     80    private int testSamplesStart;
     81    public int TestSamplesStart {
     82      get { return testSamplesStart; }
     83      set { testSamplesStart = value; }
     84    }
     85
     86    private int testSamplesEnd;
     87    public int TestSamplesEnd {
     88      get { return testSamplesEnd; }
     89      set { testSamplesEnd = value; }
     90    }
     91
     92    private List<int> allowedInputVariables;
     93    public List<int> AllowedInputVariables {
     94      get { return allowedInputVariables; }
     95    }
     96
     97    private List<int> allowedTargetVariables;
     98    public List<int> AllowedTargetVariables {
     99      get { return allowedTargetVariables; }
     100    }
     101
     102    private bool autoRegressive;
     103    public bool AutoRegressive {
     104      get { return autoRegressive; }
     105      set { autoRegressive = value; }
     106    }
     107
     108    private int minTimeOffset;
     109    public int MinTimeOffset {
     110      get { return minTimeOffset; }
     111      set { minTimeOffset = value; }
     112    }
     113
     114    private int maxTimeOffset;
     115    public int MaxTimeOffset {
     116      get { return maxTimeOffset; }
     117      set { maxTimeOffset = value; }
     118    }
     119
     120    private LearningTask learningTask;
     121    public LearningTask LearningTask {
     122      get { return learningTask; }
     123      set { learningTask = value; }
     124    }
     125
    39126    public Problem()
    40127      : base() {
     128      dataset = new DataAnalysis.Dataset();
     129      allowedInputVariables = new List<int>();
     130      allowedTargetVariables = new List<int>();
     131    }
     132
     133
     134    public string GetVariableName(int index) {
     135      return dataset.GetVariableName(index);
     136    }
     137
     138    public override IView CreateView() {
     139      return new ProblemView(this);
     140    }
     141
     142    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
     143      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
     144      node.AppendChild(PersistenceManager.Persist("DataSet", dataset, document, persistedObjects));
     145      XmlAttribute trainingSamplesStartAttr = document.CreateAttribute("TrainingSamplesStart");
     146      trainingSamplesStartAttr.Value = TrainingSamplesStart.ToString();
     147      XmlAttribute trainingSamplesEndAttr = document.CreateAttribute("TrainingSamplesEnd");
     148      trainingSamplesEndAttr.Value = TrainingSamplesEnd.ToString();
     149      XmlAttribute validationSamplesStartAttr = document.CreateAttribute("ValidationSamplesStart");
     150      validationSamplesStartAttr.Value = ValidationSamplesStart.ToString();
     151      XmlAttribute validationSamplesEndAttr = document.CreateAttribute("ValidationSamplesEnd");
     152      validationSamplesEndAttr.Value = ValidationSamplesEnd.ToString();
     153      XmlAttribute testSamplesStartAttr = document.CreateAttribute("TestSamplesStart");
     154      testSamplesStartAttr.Value = TestSamplesStart.ToString();
     155      XmlAttribute testSamplesEndAttr = document.CreateAttribute("TestSamplesEnd");
     156      testSamplesEndAttr.Value = TestSamplesEnd.ToString();
     157      XmlAttribute learningTaskAttr = document.CreateAttribute("LearningTask");
     158      learningTaskAttr.Value = LearningTask.ToString();
     159      XmlAttribute autoRegressiveAttr = document.CreateAttribute("AutoRegressive");
     160      autoRegressiveAttr.Value = AutoRegressive.ToString();
     161      XmlAttribute minTimeOffsetAttr = document.CreateAttribute("MinTimeOffset");
     162      minTimeOffsetAttr.Value = MinTimeOffset.ToString();
     163      XmlAttribute maxTimeOffsetAttr = document.CreateAttribute("MaxTimeOffset");
     164      maxTimeOffsetAttr.Value = MaxTimeOffset.ToString();
     165
     166      node.Attributes.Append(trainingSamplesStartAttr);
     167      node.Attributes.Append(trainingSamplesEndAttr);
     168      node.Attributes.Append(validationSamplesStartAttr);
     169      node.Attributes.Append(validationSamplesEndAttr);
     170      node.Attributes.Append(testSamplesStartAttr);
     171      node.Attributes.Append(testSamplesEndAttr);
     172      node.Attributes.Append(learningTaskAttr);
     173      node.Attributes.Append(autoRegressiveAttr);
     174      node.Attributes.Append(minTimeOffsetAttr);
     175      node.Attributes.Append(maxTimeOffsetAttr);
     176
     177      XmlElement targetVariablesElement = document.CreateElement("AllowedTargetVariables");
     178      targetVariablesElement.InnerText = SemiColonSeparatedList(AllowedTargetVariables);
     179      XmlElement inputVariablesElement = document.CreateElement("AllowedInputVariables");
     180      inputVariablesElement.InnerText = SemiColonSeparatedList(AllowedInputVariables);
     181      node.AppendChild(targetVariablesElement);
     182      node.AppendChild(inputVariablesElement);
     183      return node;
     184    }
     185
     186    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
     187      base.Populate(node, restoredObjects);
     188      dataset = (HeuristicLab.DataAnalysis.Dataset)PersistenceManager.Restore(node.SelectSingleNode("DataSet"), restoredObjects);
     189      TrainingSamplesStart = int.Parse(node.Attributes["TrainingSamplesStart"].Value);
     190      TrainingSamplesEnd = int.Parse(node.Attributes["TrainingSamplesEnd"].Value);
     191      ValidationSamplesStart = int.Parse(node.Attributes["ValidationSamplesStart"].Value);
     192      ValidationSamplesEnd = int.Parse(node.Attributes["ValidationSamplesEnd"].Value);
     193      TestSamplesStart = int.Parse(node.Attributes["TestSamplesStart"].Value);
     194      TestSamplesEnd = int.Parse(node.Attributes["TestSamplesEnd"].Value);
     195      LearningTask = (LearningTask)Enum.Parse(typeof(LearningTask), node.Attributes["LearningTask"].Value);
     196      AutoRegressive = bool.Parse(node.Attributes["AutoRegressive"].Value);
     197      if (node.Attributes["MinTimeOffset"] != null)
     198        MinTimeOffset = XmlConvert.ToInt32(node.Attributes["MinTimeOffset"].Value);
     199      else MinTimeOffset = 0;
     200      if (node.Attributes["MaxTimeOffset"] != null)
     201        MaxTimeOffset = XmlConvert.ToInt32(node.Attributes["MaxTimeOffset"].Value);
     202      else MaxTimeOffset = 0;
     203
     204      allowedTargetVariables.Clear();
     205      foreach (string tok in node.SelectSingleNode("AllowedTargetVariables").InnerText.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
     206        allowedTargetVariables.Add(int.Parse(tok));
     207      allowedInputVariables.Clear();
     208      foreach (string tok in node.SelectSingleNode("AllowedInputVariables").InnerText.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
     209        allowedInputVariables.Add(int.Parse(tok));
     210    }
     211
     212    private string SemiColonSeparatedList(List<int> xs) {
     213      StringBuilder b = new StringBuilder();
     214      foreach (int x in xs) {
     215        b = b.Append(x).Append(";");
     216      }
     217      if (xs.Count > 0) b.Remove(b.Length - 1, 1); // remove last ';'
     218      return b.ToString();
    41219    }
    42220  }
  • trunk/sources/HeuristicLab.CEDMA.Core/ProblemView.Designer.cs

    r992 r1287  
    4545    private void InitializeComponent() {
    4646      this.importButton = new System.Windows.Forms.Button();
    47       this.textBox1 = new System.Windows.Forms.TextBox();
     47      this.trainingSamplesStartTextBox = new System.Windows.Forms.TextBox();
    4848      this.trainingLabel = new System.Windows.Forms.Label();
    49       this.textBox4 = new System.Windows.Forms.TextBox();
    50       this.textBox2 = new System.Windows.Forms.TextBox();
    51       this.textBox3 = new System.Windows.Forms.TextBox();
     49      this.trainingSamplesEndTextBox = new System.Windows.Forms.TextBox();
     50      this.validationSamplesEndTextBox = new System.Windows.Forms.TextBox();
     51      this.validationSamplesStartTextBox = new System.Windows.Forms.TextBox();
    5252      this.validationLabel = new System.Windows.Forms.Label();
    53       this.textBox5 = new System.Windows.Forms.TextBox();
    54       this.textBox6 = new System.Windows.Forms.TextBox();
     53      this.testSamplesEndTextBox = new System.Windows.Forms.TextBox();
     54      this.testSamplesStartTextBox = new System.Windows.Forms.TextBox();
    5555      this.testLabel = new System.Windows.Forms.Label();
    56       this.datasetView = new HeuristicLab.DataAnalysis.DatasetView();
    5756      this.targetsListBox = new System.Windows.Forms.CheckedListBox();
    5857      this.inputsListBox = new System.Windows.Forms.CheckedListBox();
     
    6160      this.inputsGroupBox = new System.Windows.Forms.GroupBox();
    6261      this.partitioningGroupBox = new System.Windows.Forms.GroupBox();
     62      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
     63      this.classificationRadioButton = new System.Windows.Forms.RadioButton();
     64      this.regressionRadioButton = new System.Windows.Forms.RadioButton();
     65      this.timeSeriesRadioButton = new System.Windows.Forms.RadioButton();
     66      this.minTimeOffsetLabel = new System.Windows.Forms.Label();
     67      this.minTimeOffsetTextBox = new System.Windows.Forms.TextBox();
     68      this.learningTaskGroupBox = new System.Windows.Forms.GroupBox();
     69      this.autoregressiveLabel = new System.Windows.Forms.Label();
     70      this.maxTimeOffsetLabel = new System.Windows.Forms.Label();
     71      this.maxTimeOffsetTextBox = new System.Windows.Forms.TextBox();
     72      this.datasetView = new HeuristicLab.DataAnalysis.DatasetView();
    6373      this.targetsGroupBox.SuspendLayout();
    6474      this.inputsGroupBox.SuspendLayout();
    6575      this.partitioningGroupBox.SuspendLayout();
     76      this.learningTaskGroupBox.SuspendLayout();
    6677      this.SuspendLayout();
    6778      //
     
    7485      this.importButton.Text = "Import";
    7586      this.importButton.UseVisualStyleBackColor = true;
    76       //
    77       // textBox1
    78       //
    79       this.textBox1.Location = new System.Drawing.Point(119, 17);
    80       this.textBox1.Name = "textBox1";
    81       this.textBox1.Size = new System.Drawing.Size(96, 20);
    82       this.textBox1.TabIndex = 4;
     87      this.importButton.Click += new System.EventHandler(this.importButton_Click);
     88      //
     89      // trainingSamplesStartTextBox
     90      //
     91      this.trainingSamplesStartTextBox.Location = new System.Drawing.Point(119, 17);
     92      this.trainingSamplesStartTextBox.Name = "trainingSamplesStartTextBox";
     93      this.trainingSamplesStartTextBox.Size = new System.Drawing.Size(96, 20);
     94      this.trainingSamplesStartTextBox.TabIndex = 4;
     95      this.trainingSamplesStartTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated);
     96      this.trainingSamplesStartTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating);
    8397      //
    8498      // trainingLabel
     
    91105      this.trainingLabel.Text = "Training samples:";
    92106      //
    93       // textBox4
    94       //
    95       this.textBox4.Location = new System.Drawing.Point(221, 17);
    96       this.textBox4.Name = "textBox4";
    97       this.textBox4.Size = new System.Drawing.Size(96, 20);
    98       this.textBox4.TabIndex = 10;
    99       //
    100       // textBox2
    101       //
    102       this.textBox2.Location = new System.Drawing.Point(221, 43);
    103       this.textBox2.Name = "textBox2";
    104       this.textBox2.Size = new System.Drawing.Size(96, 20);
    105       this.textBox2.TabIndex = 13;
    106       //
    107       // textBox3
    108       //
    109       this.textBox3.Location = new System.Drawing.Point(119, 43);
    110       this.textBox3.Name = "textBox3";
    111       this.textBox3.Size = new System.Drawing.Size(96, 20);
    112       this.textBox3.TabIndex = 12;
     107      // trainingSamplesEndTextBox
     108      //
     109      this.trainingSamplesEndTextBox.Location = new System.Drawing.Point(221, 17);
     110      this.trainingSamplesEndTextBox.Name = "trainingSamplesEndTextBox";
     111      this.trainingSamplesEndTextBox.Size = new System.Drawing.Size(96, 20);
     112      this.trainingSamplesEndTextBox.TabIndex = 10;
     113      this.trainingSamplesEndTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated);
     114      this.trainingSamplesEndTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating);
     115      //
     116      // validationSamplesEndTextBox
     117      //
     118      this.validationSamplesEndTextBox.Location = new System.Drawing.Point(221, 43);
     119      this.validationSamplesEndTextBox.Name = "validationSamplesEndTextBox";
     120      this.validationSamplesEndTextBox.Size = new System.Drawing.Size(96, 20);
     121      this.validationSamplesEndTextBox.TabIndex = 13;
     122      this.validationSamplesEndTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated);
     123      this.validationSamplesEndTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating);
     124      //
     125      // validationSamplesStartTextBox
     126      //
     127      this.validationSamplesStartTextBox.Location = new System.Drawing.Point(119, 43);
     128      this.validationSamplesStartTextBox.Name = "validationSamplesStartTextBox";
     129      this.validationSamplesStartTextBox.Size = new System.Drawing.Size(96, 20);
     130      this.validationSamplesStartTextBox.TabIndex = 12;
     131      this.validationSamplesStartTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated);
     132      this.validationSamplesStartTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating);
    113133      //
    114134      // validationLabel
    115135      //
    116136      this.validationLabel.AutoSize = true;
    117       this.validationLabel.Location = new System.Drawing.Point(5, 48);
     137      this.validationLabel.Location = new System.Drawing.Point(5, 46);
    118138      this.validationLabel.Name = "validationLabel";
    119139      this.validationLabel.Size = new System.Drawing.Size(97, 13);
     
    121141      this.validationLabel.Text = "Validation samples:";
    122142      //
    123       // textBox5
    124       //
    125       this.textBox5.Location = new System.Drawing.Point(221, 68);
    126       this.textBox5.Name = "textBox5";
    127       this.textBox5.Size = new System.Drawing.Size(96, 20);
    128       this.textBox5.TabIndex = 16;
    129       //
    130       // textBox6
    131       //
    132       this.textBox6.Location = new System.Drawing.Point(119, 68);
    133       this.textBox6.Name = "textBox6";
    134       this.textBox6.Size = new System.Drawing.Size(96, 20);
    135       this.textBox6.TabIndex = 15;
     143      // testSamplesEndTextBox
     144      //
     145      this.testSamplesEndTextBox.Location = new System.Drawing.Point(221, 68);
     146      this.testSamplesEndTextBox.Name = "testSamplesEndTextBox";
     147      this.testSamplesEndTextBox.Size = new System.Drawing.Size(96, 20);
     148      this.testSamplesEndTextBox.TabIndex = 16;
     149      this.testSamplesEndTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated);
     150      this.testSamplesEndTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating);
     151      //
     152      // testSamplesStartTextBox
     153      //
     154      this.testSamplesStartTextBox.Location = new System.Drawing.Point(119, 68);
     155      this.testSamplesStartTextBox.Name = "testSamplesStartTextBox";
     156      this.testSamplesStartTextBox.Size = new System.Drawing.Size(96, 20);
     157      this.testSamplesStartTextBox.TabIndex = 15;
     158      this.testSamplesStartTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated);
     159      this.testSamplesStartTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating);
    136160      //
    137161      // testLabel
     
    143167      this.testLabel.TabIndex = 14;
    144168      this.testLabel.Text = "Test samples:";
     169      //
     170      // targetsListBox
     171      //
     172      this.targetsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     173                  | System.Windows.Forms.AnchorStyles.Left)
     174                  | System.Windows.Forms.AnchorStyles.Right)));
     175      this.targetsListBox.FormattingEnabled = true;
     176      this.targetsListBox.Location = new System.Drawing.Point(8, 15);
     177      this.targetsListBox.Name = "targetsListBox";
     178      this.targetsListBox.Size = new System.Drawing.Size(153, 79);
     179      this.targetsListBox.TabIndex = 19;
     180      this.targetsListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.targetsListBox_ItemCheck);
     181      //
     182      // inputsListBox
     183      //
     184      this.inputsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     185                  | System.Windows.Forms.AnchorStyles.Left)
     186                  | System.Windows.Forms.AnchorStyles.Right)));
     187      this.inputsListBox.FormattingEnabled = true;
     188      this.inputsListBox.Location = new System.Drawing.Point(6, 15);
     189      this.inputsListBox.Name = "inputsListBox";
     190      this.inputsListBox.Size = new System.Drawing.Size(141, 79);
     191      this.inputsListBox.TabIndex = 21;
     192      this.inputsListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.inputsListBox_ItemCheck);
     193      //
     194      // autoregressiveCheckBox
     195      //
     196      this.autoregressiveCheckBox.Anchor = System.Windows.Forms.AnchorStyles.Top;
     197      this.autoregressiveCheckBox.AutoSize = true;
     198      this.autoregressiveCheckBox.Enabled = false;
     199      this.autoregressiveCheckBox.Location = new System.Drawing.Point(131, 83);
     200      this.autoregressiveCheckBox.Name = "autoregressiveCheckBox";
     201      this.autoregressiveCheckBox.Size = new System.Drawing.Size(15, 14);
     202      this.autoregressiveCheckBox.TabIndex = 22;
     203      this.autoregressiveCheckBox.UseVisualStyleBackColor = true;
     204      this.autoregressiveCheckBox.CheckedChanged += new System.EventHandler(this.autoregressiveCheckBox_CheckedChanged);
     205      //
     206      // targetsGroupBox
     207      //
     208      this.targetsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     209      this.targetsGroupBox.Controls.Add(this.targetsListBox);
     210      this.targetsGroupBox.Location = new System.Drawing.Point(29, 515);
     211      this.targetsGroupBox.Name = "targetsGroupBox";
     212      this.targetsGroupBox.Size = new System.Drawing.Size(167, 100);
     213      this.targetsGroupBox.TabIndex = 23;
     214      this.targetsGroupBox.TabStop = false;
     215      this.targetsGroupBox.Text = "Target variables";
     216      //
     217      // inputsGroupBox
     218      //
     219      this.inputsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     220      this.inputsGroupBox.Controls.Add(this.inputsListBox);
     221      this.inputsGroupBox.Location = new System.Drawing.Point(202, 515);
     222      this.inputsGroupBox.Name = "inputsGroupBox";
     223      this.inputsGroupBox.Size = new System.Drawing.Size(153, 100);
     224      this.inputsGroupBox.TabIndex = 24;
     225      this.inputsGroupBox.TabStop = false;
     226      this.inputsGroupBox.Text = "Input variables:";
     227      //
     228      // partitioningGroupBox
     229      //
     230      this.partitioningGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     231      this.partitioningGroupBox.Controls.Add(this.validationSamplesEndTextBox);
     232      this.partitioningGroupBox.Controls.Add(this.trainingLabel);
     233      this.partitioningGroupBox.Controls.Add(this.trainingSamplesStartTextBox);
     234      this.partitioningGroupBox.Controls.Add(this.trainingSamplesEndTextBox);
     235      this.partitioningGroupBox.Controls.Add(this.validationLabel);
     236      this.partitioningGroupBox.Controls.Add(this.testSamplesEndTextBox);
     237      this.partitioningGroupBox.Controls.Add(this.validationSamplesStartTextBox);
     238      this.partitioningGroupBox.Controls.Add(this.testSamplesStartTextBox);
     239      this.partitioningGroupBox.Controls.Add(this.testLabel);
     240      this.partitioningGroupBox.Location = new System.Drawing.Point(29, 409);
     241      this.partitioningGroupBox.Name = "partitioningGroupBox";
     242      this.partitioningGroupBox.Size = new System.Drawing.Size(326, 100);
     243      this.partitioningGroupBox.TabIndex = 25;
     244      this.partitioningGroupBox.TabStop = false;
     245      this.partitioningGroupBox.Text = "Data set partitions:";
     246      //
     247      // openFileDialog
     248      //
     249      this.openFileDialog.DefaultExt = "txt";
     250      this.openFileDialog.FileName = "txt";
     251      this.openFileDialog.Filter = "Text files|*.txt|All files|*.*";
     252      this.openFileDialog.Title = "Import data set from file";
     253      //
     254      // classificationRadioButton
     255      //
     256      this.classificationRadioButton.AutoSize = true;
     257      this.classificationRadioButton.Checked = true;
     258      this.classificationRadioButton.Location = new System.Drawing.Point(6, 16);
     259      this.classificationRadioButton.Name = "classificationRadioButton";
     260      this.classificationRadioButton.Size = new System.Drawing.Size(86, 17);
     261      this.classificationRadioButton.TabIndex = 28;
     262      this.classificationRadioButton.TabStop = true;
     263      this.classificationRadioButton.Text = "Classification";
     264      this.classificationRadioButton.UseVisualStyleBackColor = true;
     265      this.classificationRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
     266      //
     267      // regressionRadioButton
     268      //
     269      this.regressionRadioButton.AutoSize = true;
     270      this.regressionRadioButton.Location = new System.Drawing.Point(6, 39);
     271      this.regressionRadioButton.Name = "regressionRadioButton";
     272      this.regressionRadioButton.Size = new System.Drawing.Size(78, 17);
     273      this.regressionRadioButton.TabIndex = 29;
     274      this.regressionRadioButton.Text = "Regression";
     275      this.regressionRadioButton.UseVisualStyleBackColor = true;
     276      this.regressionRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
     277      //
     278      // timeSeriesRadioButton
     279      //
     280      this.timeSeriesRadioButton.AutoSize = true;
     281      this.timeSeriesRadioButton.Location = new System.Drawing.Point(6, 62);
     282      this.timeSeriesRadioButton.Name = "timeSeriesRadioButton";
     283      this.timeSeriesRadioButton.Size = new System.Drawing.Size(119, 17);
     284      this.timeSeriesRadioButton.TabIndex = 30;
     285      this.timeSeriesRadioButton.Text = "Time series forecast";
     286      this.timeSeriesRadioButton.UseVisualStyleBackColor = true;
     287      this.timeSeriesRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
     288      //
     289      // minTimeOffsetLabel
     290      //
     291      this.minTimeOffsetLabel.AutoSize = true;
     292      this.minTimeOffsetLabel.Enabled = false;
     293      this.minTimeOffsetLabel.Location = new System.Drawing.Point(38, 106);
     294      this.minTimeOffsetLabel.Name = "minTimeOffsetLabel";
     295      this.minTimeOffsetLabel.Size = new System.Drawing.Size(87, 13);
     296      this.minTimeOffsetLabel.TabIndex = 31;
     297      this.minTimeOffsetLabel.Text = "Min. Time Offset:";
     298      //
     299      // minTimeOffsetTextBox
     300      //
     301      this.minTimeOffsetTextBox.Enabled = false;
     302      this.minTimeOffsetTextBox.Location = new System.Drawing.Point(131, 103);
     303      this.minTimeOffsetTextBox.Name = "minTimeOffsetTextBox";
     304      this.minTimeOffsetTextBox.Size = new System.Drawing.Size(96, 20);
     305      this.minTimeOffsetTextBox.TabIndex = 32;
     306      this.minTimeOffsetTextBox.Validated += new System.EventHandler(this.timeOffsetTextBox_Validated);
     307      this.minTimeOffsetTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.timeOffsetTextBox_Validating);
     308      //
     309      // learningTaskGroupBox
     310      //
     311      this.learningTaskGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     312      this.learningTaskGroupBox.Controls.Add(this.autoregressiveLabel);
     313      this.learningTaskGroupBox.Controls.Add(this.classificationRadioButton);
     314      this.learningTaskGroupBox.Controls.Add(this.minTimeOffsetLabel);
     315      this.learningTaskGroupBox.Controls.Add(this.minTimeOffsetTextBox);
     316      this.learningTaskGroupBox.Controls.Add(this.maxTimeOffsetLabel);
     317      this.learningTaskGroupBox.Controls.Add(this.regressionRadioButton);
     318      this.learningTaskGroupBox.Controls.Add(this.maxTimeOffsetTextBox);
     319      this.learningTaskGroupBox.Controls.Add(this.timeSeriesRadioButton);
     320      this.learningTaskGroupBox.Controls.Add(this.autoregressiveCheckBox);
     321      this.learningTaskGroupBox.Location = new System.Drawing.Point(29, 621);
     322      this.learningTaskGroupBox.Name = "learningTaskGroupBox";
     323      this.learningTaskGroupBox.Size = new System.Drawing.Size(326, 163);
     324      this.learningTaskGroupBox.TabIndex = 35;
     325      this.learningTaskGroupBox.TabStop = false;
     326      this.learningTaskGroupBox.Text = "Learning task";
     327      //
     328      // autoregressiveLabel
     329      //
     330      this.autoregressiveLabel.AutoSize = true;
     331      this.autoregressiveLabel.Enabled = false;
     332      this.autoregressiveLabel.Location = new System.Drawing.Point(45, 83);
     333      this.autoregressiveLabel.Name = "autoregressiveLabel";
     334      this.autoregressiveLabel.Size = new System.Drawing.Size(80, 13);
     335      this.autoregressiveLabel.TabIndex = 35;
     336      this.autoregressiveLabel.Text = "Autoregressive:";
     337      //
     338      // maxTimeOffsetLabel
     339      //
     340      this.maxTimeOffsetLabel.AutoSize = true;
     341      this.maxTimeOffsetLabel.Enabled = false;
     342      this.maxTimeOffsetLabel.Location = new System.Drawing.Point(35, 132);
     343      this.maxTimeOffsetLabel.Name = "maxTimeOffsetLabel";
     344      this.maxTimeOffsetLabel.Size = new System.Drawing.Size(90, 13);
     345      this.maxTimeOffsetLabel.TabIndex = 33;
     346      this.maxTimeOffsetLabel.Text = "Max. Time Offset:";
     347      //
     348      // maxTimeOffsetTextBox
     349      //
     350      this.maxTimeOffsetTextBox.Enabled = false;
     351      this.maxTimeOffsetTextBox.Location = new System.Drawing.Point(131, 129);
     352      this.maxTimeOffsetTextBox.Name = "maxTimeOffsetTextBox";
     353      this.maxTimeOffsetTextBox.Size = new System.Drawing.Size(96, 20);
     354      this.maxTimeOffsetTextBox.TabIndex = 34;
     355      this.maxTimeOffsetTextBox.Validated += new System.EventHandler(this.timeOffsetTextBox_Validated);
     356      this.maxTimeOffsetTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.timeOffsetTextBox_Validating);
    145357      //
    146358      // datasetView
     
    154366      this.datasetView.Location = new System.Drawing.Point(3, 32);
    155367      this.datasetView.Name = "datasetView";
    156       this.datasetView.Size = new System.Drawing.Size(326, 221);
     368      this.datasetView.Size = new System.Drawing.Size(395, 371);
    157369      this.datasetView.TabIndex = 17;
    158       //
    159       // targetsListBox
    160       //
    161       this.targetsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    162                   | System.Windows.Forms.AnchorStyles.Left)
    163                   | System.Windows.Forms.AnchorStyles.Right)));
    164       this.targetsListBox.FormattingEnabled = true;
    165       this.targetsListBox.Location = new System.Drawing.Point(8, 15);
    166       this.targetsListBox.Name = "targetsListBox";
    167       this.targetsListBox.Size = new System.Drawing.Size(153, 79);
    168       this.targetsListBox.TabIndex = 19;
    169       //
    170       // inputsListBox
    171       //
    172       this.inputsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    173                   | System.Windows.Forms.AnchorStyles.Left)
    174                   | System.Windows.Forms.AnchorStyles.Right)));
    175       this.inputsListBox.FormattingEnabled = true;
    176       this.inputsListBox.Location = new System.Drawing.Point(6, 15);
    177       this.inputsListBox.Name = "inputsListBox";
    178       this.inputsListBox.Size = new System.Drawing.Size(141, 79);
    179       this.inputsListBox.TabIndex = 21;
    180       //
    181       // autoregressiveCheckBox
    182       //
    183       this.autoregressiveCheckBox.AutoSize = true;
    184       this.autoregressiveCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
    185       this.autoregressiveCheckBox.Location = new System.Drawing.Point(3, 471);
    186       this.autoregressiveCheckBox.Name = "autoregressiveCheckBox";
    187       this.autoregressiveCheckBox.Size = new System.Drawing.Size(102, 17);
    188       this.autoregressiveCheckBox.TabIndex = 22;
    189       this.autoregressiveCheckBox.Text = "Auto regressive:";
    190       this.autoregressiveCheckBox.UseVisualStyleBackColor = true;
    191       //
    192       // targetsGroupBox
    193       //
    194       this.targetsGroupBox.Controls.Add(this.targetsListBox);
    195       this.targetsGroupBox.Location = new System.Drawing.Point(3, 365);
    196       this.targetsGroupBox.Name = "targetsGroupBox";
    197       this.targetsGroupBox.Size = new System.Drawing.Size(167, 100);
    198       this.targetsGroupBox.TabIndex = 23;
    199       this.targetsGroupBox.TabStop = false;
    200       this.targetsGroupBox.Text = "Target variables";
    201       //
    202       // inputsGroupBox
    203       //
    204       this.inputsGroupBox.Controls.Add(this.inputsListBox);
    205       this.inputsGroupBox.Location = new System.Drawing.Point(176, 365);
    206       this.inputsGroupBox.Name = "inputsGroupBox";
    207       this.inputsGroupBox.Size = new System.Drawing.Size(153, 100);
    208       this.inputsGroupBox.TabIndex = 24;
    209       this.inputsGroupBox.TabStop = false;
    210       this.inputsGroupBox.Text = "Input variables:";
    211       //
    212       // partitioningGroupBox
    213       //
    214       this.partitioningGroupBox.Controls.Add(this.textBox2);
    215       this.partitioningGroupBox.Controls.Add(this.trainingLabel);
    216       this.partitioningGroupBox.Controls.Add(this.textBox1);
    217       this.partitioningGroupBox.Controls.Add(this.textBox4);
    218       this.partitioningGroupBox.Controls.Add(this.validationLabel);
    219       this.partitioningGroupBox.Controls.Add(this.textBox5);
    220       this.partitioningGroupBox.Controls.Add(this.textBox3);
    221       this.partitioningGroupBox.Controls.Add(this.textBox6);
    222       this.partitioningGroupBox.Controls.Add(this.testLabel);
    223       this.partitioningGroupBox.Location = new System.Drawing.Point(3, 259);
    224       this.partitioningGroupBox.Name = "partitioningGroupBox";
    225       this.partitioningGroupBox.Size = new System.Drawing.Size(326, 100);
    226       this.partitioningGroupBox.TabIndex = 25;
    227       this.partitioningGroupBox.TabStop = false;
    228       this.partitioningGroupBox.Text = "Data set partitions:";
    229370      //
    230371      // ProblemView
     
    232373      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    233374      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     375      this.Controls.Add(this.learningTaskGroupBox);
    234376      this.Controls.Add(this.partitioningGroupBox);
    235377      this.Controls.Add(this.inputsGroupBox);
    236378      this.Controls.Add(this.targetsGroupBox);
    237       this.Controls.Add(this.autoregressiveCheckBox);
    238379      this.Controls.Add(this.datasetView);
    239380      this.Controls.Add(this.importButton);
    240381      this.Name = "ProblemView";
    241       this.Size = new System.Drawing.Size(337, 569);
     382      this.Size = new System.Drawing.Size(406, 787);
    242383      this.targetsGroupBox.ResumeLayout(false);
    243384      this.inputsGroupBox.ResumeLayout(false);
    244385      this.partitioningGroupBox.ResumeLayout(false);
    245386      this.partitioningGroupBox.PerformLayout();
     387      this.learningTaskGroupBox.ResumeLayout(false);
     388      this.learningTaskGroupBox.PerformLayout();
    246389      this.ResumeLayout(false);
    247       this.PerformLayout();
    248390
    249391    }
     
    252394
    253395    private System.Windows.Forms.Button importButton;
    254     private System.Windows.Forms.TextBox textBox1;
     396    private System.Windows.Forms.TextBox trainingSamplesStartTextBox;
    255397    private System.Windows.Forms.Label trainingLabel;
    256     private System.Windows.Forms.TextBox textBox4;
    257     private System.Windows.Forms.TextBox textBox2;
    258     private System.Windows.Forms.TextBox textBox3;
     398    private System.Windows.Forms.TextBox trainingSamplesEndTextBox;
     399    private System.Windows.Forms.TextBox validationSamplesEndTextBox;
     400    private System.Windows.Forms.TextBox validationSamplesStartTextBox;
    259401    private System.Windows.Forms.Label validationLabel;
    260     private System.Windows.Forms.TextBox textBox5;
    261     private System.Windows.Forms.TextBox textBox6;
     402    private System.Windows.Forms.TextBox testSamplesEndTextBox;
     403    private System.Windows.Forms.TextBox testSamplesStartTextBox;
    262404    private System.Windows.Forms.Label testLabel;
    263405    private HeuristicLab.DataAnalysis.DatasetView datasetView;
     
    268410    private System.Windows.Forms.GroupBox inputsGroupBox;
    269411    private System.Windows.Forms.GroupBox partitioningGroupBox;
     412    private System.Windows.Forms.OpenFileDialog openFileDialog;
     413    private System.Windows.Forms.RadioButton classificationRadioButton;
     414    private System.Windows.Forms.RadioButton regressionRadioButton;
     415    private System.Windows.Forms.RadioButton timeSeriesRadioButton;
     416    private System.Windows.Forms.Label minTimeOffsetLabel;
     417    private System.Windows.Forms.TextBox minTimeOffsetTextBox;
     418    private System.Windows.Forms.GroupBox learningTaskGroupBox;
     419    private System.Windows.Forms.Label maxTimeOffsetLabel;
     420    private System.Windows.Forms.TextBox maxTimeOffsetTextBox;
     421    private System.Windows.Forms.Label autoregressiveLabel;
    270422  }
    271423}
  • trunk/sources/HeuristicLab.CEDMA.Core/ProblemView.cs

    r992 r1287  
    2929using System.Windows.Forms;
    3030using HeuristicLab.Core;
     31using HeuristicLab.DataAnalysis;
     32using System.Diagnostics;
    3133
    3234namespace HeuristicLab.CEDMA.Core {
     
    3739      this.problem = problem;
    3840      InitializeComponent();
    39     }
     41      UpdateControls();
     42    }
     43
     44    protected override void UpdateControls() {
     45      base.UpdateControls();
     46      datasetView.Dataset = problem.DataSet;
     47      trainingSamplesStartTextBox.Text = problem.TrainingSamplesStart.ToString();
     48      trainingSamplesEndTextBox.Text = problem.TrainingSamplesEnd.ToString();
     49      validationSamplesStartTextBox.Text = problem.ValidationSamplesStart.ToString();
     50      validationSamplesEndTextBox.Text = problem.ValidationSamplesEnd.ToString();
     51      testSamplesStartTextBox.Text = problem.TestSamplesStart.ToString();
     52      testSamplesEndTextBox.Text = problem.TestSamplesEnd.ToString();
     53      minTimeOffsetTextBox.Text = problem.MinTimeOffset.ToString();
     54      maxTimeOffsetTextBox.Text = problem.MaxTimeOffset.ToString();
     55      autoregressiveCheckBox.Checked = problem.AutoRegressive;
     56      switch (problem.LearningTask) {
     57        case LearningTask.Classification: classificationRadioButton.Checked = true; break;
     58        case LearningTask.Regression: regressionRadioButton.Checked = true; break;
     59        case LearningTask.TimeSeries: timeSeriesRadioButton.Checked = true; break;
     60      }
     61      targetsListBox.Items.Clear();
     62      inputsListBox.Items.Clear();
     63      for (int i = 0; i < problem.DataSet.Columns; i++) {
     64        targetsListBox.Items.Add(problem.DataSet.GetVariableName(i), problem.AllowedTargetVariables.Contains(i));
     65        inputsListBox.Items.Add(problem.DataSet.GetVariableName(i), problem.AllowedInputVariables.Contains(i));
     66      }
     67    }
     68
     69    private void importButton_Click(object sender, EventArgs e) {
     70      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
     71        DatasetParser parser = new DatasetParser();
     72        bool success = false;
     73        try {
     74          try {
     75            parser.Import(openFileDialog.FileName, true);
     76            success = true;
     77          }
     78          catch (DataFormatException ex) {
     79            ShowWarningMessageBox(ex);
     80            // not possible to parse strictly => clear and try to parse non-strict
     81            parser.Reset();
     82            parser.Import(openFileDialog.FileName, false);
     83            success = true;
     84          }
     85        }
     86        catch (DataFormatException ex) {
     87          // if the non-strict parsing also failed then show the exception
     88          ShowErrorMessageBox(ex);
     89        }
     90        if (success) {
     91          Dataset dataset = (Dataset)problem.DataSet;
     92          dataset.Rows = parser.Rows;
     93          dataset.Columns = parser.Columns;
     94          for (int i = 0; i < parser.VariableNames.Length; i++) {
     95            dataset.SetVariableName(i, parser.VariableNames[i]);
     96          }
     97          dataset.Name = parser.ProblemName;
     98          dataset.Samples = new double[dataset.Rows * dataset.Columns];
     99          Array.Copy(parser.Samples, dataset.Samples, dataset.Columns * dataset.Rows);
     100          datasetView.Dataset = problem.DataSet;
     101
     102          problem.TrainingSamplesStart = parser.TrainingSamplesStart;
     103          problem.ValidationSamplesEnd = parser.TrainingSamplesStart;
     104          problem.TrainingSamplesEnd = parser.TrainingSamplesEnd;
     105          problem.ValidationSamplesStart = parser.ValidationSamplesStart;
     106          problem.ValidationSamplesEnd = parser.ValidationSamplesEnd;
     107          problem.TestSamplesStart = parser.TestSamplesStart;
     108          problem.TestSamplesEnd = parser.TestSamplesEnd;
     109          problem.AllowedTargetVariables.Add(parser.TargetVariable);
     110
     111          List<int> nonInputVariables = parser.NonInputVariables;
     112          for (int i = 0; i < dataset.Columns; i++) {
     113            if (!nonInputVariables.Contains(i)) problem.AllowedInputVariables.Add(i);
     114          }
     115          Refresh();
     116        }
     117      }
     118
     119    }
     120
     121    private void targetsListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
     122      if (e.NewValue == CheckState.Checked && !problem.AllowedTargetVariables.Contains(e.Index))
     123        problem.AllowedTargetVariables.Add(e.Index);
     124      else if (e.NewValue == CheckState.Unchecked && problem.AllowedTargetVariables.Contains(e.Index))
     125        problem.AllowedTargetVariables.Remove(e.Index);
     126    }
     127
     128    private void inputsListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
     129      if (e.NewValue == CheckState.Checked && !problem.AllowedInputVariables.Contains(e.Index))
     130        problem.AllowedInputVariables.Add(e.Index);
     131      else if (e.NewValue == CheckState.Unchecked && problem.AllowedInputVariables.Contains(e.Index))
     132        problem.AllowedInputVariables.Remove(e.Index);
     133    }
     134
     135    private void autoregressiveCheckBox_CheckedChanged(object sender, EventArgs e) {
     136      problem.AutoRegressive = autoregressiveCheckBox.Checked;
     137    }
     138
     139    private void samplesTextBox_Validating(object sender, CancelEventArgs e) {
     140      try {
     141        int trainingStart = int.Parse(trainingSamplesStartTextBox.Text);
     142        int trainingEnd = int.Parse(trainingSamplesEndTextBox.Text);
     143        int validationStart = int.Parse(validationSamplesStartTextBox.Text);
     144        int validationEnd = int.Parse(validationSamplesEndTextBox.Text);
     145        int testStart = int.Parse(testSamplesStartTextBox.Text);
     146        int testEnd = int.Parse(testSamplesEndTextBox.Text);
     147        if (trainingStart < 0 || validationStart < 0 || testStart < 0 ||
     148          trainingEnd >= problem.DataSet.Rows || validationEnd >= problem.DataSet.Rows || testEnd >= problem.DataSet.Rows ||
     149          trainingStart >= trainingEnd ||
     150          validationStart >= validationEnd ||
     151          testStart >= testEnd ||
     152          IsOverlapping(trainingStart, trainingEnd, validationStart, validationEnd) ||
     153          IsOverlapping(trainingStart, trainingEnd, testStart, testEnd) ||
     154          IsOverlapping(validationStart, validationEnd, testStart, testEnd))
     155          ColorSamplesTextBoxes(Color.Red);
     156        else
     157          ColorSamplesTextBoxes(Color.White);
     158      }
     159      catch (FormatException ex) {
     160        ColorSamplesTextBoxes(Color.Red);
     161      }
     162    }
     163
     164    private void samplesTextBox_Validated(object sender, EventArgs e) {
     165      problem.TrainingSamplesStart = int.Parse(trainingSamplesStartTextBox.Text);
     166      problem.TrainingSamplesEnd = int.Parse(trainingSamplesEndTextBox.Text);
     167      problem.ValidationSamplesStart = int.Parse(validationSamplesStartTextBox.Text);
     168      problem.ValidationSamplesEnd = int.Parse(validationSamplesEndTextBox.Text);
     169      problem.TestSamplesStart = int.Parse(testSamplesStartTextBox.Text);
     170      problem.TestSamplesEnd = int.Parse(testSamplesEndTextBox.Text);
     171    }
     172
     173    private void ColorSamplesTextBoxes(Color color) {
     174      trainingSamplesStartTextBox.BackColor = color;
     175      trainingSamplesEndTextBox.BackColor = color;
     176      validationSamplesStartTextBox.BackColor = color;
     177      validationSamplesEndTextBox.BackColor = color;
     178      testSamplesStartTextBox.BackColor = color;
     179      testSamplesEndTextBox.BackColor = color;
     180    }
     181
     182    private bool IsOverlapping(int x0, int y0, int x1, int y1) {
     183      Trace.Assert(x0 <= y0 && x1 <= y1);
     184      int tmp;
     185      // make sure that x0,y0 is the left interval
     186      if (x1 < x0) {
     187        tmp = x1;
     188        x1 = x0;
     189        x0 = tmp;
     190        tmp = y1;
     191        y1 = y0;
     192        y0 = tmp;
     193      }
     194      return y0 > x1;
     195    }
     196    private void ShowWarningMessageBox(Exception ex) {
     197      MessageBox.Show(ex.Message,
     198                      "Warning - " + ex.GetType().Name,
     199                      MessageBoxButtons.OK,
     200                      MessageBoxIcon.Warning);
     201    }
     202    private void ShowErrorMessageBox(Exception ex) {
     203      MessageBox.Show(BuildErrorMessage(ex),
     204                      "Error - " + ex.GetType().Name,
     205                      MessageBoxButtons.OK,
     206                      MessageBoxIcon.Error);
     207    }
     208    private string BuildErrorMessage(Exception ex) {
     209      StringBuilder sb = new StringBuilder();
     210      sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     211
     212      while (ex.InnerException != null) {
     213        ex = ex.InnerException;
     214        sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
     215      }
     216      return sb.ToString();
     217    }
     218
     219    #region gui events
     220    private void radioButton_CheckedChanged(object sender, EventArgs e) {
     221      minTimeOffsetLabel.Enabled = timeSeriesRadioButton.Checked;
     222      minTimeOffsetTextBox.Enabled = timeSeriesRadioButton.Checked;
     223      maxTimeOffsetLabel.Enabled = timeSeriesRadioButton.Checked;
     224      maxTimeOffsetTextBox.Enabled = timeSeriesRadioButton.Checked;
     225      autoregressiveCheckBox.Enabled = timeSeriesRadioButton.Checked;
     226      autoregressiveLabel.Enabled = timeSeriesRadioButton.Checked;
     227      if (timeSeriesRadioButton.Checked) problem.LearningTask = LearningTask.TimeSeries;
     228      else if (classificationRadioButton.Checked) problem.LearningTask = LearningTask.Classification;
     229      else if (regressionRadioButton.Checked) problem.LearningTask = LearningTask.Regression;
     230    }
     231
     232    private void timeOffsetTextBox_Validating(object sender, CancelEventArgs e) {
     233      int min, max;
     234      e.Cancel = !int.TryParse(minTimeOffsetTextBox.Text, out min);
     235      e.Cancel = !int.TryParse(maxTimeOffsetTextBox.Text, out max);
     236      e.Cancel = min > max;
     237    }
     238    private void timeOffsetTextBox_Validated(object sender, EventArgs e) {
     239      problem.MinTimeOffset = int.Parse(minTimeOffsetTextBox.Text);
     240      problem.MaxTimeOffset = int.Parse(maxTimeOffsetTextBox.Text);
     241    }
     242    #endregion
    40243  }
    41244}
  • trunk/sources/HeuristicLab.CEDMA.Core/ProblemView.resx

    r992 r1287  
    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>
  • trunk/sources/HeuristicLab.CEDMA.Core/Results.cs

    r1075 r1287  
    3636
    3737namespace HeuristicLab.CEDMA.Core {
    38   public class Results : IViewable, IEnumerable<Record> {
    39     private Dictionary<Record, Dataset> datasets;
     38  public class Results : ItemBase {
     39    private string[] categoricalVariables = null;
     40    public string[] CategoricalVariables {
     41      get {
     42        if (categoricalVariables == null) {
     43          LoadModelAttributes();
     44        }
     45        return categoricalVariables;
     46      }
     47    }
     48
     49    private string[] ordinalVariables = null;
     50    public string[] OrdinalVariables {
     51      get {
     52        if (ordinalVariables == null) {
     53          LoadModelAttributes();
     54        }
     55        return ordinalVariables;
     56      }
     57    }
    4058
    4159    private IStore store;
     
    4765    }
    4866
    49     private void ReloadList() {
    50       var results = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeGeneticProgrammingFunctionTree))
    51       .Select(x => store.Select(new SelectFilter(
    52         new Entity[] { new Entity(x.Subject.Uri) },
    53         new Entity[] { Ontology.PredicateModelAttribute },
    54           new Resource[] { Ontology.AnyEntity })));
     67    private Entity dataSetEntity;
    5568
    56       Random random = new Random();
    57       foreach(Statement[] ss in results) {
    58         if(ss.Length > 0) {
    59           Record r = new Record(this, ss[0].Subject.Uri);
    60           r.Set(Record.X_JITTER, random.NextDouble() * 2.0 - 1.0);
    61           r.Set(Record.Y_JITTER, random.NextDouble() * 2.0 - 1.0);
    62           foreach(Statement s in ss) {
    63             string varName;
    64             predicateToVariableName.TryGetValue(s.Predicate, out varName);
    65             if(varName != null) {
    66               if(varName == Record.TREE_HEIGHT || varName == Record.TREE_SIZE || varName == Record.TARGET_VARIABLE) {
    67                 r.Set(varName, (double)(int)((Literal)s.Property).Value);
    68               } else {
    69                 r.Set(varName, (double)((Literal)s.Property).Value);
    70               }
     69    public Results(IStore store) {
     70      this.store = store;
     71    }
     72
     73    internal void FilterDataSet(Entity entity) {
     74      this.dataSetEntity = entity;
     75    }
     76
     77    private List<ResultsEntry> entries = null;
     78    private bool cached = false;
     79    public IEnumerable<ResultsEntry> GetEntries() {
     80      if (!cached)
     81        return SelectRows();
     82      return entries.AsEnumerable();
     83    }
     84
     85    private IEnumerable<ResultsEntry> SelectRows() {
     86      if (store == null) yield break;
     87      entries = new List<ResultsEntry>();
     88      var results = store.Query("<" + dataSetEntity + "> <" + Ontology.PredicateHasModel + "> ?Model ." + Environment.NewLine +
     89        "?Model ?Attribute ?Value .")
     90        .GroupBy(x => (Entity)x.Get("Model"));
     91      foreach (var modelBindings in results) {
     92        ResultsEntry entry = new ResultsEntry(modelBindings.Key.Uri);
     93        foreach (var binding in modelBindings) {
     94          if (binding.Get("Value") is Literal) {
     95            string name = ((Entity)binding.Get("Attribute")).Uri.Replace(Ontology.CedmaNameSpace, "");
     96            if (entry.Get(name) == null) {
     97              object value = ((Literal)binding.Get("Value")).Value;
     98              entry.Set(name, value);
    7199            }
    72100          }
    73           lock(records) {
    74             records.Add(r);
    75           }
    76           FireRecordAdded(r);
    77101        }
     102        entries.Add(entry);
     103        yield return entry;
    78104      }
     105
    79106      FireChanged();
     107      cached = true;
    80108    }
    81109
    82     public Results(IStore store)
    83       : base() {
    84       this.store = store;
    85       records = new List<Record>();
    86       datasets = new Dictionary<Record, Dataset>();
    87       //predicateToVariableName = new Dictionary<Entity, string>();
    88       //predicateToVariableName[targetVariablePredicate] = Record.TARGET_VARIABLE;
    89       //predicateToVariableName[treeSizePredicate] = Record.TREE_SIZE;
    90       //predicateToVariableName[treeHeightPredicate] = Record.TREE_HEIGHT;
    91       //predicateToVariableName[selectionPressurePredicate] = Record.SELECTIONPRESSURE;
    92       //predicateToVariableName[trainingMAPEPredicate] = Record.MAPE_TRAINING;
    93       //predicateToVariableName[validationMAPEPredicate] = Record.MAPE_VALIDATION;
    94       //predicateToVariableName[testMAPEPredicate] = Record.MAPE_TEST;
    95       //predicateToVariableName[trainingR2Predicate] = Record.R2_TRAINING;
    96       //predicateToVariableName[validationR2Predicate] = Record.R2_VALIDATION;
    97       //predicateToVariableName[testR2Predicate] = Record.R2_TEST;
     110    internal IEnumerable<string> SelectModelAttributes() {
     111      return CategoricalVariables.Concat(OrdinalVariables);
    98112    }
    99113
    100     public override IView CreateView() {
    101       return new ResultsView(this);
     114    private void LoadModelAttributes() {
     115      this.ordinalVariables =
     116        store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeOrdinalAttribute + "> .")
     117        .Select(s => ((Entity)s.Get("ModelAttribute")).Uri.Replace(Ontology.CedmaNameSpace, ""))
     118        .ToArray();
     119      this.categoricalVariables =
     120        store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeCategoricalAttribute + "> .")
     121        .Select(s => ((Entity)s.Get("ModelAttribute")).Uri.Replace(Ontology.CedmaNameSpace, ""))
     122        .ToArray();
    102123    }
    103 
    104     //internal void OpenModel(Record record) {
    105     //  IList<Statement> modelResults = store.Select(new Statement(new Entity(record.Uri), Ontology.PredicateSerializedData, Ontology.AnyEntity));
    106     //  if(modelResults.Count == 1) {
    107     //    string rawData = ((SerializedLiteral)modelResults[0].Property).RawData;
    108     //    XmlDocument doc = new XmlDocument();
    109     //    doc.LoadXml(rawData);
    110     //    IFunctionTree tree = (IFunctionTree)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>());
    111     //    int targetVariable = (int)record.Get(Record.TARGET_VARIABLE);
    112     //    Dataset dataset = GetDataset(record);
    113 
    114     //    ModelView modelView = new ModelView(record, dataset, tree, targetVariable);
    115     //    PluginManager.ControlManager.ShowControl(modelView);
    116     //  }
    117     //}
    118 
    119     //private Dataset GetDataset(Record record) {
    120     //  if(!datasets.ContainsKey(record)) {
    121     //    IList<Statement> result = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateHasModel, new Entity(record.Uri)));
    122     //    if(result.Count == 1) {
    123     //      IList<Statement> datasetResult = store.Select(new Statement(result[0].Subject, Ontology.PredicateSerializedData, Ontology.AnyEntity));
    124     //      if(datasetResult.Count == 1) {
    125     //        string rawData = ((SerializedLiteral)datasetResult[0].Property).RawData;
    126     //        XmlDocument doc = new XmlDocument();
    127     //        doc.LoadXml(rawData);
    128     //        Dataset dataset = (Dataset)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>());
    129     //        datasets.Add(record, dataset);
    130     //      }
    131     //    }
    132     //  }
    133     //  return datasets[record];
    134     //}
    135 
    136     //internal void OpenAlgorithm(Record record) {
    137     //  IList<Statement> generatedBy = store.Select(new Statement(new Entity(record.Uri), Ontology.PredicateGeneratedBy, Ontology.AnyEntity));
    138     //  if(generatedBy.Count == 1) {
    139     //    IList<Statement> algoResult = store.Select(new Statement((Entity)generatedBy[0].Property, Ontology.PredicateSerializedData, Ontology.AnyEntity));
    140     //    if(algoResult.Count == 1) {
    141     //      string rawData = ((SerializedLiteral)algoResult[0].Property).RawData;
    142     //      XmlDocument doc = new XmlDocument();
    143     //      doc.LoadXml(rawData);
    144     //      IItem algo = (IItem)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>());
    145     //      PluginManager.ControlManager.ShowControl(algo.CreateView());
    146     //    }
    147     //  }
    148     //}
    149 
    150     internal void FilterDataSet(Entity entity) {
    151 
    152     }
    153 
    154     #region IEnumerable<Record> Members
    155 
    156     public IEnumerator<Record> GetEnumerator() {
    157       throw new NotImplementedException();
    158     }
    159 
    160     #endregion
    161 
    162     #region IEnumerable Members
    163 
    164     IEnumerator IEnumerable.GetEnumerator() {
    165       return this.GetEnumerator();
    166     }
    167 
    168     #endregion
    169124  }
    170125}
  • trunk/sources/HeuristicLab.CEDMA.Core/TableResultsView.Designer.cs

    r1106 r1287  
    3939      this.dataGridView.Size = new System.Drawing.Size(450, 459);
    4040      this.dataGridView.TabIndex = 0;
     41      this.dataGridView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.dataGridView_MouseDoubleClick);
     42      this.dataGridView.SelectionChanged += new System.EventHandler(this.dataGridView_SelectionChanged);
    4143      //
    4244      // TableResultsView
  • trunk/sources/HeuristicLab.CEDMA.Core/TableResultsView.cs

    r1106 r1287  
    99using HeuristicLab.Core;
    1010using HeuristicLab.CEDMA.Core;
     11using HeuristicLab.PluginInfrastructure;
     12using HeuristicLab.CEDMA.DB.Interfaces;
    1113
    1214namespace HeuristicLab.CEDMA.Core {
    13   public partial class TableResultsView : ViewBase, IResultsView {
    14     private Results results;
    15     public TableResultsView() {
     15
     16  public partial class TableResultsView : ViewBase {
     17    private Results Results {
     18      get { return (Results)Item; }
     19      set { Item = value; }
     20    }
     21    private bool suppressEvents;
     22    public TableResultsView(Results results) {
     23      suppressEvents = false;
    1624      InitializeComponent();
     25      Results = results;
     26      results.Changed += new EventHandler(results_Changed);
    1727    }
    1828
    19     public Control Control {
    20       get { return this; }
    21     }
    22 
    23     public void ShowResults(Results results) {
    24       this.results = results;
     29    void results_Changed(object sender, EventArgs e) {
     30      if (suppressEvents) return;
    2531      UpdateControls();
    2632    }
    2733
    2834    protected override void UpdateControls() {
    29       base.UpdateControls();
    30       if (results == null) return;
    31       List<string> columnNames = new List<string>();
    32       columnNames.AddRange(Results.CategoricalVariables);
    33       columnNames.AddRange(Results.OrdinalVariables);
     35      suppressEvents = true;
    3436      dataGridView.Rows.Clear();
    3537      dataGridView.Columns.Clear();
    36       foreach (string varName in columnNames) {
    37         dataGridView.Columns.Add(varName, varName);
     38      List<string> attributeNames = Results.SelectModelAttributes().ToList();
     39      foreach (var attribute in attributeNames) {
     40        dataGridView.Columns.Add(attribute, attribute);
    3841      }
    3942
    40       foreach (object[] row in results.SelectRows(columnNames)) {
    41         dataGridView.Rows.Add(row);
     43      var entries = Results.GetEntries();
     44      foreach (var entry in entries) {
     45        int rowIndex = dataGridView.Rows.Add();
     46        dataGridView.Rows[rowIndex].Tag = entry;
     47        foreach (string attrName in attributeNames) {
     48          dataGridView.Rows[rowIndex].Cells[attrName].Value = entry.Get(attrName);
     49        }
     50        if (entry.Selected) dataGridView.Rows[rowIndex].Selected = true;
    4251      }
    4352      dataGridView.Update();
     53      suppressEvents = false;
     54    }
     55
     56    private void dataGridView_SelectionChanged(object sender, EventArgs e) {
     57      if (suppressEvents) return;
     58      foreach (DataGridViewRow row in dataGridView.Rows) {
     59        ((ResultsEntry)row.Tag).Selected = row.Selected;
     60      }
     61      suppressEvents = true;
     62      Results.FireChanged();
     63      suppressEvents = false;
     64    }
     65
     66    private void dataGridView_MouseDoubleClick(object sender, MouseEventArgs e) {
     67      if (e.Button == MouseButtons.Left && e.Clicks == 2) {
     68        DataGridView.HitTestInfo hitInfo = dataGridView.HitTest(e.X, e.Y);
     69        ResultsEntry entry = (ResultsEntry)dataGridView.Rows[hitInfo.RowIndex].Tag;
     70        string serializedData =  (string)entry.Get(Ontology.PredicateSerializedData.Uri.Replace(Ontology.CedmaNameSpace, ""));
     71        var model = (IItem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String(serializedData));
     72        PluginManager.ControlManager.ShowControl(model.CreateView());
     73      }
    4474    }
    4575  }
     76
     77  public class TablesResultsViewFactory : IResultsViewFactory {
     78    #region IResultsViewFactory Members
     79
     80    public string Name {
     81      get { return "Table"; }
     82    }
     83
     84    public IControl CreateView(Results results) {
     85      return new TableResultsView(results);
     86    }
     87
     88    #endregion
     89  }
    4690}
Note: See TracChangeset for help on using the changeset viewer.