Index: /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
===================================================================
--- /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj (revision 17145)
+++ /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj (revision 17146)
@@ -325,9 +325,9 @@
ModifiableDatasetView.cs
-
- UserControl
-
-
- ParsedConstraintView.cs
+
+ UserControl
+
+
+ ProblemDataConstraintView.cs
Index: anches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs
===================================================================
--- /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs (revision 17145)
+++ (revision )
@@ -1,137 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-using System;
-using System.Collections.Generic;
-using HeuristicLab.Collections;
-using HeuristicLab.Core;
-using HeuristicLab.MainForm;
-using HeuristicLab.MainForm.WindowsForms;
-
-namespace HeuristicLab.Problems.DataAnalysis.Views {
- [View("ParsedConstraint View")]
- [Content(typeof(ProblemDataConstraint), true)]
- public partial class ParsedConstraintView : AsynchronousContentView {
- private CheckedItemList intervalConstraints;
- public new ProblemDataConstraint Content {
- get => (ProblemDataConstraint)base.Content;
- set => base.Content = value;
- }
-
- public ParsedConstraintView() {
- InitializeComponent();
- errorOutput.Text = "";
- intervalConstraints = new CheckedItemList();
- }
-
- protected override void OnContentChanged() {
- base.OnContentChanged();
- UpdateControl();
- }
-
- protected override void RegisterContentEvents() {
- base.RegisterContentEvents();
- intervalConstraints.CheckedItemsChanged += constraint_CheckedItemChanged;
- intervalConstraints.ItemsAdded += constraints_Updated;
- intervalConstraints.ItemsRemoved += constraint_removed;
- Content.Changed += Content_Changed;
- }
-
- protected override void DeregisterContentEvents() {
- intervalConstraints.CheckedItemsChanged -= constraint_CheckedItemChanged;
- intervalConstraints.ItemsAdded -= constraints_Updated;
- intervalConstraints.ItemsRemoved -= constraint_removed;
- Content.Changed -= Content_Changed;
- base.DeregisterContentEvents();
- }
-
- protected override void SetEnabledStateOfControls() {
- constraintsInput.Enabled = Content != null && !Locked && !ReadOnly;
- }
-
-
- private IEnumerable ParseConstraints(string input) {
- return IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable,
- Content.ProblemData.AllowedInputVariables);
- }
-
- private void parseBtn_Click(object sender, EventArgs e) {
- if (constraintsInput.Text != null) {
- intervalConstraints.Clear();
- var parsedConstraints = ParseConstraints(constraintsInput.Text);
- Content.Constraints = parsedConstraints;
- Content.Input = constraintsInput.Text;
- errorOutput.Text = "";
- } else {
- errorOutput.Text = "No constraints were found!";
- }
- }
-
- private void UpdateControl() {
- if (Content == null) {
- intervalConstraints.Clear();
- constraintsOutput.Content = intervalConstraints;
- } else {
- intervalConstraints.Clear();
- constraintsInput.Text = Content.Input;
- foreach (var constraint in Content.Constraints) {
- intervalConstraints.Add(constraint, constraint.Enabled);
- }
-
- constraintsOutput.Content = intervalConstraints;
- }
- }
-
- private void constraint_Changed(object sender, EventArgs e) {
- var constraint = (IntervalConstraint) sender;
- intervalConstraints.SetItemCheckedState(constraint, constraint.Enabled);
- }
-
- private void constraints_Updated(object sender, CollectionItemsChangedEventArgs> e) {
- foreach (var addedItem in e.Items) {
- addedItem.Value.Changed += constraint_Changed;
- }
- }
-
- private void constraint_removed(object sender, CollectionItemsChangedEventArgs> e) {
- foreach (var removedItem in e.Items) {
- removedItem.Value.Changed -= constraint_Changed;
- }
- }
-
- private void constraint_CheckedItemChanged(object sender,
- CollectionItemsChangedEventArgs> e) {
- ICheckedItemList checkedItemList = (ICheckedItemList) sender;
- foreach (var indexedItem in e.Items) {
- indexedItem.Value.Enabled = checkedItemList.ItemChecked(indexedItem.Value);
- }
- }
-
- private void constraintsInput_TextChanged(object sender, EventArgs e) {
- errorOutput.Text = "Unparsed changes! Press parse button to save changes.";
- Content.Input = constraintsInput.Text;
- }
-
- private void Content_Changed(object sender, EventArgs e) {
- UpdateControl();
- }
-
- }
-}
Index: anches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.designer.cs
===================================================================
--- /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.designer.cs (revision 17145)
+++ (revision )
@@ -1,186 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-using System;
-
-namespace HeuristicLab.Problems.DataAnalysis.Views {
- partial class ParsedConstraintView {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing) {
- if (disposing && (components != null)) {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent() {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ParsedConstraintView));
- this.splitContainer1 = new System.Windows.Forms.SplitContainer();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.constraintsInput = new System.Windows.Forms.TextBox();
- this.parseBtn = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- //this.constraintsOutput = new System.Windows.Forms.Label();
- this.constraintsOutput = new HeuristicLab.Core.Views.CheckedItemListView();
- this.errorOutput = new System.Windows.Forms.Label();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
- this.splitContainer1.Panel1.SuspendLayout();
- this.splitContainer1.Panel2.SuspendLayout();
- this.splitContainer1.SuspendLayout();
- this.groupBox1.SuspendLayout();
- this.SuspendLayout();
- //
- // splitContainer1
- //
- this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.splitContainer1.Location = new System.Drawing.Point(0, 0);
- this.splitContainer1.Name = "splitContainer1";
- //
- // splitContainer1.Panel1
- //
- this.splitContainer1.Panel1.Controls.Add(this.groupBox1);
- //
- // splitContainer1.Panel2
- //
- this.splitContainer1.Panel2.Controls.Add(this.constraintsOutput);
- this.splitContainer1.Size = new System.Drawing.Size(888, 629);
- this.splitContainer1.SplitterDistance = 296;
- this.splitContainer1.TabIndex = 0;
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.constraintsInput);
- this.groupBox1.Controls.Add(this.parseBtn);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.groupBox1.Location = new System.Drawing.Point(0, 0);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(296, 629);
- this.groupBox1.TabIndex = 3;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Constraints Input";
- //
- // constraintsInput
- //
- this.constraintsInput.AcceptsTab = true;
- this.constraintsInput.Dock = System.Windows.Forms.DockStyle.Fill;
- this.constraintsInput.Location = new System.Drawing.Point(3, 198);
- this.constraintsInput.Multiline = true;
- this.constraintsInput.Name = "constraintsInput";
- this.constraintsInput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.constraintsInput.Size = new System.Drawing.Size(290, 405);
- this.constraintsInput.TabIndex = 2;
- this.constraintsInput.TextChanged += new System.EventHandler(this.constraintsInput_TextChanged);
- //
- // parseBtn
- //
- this.parseBtn.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.parseBtn.Location = new System.Drawing.Point(3, 603);
- this.parseBtn.Name = "parseBtn";
- this.parseBtn.Size = new System.Drawing.Size(290, 23);
- this.parseBtn.TabIndex = 1;
- this.parseBtn.Text = "Parse Constraints";
- this.parseBtn.UseVisualStyleBackColor = true;
- this.parseBtn.Click += new System.EventHandler(this.parseBtn_Click);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Dock = System.Windows.Forms.DockStyle.Top;
- this.label1.Location = new System.Drawing.Point(3, 16);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(250, 182);
- this.label1.TabIndex = 0;
- this.label1.Text = "To define target variable constraints:" + Environment.NewLine +
- "1. Start the definition with target:" + Environment.NewLine +
- "2. Specify the target variable between '-characters" + Environment.NewLine +
- "3. Add the keyword in" + Environment.NewLine +
- "4. Specify the interval with [lowerbound .. upperbound]" + Environment.NewLine +
- "5. Open or closed square brackets denotes if an interval is open or closed" + Environment.NewLine + Environment.NewLine +
- "To define a derivation constraint: " + Environment.NewLine +
- "1. Start with d or \u2202" + Environment.NewLine +
- "2. Specify the target between '-characters" + Environment.NewLine +
- "3. Seperate taget and derivation variable with /" + Environment.NewLine +
- "4. Add derivation variable between '-characters'" + Environment.NewLine +
- "5. Follow the steps 3-5 from above";
- //
- // constraintsOutput
- //
- this.constraintsOutput.Dock = System.Windows.Forms.DockStyle.Fill;
- this.constraintsOutput.Location = new System.Drawing.Point(3, 16);
- this.constraintsOutput.Name = "constraintsOutput";
- this.constraintsOutput.Size = new System.Drawing.Size(582, 587);
- this.constraintsOutput.TabIndex = 2;
- //
- // errorOutput
- //
- this.errorOutput.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.errorOutput.ForeColor = System.Drawing.Color.Red;
- this.errorOutput.Location = new System.Drawing.Point(3, 603);
- this.errorOutput.Name = "errorOutput";
- this.errorOutput.Size = new System.Drawing.Size(582, 23);
- this.errorOutput.TabIndex = 1;
- this.errorOutput.Text = "ERROR";
- this.errorOutput.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // ParsedConstraintView
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.splitContainer1);
- this.Name = "ParsedConstraintView";
- this.Size = new System.Drawing.Size(888, 629);
- this.splitContainer1.Panel1.ResumeLayout(false);
- this.splitContainer1.Panel2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
- this.splitContainer1.ResumeLayout(false);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.SplitContainer splitContainer1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button parseBtn;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox constraintsInput;
- private System.Windows.Forms.Label errorOutput;
-
- //private System.Windows.Forms.Label constraintsOutput;
- private HeuristicLab.Core.Views.CheckedItemListView constraintsOutput;
- }
-}
Index: /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.cs
===================================================================
--- /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.cs (revision 17146)
+++ /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.cs (revision 17146)
@@ -0,0 +1,136 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+using System;
+using System.Collections.Generic;
+using HeuristicLab.Collections;
+using HeuristicLab.Core;
+using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ [View("ParsedConstraint View")]
+ [Content(typeof(ProblemDataConstraint), true)]
+ public partial class ProblemDataConstraintView : AsynchronousContentView {
+ private readonly CheckedItemList intervalConstraints = new CheckedItemList();
+ public new ProblemDataConstraint Content {
+ get => (ProblemDataConstraint)base.Content;
+ set => base.Content = value;
+ }
+
+ public ProblemDataConstraintView() {
+ InitializeComponent();
+ errorOutput.Text = "";
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ UpdateControl();
+ }
+
+ protected override void RegisterContentEvents() {
+ base.RegisterContentEvents();
+ intervalConstraints.CheckedItemsChanged += constraint_CheckedItemChanged;
+ intervalConstraints.ItemsAdded += constraints_Updated;
+ intervalConstraints.ItemsRemoved += constraint_removed;
+ Content.Changed += Content_Changed;
+ }
+
+ protected override void DeregisterContentEvents() {
+ intervalConstraints.CheckedItemsChanged -= constraint_CheckedItemChanged;
+ intervalConstraints.ItemsAdded -= constraints_Updated;
+ intervalConstraints.ItemsRemoved -= constraint_removed;
+ Content.Changed -= Content_Changed;
+ base.DeregisterContentEvents();
+ }
+
+ protected override void SetEnabledStateOfControls() {
+ constraintsInput.Enabled = Content != null && !Locked && !ReadOnly;
+ }
+
+
+ private IEnumerable ParseConstraints(string input) {
+ return IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable,
+ Content.ProblemData.AllowedInputVariables);
+ }
+
+ private void parseBtn_Click(object sender, EventArgs e) {
+ if (constraintsInput.Text != null) {
+ intervalConstraints.Clear();
+ var parsedConstraints = ParseConstraints(constraintsInput.Text);
+ Content.Constraints = parsedConstraints;
+ Content.Input = constraintsInput.Text;
+ errorOutput.Text = "";
+ } else {
+ errorOutput.Text = "No constraints were found!";
+ }
+ }
+
+ private void UpdateControl() {
+ if (Content == null) {
+ intervalConstraints.Clear();
+ intervalConstraintsView.Content = intervalConstraints;
+ } else {
+ intervalConstraints.Clear();
+ constraintsInput.Text = Content.Input;
+ foreach (var constraint in Content.Constraints) {
+ intervalConstraints.Add(constraint, constraint.Enabled);
+ }
+
+ intervalConstraintsView.Content = intervalConstraints;
+ }
+ }
+
+ private void constraint_Changed(object sender, EventArgs e) {
+ var constraint = (IntervalConstraint)sender;
+ intervalConstraints.SetItemCheckedState(constraint, constraint.Enabled);
+ }
+
+ private void constraints_Updated(object sender, CollectionItemsChangedEventArgs> e) {
+ foreach (var addedItem in e.Items) {
+ addedItem.Value.Changed += constraint_Changed;
+ }
+ }
+
+ private void constraint_removed(object sender, CollectionItemsChangedEventArgs> e) {
+ foreach (var removedItem in e.Items) {
+ removedItem.Value.Changed -= constraint_Changed;
+ }
+ }
+
+ private void constraint_CheckedItemChanged(object sender,
+ CollectionItemsChangedEventArgs> e) {
+ ICheckedItemList checkedItemList = (ICheckedItemList)sender;
+ foreach (var indexedItem in e.Items) {
+ indexedItem.Value.Enabled = checkedItemList.ItemChecked(indexedItem.Value);
+ }
+ }
+
+ private void constraintsInput_TextChanged(object sender, EventArgs e) {
+ errorOutput.Text = "Unparsed changes! Press parse button to save changes.";
+ Content.Input = constraintsInput.Text;
+ }
+
+ private void Content_Changed(object sender, EventArgs e) {
+ UpdateControl();
+ }
+
+ }
+}
Index: /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.designer.cs
===================================================================
--- /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.designer.cs (revision 17146)
+++ /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.designer.cs (revision 17146)
@@ -0,0 +1,184 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+using System;
+
+namespace HeuristicLab.Problems.DataAnalysis.Views {
+ partial class ProblemDataConstraintView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProblemDataConstraintView));
+ this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.constraintsInput = new System.Windows.Forms.TextBox();
+ this.parseBtn = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.intervalConstraintsView = new HeuristicLab.Core.Views.CheckedItemListView();
+ this.errorOutput = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
+ this.splitContainer1.Panel1.SuspendLayout();
+ this.splitContainer1.Panel2.SuspendLayout();
+ this.splitContainer1.SuspendLayout();
+ this.groupBox1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // splitContainer1
+ //
+ this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+ this.splitContainer1.Name = "splitContainer1";
+ //
+ // splitContainer1.Panel1
+ //
+ this.splitContainer1.Panel1.Controls.Add(this.groupBox1);
+ //
+ // splitContainer1.Panel2
+ //
+ this.splitContainer1.Panel2.Controls.Add(this.intervalConstraintsView);
+ this.splitContainer1.Size = new System.Drawing.Size(888, 629);
+ this.splitContainer1.SplitterDistance = 296;
+ this.splitContainer1.TabIndex = 0;
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.constraintsInput);
+ this.groupBox1.Controls.Add(this.parseBtn);
+ this.groupBox1.Controls.Add(this.label1);
+ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.groupBox1.Location = new System.Drawing.Point(0, 0);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(296, 629);
+ this.groupBox1.TabIndex = 3;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Constraints Input";
+ //
+ // constraintsInput
+ //
+ this.constraintsInput.AcceptsTab = true;
+ this.constraintsInput.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.constraintsInput.Location = new System.Drawing.Point(3, 198);
+ this.constraintsInput.Multiline = true;
+ this.constraintsInput.Name = "constraintsInput";
+ this.constraintsInput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.constraintsInput.Size = new System.Drawing.Size(290, 405);
+ this.constraintsInput.TabIndex = 2;
+ this.constraintsInput.TextChanged += new System.EventHandler(this.constraintsInput_TextChanged);
+ //
+ // parseBtn
+ //
+ this.parseBtn.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.parseBtn.Location = new System.Drawing.Point(3, 603);
+ this.parseBtn.Name = "parseBtn";
+ this.parseBtn.Size = new System.Drawing.Size(290, 23);
+ this.parseBtn.TabIndex = 1;
+ this.parseBtn.Text = "Parse Constraints";
+ this.parseBtn.UseVisualStyleBackColor = true;
+ this.parseBtn.Click += new System.EventHandler(this.parseBtn_Click);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.label1.Location = new System.Drawing.Point(3, 16);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(250, 182);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "To define target variable constraints:" + Environment.NewLine +
+ "1. Start the definition with target:" + Environment.NewLine +
+ "2. Specify the target variable between '-characters" + Environment.NewLine +
+ "3. Add the keyword in" + Environment.NewLine +
+ "4. Specify the interval with [lowerbound .. upperbound]" + Environment.NewLine +
+ "5. Open or closed square brackets denotes if an interval is open or closed" + Environment.NewLine + Environment.NewLine +
+ "To define a derivation constraint: " + Environment.NewLine +
+ "1. Start with d or \u2202" + Environment.NewLine +
+ "2. Specify the target between '-characters" + Environment.NewLine +
+ "3. Seperate taget and derivation variable with /" + Environment.NewLine +
+ "4. Add derivation variable between '-characters'" + Environment.NewLine +
+ "5. Follow the steps 3-5 from above";
+ //
+ // intervalConstraintsView
+ //
+ this.intervalConstraintsView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.intervalConstraintsView.Location = new System.Drawing.Point(3, 16);
+ this.intervalConstraintsView.Name = "intervalConstraintsView";
+ this.intervalConstraintsView.Size = new System.Drawing.Size(582, 587);
+ this.intervalConstraintsView.TabIndex = 2;
+ //
+ // errorOutput
+ //
+ this.errorOutput.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.errorOutput.ForeColor = System.Drawing.Color.Red;
+ this.errorOutput.Location = new System.Drawing.Point(3, 603);
+ this.errorOutput.Name = "errorOutput";
+ this.errorOutput.Size = new System.Drawing.Size(582, 23);
+ this.errorOutput.TabIndex = 1;
+ this.errorOutput.Text = "ERROR";
+ this.errorOutput.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // ParsedConstraintView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.splitContainer1);
+ this.Name = "ParsedConstraintView";
+ this.Size = new System.Drawing.Size(888, 629);
+ this.splitContainer1.Panel1.ResumeLayout(false);
+ this.splitContainer1.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
+ this.splitContainer1.ResumeLayout(false);
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.SplitContainer splitContainer1;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.Button parseBtn;
+ private System.Windows.Forms.Label label1;
+ private HeuristicLab.Core.Views.CheckedItemListView intervalConstraintsView;
+ private System.Windows.Forms.TextBox constraintsInput;
+ private System.Windows.Forms.Label errorOutput;
+
+ }
+}
Index: /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs
===================================================================
--- /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs (revision 17145)
+++ /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs (revision 17146)
@@ -28,6 +28,12 @@
public static class IntervalConstraintsParser {
- public static IEnumerable ParseInput(string input, string target = "", IEnumerable variables = null) {
- var lines = input.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
+ public static IEnumerable ParseInput(string inputText, string target, IEnumerable variables) {
+
+ if (string.IsNullOrEmpty(inputText)) throw new ArgumentNullException("No input text has been provided.");
+ if (string.IsNullOrEmpty(target)) throw new ArgumentNullException("No target variable has been provided.");
+ if (variables == null) throw new ArgumentNullException("No variables have been provided.");
+ if (!variables.Any()) throw new ArgumentException("Varialbes are empty.");
+
+ var lines = inputText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
foreach (var line in lines) {
var trimmedLine = line.TrimStart();
@@ -36,10 +42,10 @@
var start = "Target:".Length;
var end = trimmedLine.Length;
- var targetConstraint = trimmedLine.Substring(start, end-start);
+ var targetConstraint = trimmedLine.Substring(start, end - start);
var match = Regex.Match(targetConstraint,
@"(['](.*)[']|(.*[^\s]))\s*(\bin\b)\s*([\[\]])\s*(\S*)\s*(\.{2})\s*(\S*)\s*([\[\]])");
if (match.Success) {
if (match.Groups.Count != 10) {
- throw new ArgumentException("The given target-constraint is not complete!");
+ throw new ArgumentException("The target-constraint is not complete.");
} else {
var targetVariable = match.Groups[1].Value.Trim();
@@ -47,9 +53,9 @@
targetVariable = targetVariable.Substring(1, targetVariable.Length - 2);
}
- if (target != "") {
- if (targetVariable != target) {
- throw new ArgumentException("The given target variable is not in the given dataset!");
- }
+
+ if (targetVariable != target) {
+ throw new ArgumentException($"The target variable {targetVariable} does not match the provided target {target}.");
}
+
var lowerBound = ParseIntervalBounds(match.Groups[6].Value);
var upperBound = ParseIntervalBounds(match.Groups[8].Value);
@@ -68,5 +74,5 @@
}
} else {
- throw new ArgumentException("The inserted target constraint is not valid!");
+ throw new ArgumentException("The inserted target constraint is not valid.");
}
//Check for derivation
@@ -77,5 +83,5 @@
if (match.Success) {
if (match.Groups.Count != 17) {
- throw new ArgumentException("The given derivation-constraint is not complete");
+ throw new ArgumentException("The given derivation-constraint is not complete.");
} else {
var derivationTarget = match.Groups[3].Value.Trim();
@@ -88,20 +94,18 @@
derivationVariable = derivationVariable.Substring(1, derivationVariable.Length - 2);
}
- if (target != "") {
- if (derivationTarget != target)
- throw new ArgumentException("The given target variable is not given in the dataset!");
+
+ if (derivationTarget != target) {
+ throw new ArgumentException($"The target variable {derivationTarget} does not match the provided target {target}.");
}
- if (variables != null && variables.Any()) {
- if (variables.All(v => v != derivationVariable)) {
- throw new ArgumentException("The given variable does not exist in the dataset!");
- }
+ if (variables.All(v => v != derivationVariable)) {
+ throw new ArgumentException($"The given variable {derivationVariable} does not exist in the dataset.");
}
if (match.Groups[2].Value.Trim() != "" || match.Groups[11].Value.Trim() != "") {
if (match.Groups[2].Value.Trim() == "" || match.Groups[11].Value.Trim() == "")
- throw new ArgumentException("Number of derivation has to be written on both sides!");
+ throw new ArgumentException("Number of derivation has to be written on both sides.");
if (match.Groups[2].Value.Trim() != match.Groups[11].Value.Trim())
- throw new ArgumentException("Derivation number is not equal on both sides!");
+ throw new ArgumentException("Derivation number is not equal on both sides.");
}
@@ -122,5 +126,5 @@
}
} else {
- throw new ArgumentException("The inserted derivation constraint is not valid!");
+ throw new ArgumentException("The inserted derivation constraint is not valid.");
}
//Check for comment
Index: /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ProblemDataConstraint.cs
===================================================================
--- /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ProblemDataConstraint.cs (revision 17145)
+++ /branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ProblemDataConstraint.cs (revision 17146)
@@ -24,11 +24,11 @@
using System.Collections.Generic;
using System.Linq;
+using HEAL.Attic;
using HeuristicLab.Common;
using HeuristicLab.Core;
-using HEAL.Attic;
namespace HeuristicLab.Problems.DataAnalysis {
[StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")]
- [Item("ParsedConstraint", "Represents parsed constraints.")]
+ [Item("ProblemDataConstraints", "Represents constraints associated with a problem data.")]
public class ProblemDataConstraint : Item {
private static readonly string exampleInput = "# Example for a target variable constraint:" + Environment.NewLine +
@@ -76,5 +76,5 @@
}
- public ProblemDataConstraint() :base () {
+ public ProblemDataConstraint() : base() {
this.Input = exampleInput;
this.constraints = new List();