Changeset 1287 for trunk/sources/HeuristicLab.CEDMA.Core
- Timestamp:
- 03/08/09 12:48:18 (15 years ago)
- 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 29 29 using System.ServiceModel.Description; 30 30 using HeuristicLab.CEDMA.DB.Interfaces; 31 using HeuristicLab.CEDMA.Charting;32 31 33 32 namespace HeuristicLab.CEDMA.Core { 34 33 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; 40 37 private string serverUri; 41 38 public string ServerUri { … … 43 40 } 44 41 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; } 55 44 } 56 45 57 46 public Console() 58 47 : base() { 59 agentList = new AgentList(); 60 resultsList = new ResultList(); 61 operatorLibary = new DatabaseOperatorLibrary(); 48 dataSetList = new DataSetList(); 62 49 } 63 50 … … 88 75 private void ResetConnection() { 89 76 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; 102 84 } 103 85 #endregion -
trunk/sources/HeuristicLab.CEDMA.Core/ConsoleEditor.cs
r561 r1287 36 36 private System.Windows.Forms.Label uriLabel; 37 37 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; 44 39 private Console console; 45 40 … … 47 42 InitializeComponent(); 48 43 this.console = console; 44 serverPanel.Enabled = false; 49 45 } 50 46 47 #region autogenerated code 51 48 private void InitializeComponent() { 52 49 this.uriTextBox = new System.Windows.Forms.TextBox(); 53 50 this.uriLabel = new System.Windows.Forms.Label(); 54 51 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(); 61 53 this.SuspendLayout(); 62 54 // … … 87 79 this.connectButton.Click += new System.EventHandler(this.connectButton_Click); 88 80 // 89 // openOpLibButton81 // serverPanel 90 82 // 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; 148 90 // 149 91 // ConsoleEditor 150 92 // 151 93 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); 158 95 this.Controls.Add(this.connectButton); 159 96 this.Controls.Add(this.uriLabel); … … 166 103 } 167 104 105 #endregion 106 168 107 private void connectButton_Click(object sender, EventArgs e) { 169 108 try { 170 109 console.Connect(uriTextBox.Text); 171 110 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); 175 116 } catch(CommunicationException ex) { 176 117 MessageBox.Show("Exception while trying to connect to " + uriTextBox.Text + "\n" + ex.Message); 177 118 } 178 119 } 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 }196 120 } 197 121 } -
trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs
r957 r1287 30 30 31 31 namespace HeuristicLab.CEDMA.Core { 32 public class DataSet {32 public class DataSet : IViewable { 33 33 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 36 46 private Problem problem; 37 38 47 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 } 40 64 } 41 65 42 66 public DataSet() 43 67 : base() { 44 problem = new Problem(); 68 guid = Guid.NewGuid(); 69 name = "Data set"; 45 70 } 46 71 47 public DataSet(IStore store, long id)72 public DataSet(IStore store, Entity dataSetEntity) 48 73 : this() { 49 74 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(); 55 77 } 56 78 57 79 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))); 63 84 } 64 85 … … 66 87 return new DataSetView(this); 67 88 } 89 90 internal Results GetResults() { 91 Results results = new Results(Store); 92 results.FilterDataSet(new Entity(Ontology.CedmaNameSpace + Guid)); 93 return results; 94 } 68 95 } 69 96 } -
trunk/sources/HeuristicLab.CEDMA.Core/DataSetList.cs
r957 r1287 41 41 store = value; 42 42 Action reload = ReloadList; 43 lock (dataSetList) {43 lock (dataSetList) { 44 44 dataSetList.Clear(); 45 45 } … … 58 58 59 59 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 } 74 77 } 75 78 76 79 public IEnumerator<DataSet> GetEnumerator() { 77 80 List<DataSet> dataSets = new List<DataSet>(); 78 lock (dataSets) {81 lock (dataSets) { 79 82 dataSets.AddRange(dataSetList); 80 83 } … … 85 88 return GetEnumerator(); 86 89 } 90 91 public void Add(DataSet dataSet) { 92 dataSetList.Add(dataSet); 93 } 87 94 } 88 95 } -
trunk/sources/HeuristicLab.CEDMA.Core/DataSetListView.Designer.cs
r957 r1287 48 48 /// </summary> 49 49 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(); 51 52 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(); 54 55 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();59 56 this.splitContainer1.Panel1.SuspendLayout(); 60 57 this.splitContainer1.Panel2.SuspendLayout(); 61 58 this.splitContainer1.SuspendLayout(); 62 this.agentsGroupBox.SuspendLayout(); 63 this.entryContextMenuStrip.SuspendLayout(); 59 this.dataSetsGroupBox.SuspendLayout(); 64 60 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); 65 83 // 66 84 // splitContainer1 … … 75 93 // splitContainer1.Panel1 76 94 // 77 this.splitContainer1.Panel1.Controls.Add(this. agentsGroupBox);95 this.splitContainer1.Panel1.Controls.Add(this.dataSetsGroupBox); 78 96 // 79 97 // splitContainer1.Panel2 … … 84 102 this.splitContainer1.TabIndex = 0; 85 103 // 86 // agentsGroupBox104 // dataSetsGroupBox 87 105 // 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"; 96 114 // 97 // agentTreeView115 // dataSetsListView 98 116 // 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); 106 126 // 107 127 // detailsGroupBox … … 115 135 this.detailsGroupBox.Text = "&Details"; 116 136 // 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 154 138 // 155 139 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); … … 157 141 this.Controls.Add(this.addButton); 158 142 this.Controls.Add(this.splitContainer1); 159 this.Name = " AgentListView";143 this.Name = "DataSetListView"; 160 144 this.Size = new System.Drawing.Size(276, 184); 161 145 this.splitContainer1.Panel1.ResumeLayout(false); 162 146 this.splitContainer1.Panel2.ResumeLayout(false); 163 147 this.splitContainer1.ResumeLayout(false); 164 this.agentsGroupBox.ResumeLayout(false); 165 this.entryContextMenuStrip.ResumeLayout(false); 148 this.dataSetsGroupBox.ResumeLayout(false); 166 149 this.ResumeLayout(false); 167 150 … … 171 154 172 155 private System.Windows.Forms.SplitContainer splitContainer1; 173 private System.Windows.Forms.GroupBox agentsGroupBox;156 private System.Windows.Forms.GroupBox dataSetsGroupBox; 174 157 private System.Windows.Forms.GroupBox detailsGroupBox; 175 158 private System.Windows.Forms.Button addButton; 176 private TreeView agentTreeView;177 159 private Button refreshButton; 178 private ContextMenuStrip entryContextMenuStrip; 179 private ToolStripMenuItem exportAllResultsToolStripMenuItem; 160 private ListView dataSetsListView; 180 161 } 181 162 } -
trunk/sources/HeuristicLab.CEDMA.Core/DataSetListView.cs
r957 r1287 31 31 namespace HeuristicLab.CEDMA.Core { 32 32 public partial class DataSetListView : ViewBase { 33 public DataSetList DataSetList {33 public DataSetList DataSetList { 34 34 get { return (DataSetList)Item; } 35 35 set { base.Item = value; } … … 47 47 48 48 void dataSetList_Changed(object sender, EventArgs e) { 49 UpdateControls(); 49 if (InvokeRequired) Invoke((EventHandler)dataSetList_Changed, sender, e); 50 else UpdateControls(); 50 51 } 51 52 … … 56 57 if(DataSetList == null) { 57 58 Caption = "Data Sets View"; 58 agentTreeView.Enabled = false;59 dataSetsListView.Enabled = false; 59 60 } else { 60 agentTreeView.Enabled = true;61 agentTreeView.Nodes.Clear();61 dataSetsListView.Enabled = true; 62 dataSetsListView.Items.Clear(); 62 63 foreach(DataSet dataSet in DataSetList) { 63 TreeNode node = new TreeNode();64 ListViewItem node = new ListViewItem(); 64 65 node.Text = dataSet.Name; 65 66 node.Tag = dataSet; 66 node.Nodes.Add("dummy"); 67 node.ContextMenuStrip = entryContextMenuStrip; 68 agentTreeView.Nodes.Add(node); 67 dataSetsListView.Items.Add(node); 69 68 } 70 69 } … … 73 72 #region Button Events 74 73 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(); 76 78 } 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; 86 86 Control control = (Control)viewable.CreateView(); 87 87 detailsGroupBox.Controls.Add(control); … … 90 90 } 91 91 } 92 #endregion 93 92 94 93 95 private void refreshButton_Click(object sender, EventArgs e) { -
trunk/sources/HeuristicLab.CEDMA.Core/DataSetListView.resx
r957 r1287 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </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>123 120 </root> -
trunk/sources/HeuristicLab.CEDMA.Core/DataSetView.Designer.cs
r957 r1287 46 46 private void InitializeComponent() { 47 47 this.editorGroupBox = new System.Windows.Forms.GroupBox(); 48 this.saveButton = new System.Windows.Forms.Button();49 48 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(); 50 52 this.SuspendLayout(); 51 53 // … … 57 59 this.editorGroupBox.Location = new System.Drawing.Point(0, 3); 58 60 this.editorGroupBox.Name = "editorGroupBox"; 59 this.editorGroupBox.Size = new System.Drawing.Size( 274, 119);61 this.editorGroupBox.Size = new System.Drawing.Size(381, 218); 60 62 this.editorGroupBox.TabIndex = 0; 61 63 this.editorGroupBox.TabStop = false; 62 64 this.editorGroupBox.Text = "&Editor:"; 63 65 // 64 // saveButton65 //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 //75 66 // activateButton 76 67 // 77 68 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); 79 70 this.activateButton.Name = "activateButton"; 80 71 this.activateButton.Size = new System.Drawing.Size(75, 23); 81 72 this.activateButton.TabIndex = 2; 82 this.activateButton.Text = "& Start";73 this.activateButton.Text = "&Activate"; 83 74 this.activateButton.UseVisualStyleBackColor = true; 84 75 this.activateButton.Click += new System.EventHandler(this.activateButton_Click); 85 76 // 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 87 107 // 88 108 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 89 109 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); 90 113 this.Controls.Add(this.activateButton); 91 this.Controls.Add(this.saveButton);92 114 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); 95 117 this.ResumeLayout(false); 96 118 … … 100 122 101 123 private System.Windows.Forms.GroupBox editorGroupBox; 102 private System.Windows.Forms.Button saveButton;103 124 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; 104 128 } 105 129 } -
trunk/sources/HeuristicLab.CEDMA.Core/DataSetView.cs
r957 r1287 25 25 using System.Drawing; 26 26 using System.Data; 27 using System.Linq; 27 28 using System.Text; 28 29 using System.Windows.Forms; 29 30 using HeuristicLab.Core; 30 31 using HeuristicLab.CEDMA.DB.Interfaces; 32 using HeuristicLab.PluginInfrastructure; 31 33 32 34 namespace HeuristicLab.CEDMA.Core { … … 37 39 set { dataSet = value; } 38 40 } 39 41 private Results results; 40 42 public DataSetView() { 41 43 InitializeComponent(); … … 51 53 base.UpdateControls(); 52 54 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; 54 60 } 55 61 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"; 58 67 } 59 68 … … 62 71 activateButton.Enabled = false; 63 72 } 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 } 64 113 } 65 114 } 115 -
trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj
r852 r1287 72 72 </ItemGroup> 73 73 <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> 76 82 <Compile Include="Console.cs" /> 77 83 <Compile Include="ConsoleEditor.cs"> 78 84 <SubType>UserControl</SubType> 79 85 </Compile> 80 <Compile Include=" ResultTable.cs" />81 <Compile Include=" ResultExporter.cs" />82 <Compile Include="Data baseOperatorLibrary.cs" />83 <Compile Include="Data baseOperatorLibraryView.cs">86 <Compile Include="Problem.cs" /> 87 <Compile Include="DataSet.cs" /> 88 <Compile Include="DataSetList.cs" /> 89 <Compile Include="DataSetListView.cs"> 84 90 <SubType>UserControl</SubType> 85 91 </Compile> 86 <Compile Include="Data baseOperatorLibraryView.Designer.cs">87 <DependentUpon>Data baseOperatorLibraryView.cs</DependentUpon>92 <Compile Include="DataSetListView.Designer.cs"> 93 <DependentUpon>DataSetListView.cs</DependentUpon> 88 94 </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"> 99 96 <SubType>UserControl</SubType> 100 97 </Compile> 101 <Compile Include=" AgentListView.Designer.cs">102 <DependentUpon> AgentListView.cs</DependentUpon>98 <Compile Include="DataSetView.Designer.cs"> 99 <DependentUpon>DataSetView.cs</DependentUpon> 103 100 </Compile> 104 <Compile Include="AgentView.cs"> 101 <Compile Include="HeuristicLabCedmaCorePlugin.cs" /> 102 <Compile Include="ProblemView.cs"> 105 103 <SubType>UserControl</SubType> 106 104 </Compile> 107 <Compile Include=" AgentView.Designer.cs">108 <DependentUpon> AgentView.cs</DependentUpon>105 <Compile Include="ProblemView.Designer.cs"> 106 <DependentUpon>ProblemView.cs</DependentUpon> 109 107 </Compile> 108 <Compile Include="Properties\AssemblyInfo.cs" /> 109 <Compile Include="Results.cs" /> 110 110 </ItemGroup> 111 111 <ItemGroup> … … 113 113 </ItemGroup> 114 114 <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>119 115 <ProjectReference Include="..\HeuristicLab.CEDMA.DB.Interfaces\HeuristicLab.CEDMA.DB.Interfaces.csproj"> 120 116 <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project> … … 124 120 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 125 121 <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> 126 130 </ProjectReference> 127 131 <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj"> … … 135 139 </ItemGroup> 136 140 <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> 144 143 </EmbeddedResource> 145 144 <EmbeddedResource Include="ConsoleEditor.resx"> … … 147 146 <SubType>Designer</SubType> 148 147 </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> 152 156 </EmbeddedResource> 153 157 </ItemGroup> -
trunk/sources/HeuristicLab.CEDMA.Core/Problem.cs
r957 r1287 30 30 31 31 namespace HeuristicLab.CEDMA.Core { 32 33 public enum LearningTask { 34 Classification, 35 Regression, 36 TimeSeries, 37 Clustering 38 } 39 32 40 /// <summary> 33 41 /// Problem describes the data mining task. … … 36 44 /// * regression, time-series or classification problem 37 45 /// </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 39 126 public Problem() 40 127 : 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(); 41 219 } 42 220 } -
trunk/sources/HeuristicLab.CEDMA.Core/ProblemView.Designer.cs
r992 r1287 45 45 private void InitializeComponent() { 46 46 this.importButton = new System.Windows.Forms.Button(); 47 this.t extBox1= new System.Windows.Forms.TextBox();47 this.trainingSamplesStartTextBox = new System.Windows.Forms.TextBox(); 48 48 this.trainingLabel = new System.Windows.Forms.Label(); 49 this.t extBox4= 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(); 52 52 this.validationLabel = new System.Windows.Forms.Label(); 53 this.te xtBox5= new System.Windows.Forms.TextBox();54 this.te xtBox6= new System.Windows.Forms.TextBox();53 this.testSamplesEndTextBox = new System.Windows.Forms.TextBox(); 54 this.testSamplesStartTextBox = new System.Windows.Forms.TextBox(); 55 55 this.testLabel = new System.Windows.Forms.Label(); 56 this.datasetView = new HeuristicLab.DataAnalysis.DatasetView();57 56 this.targetsListBox = new System.Windows.Forms.CheckedListBox(); 58 57 this.inputsListBox = new System.Windows.Forms.CheckedListBox(); … … 61 60 this.inputsGroupBox = new System.Windows.Forms.GroupBox(); 62 61 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(); 63 73 this.targetsGroupBox.SuspendLayout(); 64 74 this.inputsGroupBox.SuspendLayout(); 65 75 this.partitioningGroupBox.SuspendLayout(); 76 this.learningTaskGroupBox.SuspendLayout(); 66 77 this.SuspendLayout(); 67 78 // … … 74 85 this.importButton.Text = "Import"; 75 86 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); 83 97 // 84 98 // trainingLabel … … 91 105 this.trainingLabel.Text = "Training samples:"; 92 106 // 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); 113 133 // 114 134 // validationLabel 115 135 // 116 136 this.validationLabel.AutoSize = true; 117 this.validationLabel.Location = new System.Drawing.Point(5, 4 8);137 this.validationLabel.Location = new System.Drawing.Point(5, 46); 118 138 this.validationLabel.Name = "validationLabel"; 119 139 this.validationLabel.Size = new System.Drawing.Size(97, 13); … … 121 141 this.validationLabel.Text = "Validation samples:"; 122 142 // 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); 136 160 // 137 161 // testLabel … … 143 167 this.testLabel.TabIndex = 14; 144 168 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); 145 357 // 146 358 // datasetView … … 154 366 this.datasetView.Location = new System.Drawing.Point(3, 32); 155 367 this.datasetView.Name = "datasetView"; 156 this.datasetView.Size = new System.Drawing.Size(3 26, 221);368 this.datasetView.Size = new System.Drawing.Size(395, 371); 157 369 this.datasetView.TabIndex = 17; 158 //159 // targetsListBox160 //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 // inputsListBox171 //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 // autoregressiveCheckBox182 //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 // targetsGroupBox193 //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 // inputsGroupBox203 //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 // partitioningGroupBox213 //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:";229 370 // 230 371 // ProblemView … … 232 373 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 233 374 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 375 this.Controls.Add(this.learningTaskGroupBox); 234 376 this.Controls.Add(this.partitioningGroupBox); 235 377 this.Controls.Add(this.inputsGroupBox); 236 378 this.Controls.Add(this.targetsGroupBox); 237 this.Controls.Add(this.autoregressiveCheckBox);238 379 this.Controls.Add(this.datasetView); 239 380 this.Controls.Add(this.importButton); 240 381 this.Name = "ProblemView"; 241 this.Size = new System.Drawing.Size( 337, 569);382 this.Size = new System.Drawing.Size(406, 787); 242 383 this.targetsGroupBox.ResumeLayout(false); 243 384 this.inputsGroupBox.ResumeLayout(false); 244 385 this.partitioningGroupBox.ResumeLayout(false); 245 386 this.partitioningGroupBox.PerformLayout(); 387 this.learningTaskGroupBox.ResumeLayout(false); 388 this.learningTaskGroupBox.PerformLayout(); 246 389 this.ResumeLayout(false); 247 this.PerformLayout();248 390 249 391 } … … 252 394 253 395 private System.Windows.Forms.Button importButton; 254 private System.Windows.Forms.TextBox t extBox1;396 private System.Windows.Forms.TextBox trainingSamplesStartTextBox; 255 397 private System.Windows.Forms.Label trainingLabel; 256 private System.Windows.Forms.TextBox t extBox4;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; 259 401 private System.Windows.Forms.Label validationLabel; 260 private System.Windows.Forms.TextBox te xtBox5;261 private System.Windows.Forms.TextBox te xtBox6;402 private System.Windows.Forms.TextBox testSamplesEndTextBox; 403 private System.Windows.Forms.TextBox testSamplesStartTextBox; 262 404 private System.Windows.Forms.Label testLabel; 263 405 private HeuristicLab.DataAnalysis.DatasetView datasetView; … … 268 410 private System.Windows.Forms.GroupBox inputsGroupBox; 269 411 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; 270 422 } 271 423 } -
trunk/sources/HeuristicLab.CEDMA.Core/ProblemView.cs
r992 r1287 29 29 using System.Windows.Forms; 30 30 using HeuristicLab.Core; 31 using HeuristicLab.DataAnalysis; 32 using System.Diagnostics; 31 33 32 34 namespace HeuristicLab.CEDMA.Core { … … 37 39 this.problem = problem; 38 40 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 40 243 } 41 244 } -
trunk/sources/HeuristicLab.CEDMA.Core/ProblemView.resx
r992 r1287 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </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> 120 123 </root> -
trunk/sources/HeuristicLab.CEDMA.Core/Results.cs
r1075 r1287 36 36 37 37 namespace 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 } 40 58 41 59 private IStore store; … … 47 65 } 48 66 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; 55 68 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); 71 99 } 72 100 } 73 lock(records) {74 records.Add(r);75 }76 FireRecordAdded(r);77 101 } 102 entries.Add(entry); 103 yield return entry; 78 104 } 105 79 106 FireChanged(); 107 cached = true; 80 108 } 81 109 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); 98 112 } 99 113 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(); 102 123 } 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> Members155 156 public IEnumerator<Record> GetEnumerator() {157 throw new NotImplementedException();158 }159 160 #endregion161 162 #region IEnumerable Members163 164 IEnumerator IEnumerable.GetEnumerator() {165 return this.GetEnumerator();166 }167 168 #endregion169 124 } 170 125 } -
trunk/sources/HeuristicLab.CEDMA.Core/TableResultsView.Designer.cs
r1106 r1287 39 39 this.dataGridView.Size = new System.Drawing.Size(450, 459); 40 40 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); 41 43 // 42 44 // TableResultsView -
trunk/sources/HeuristicLab.CEDMA.Core/TableResultsView.cs
r1106 r1287 9 9 using HeuristicLab.Core; 10 10 using HeuristicLab.CEDMA.Core; 11 using HeuristicLab.PluginInfrastructure; 12 using HeuristicLab.CEDMA.DB.Interfaces; 11 13 12 14 namespace 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; 16 24 InitializeComponent(); 25 Results = results; 26 results.Changed += new EventHandler(results_Changed); 17 27 } 18 28 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; 25 31 UpdateControls(); 26 32 } 27 33 28 34 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; 34 36 dataGridView.Rows.Clear(); 35 37 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); 38 41 } 39 42 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; 42 51 } 43 52 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 } 44 74 } 45 75 } 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 } 46 90 }
Note: See TracChangeset
for help on using the changeset viewer.