Changeset 17146 for branches/2971_named_intervals
- Timestamp:
- 07/22/19 13:39:09 (5 years ago)
- Location:
- branches/2971_named_intervals
- Files:
-
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r16896 r17146 325 325 <DependentUpon>ModifiableDatasetView.cs</DependentUpon> 326 326 </Compile> 327 <Compile Include="P arsedConstraintView.cs">328 <SubType>UserControl</SubType> 329 </Compile> 330 <Compile Include="P arsedConstraintView.designer.cs">331 <DependentUpon>P arsedConstraintView.cs</DependentUpon>327 <Compile Include="ProblemDataConstraintView.cs"> 328 <SubType>UserControl</SubType> 329 </Compile> 330 <Compile Include="ProblemDataConstraintView.designer.cs"> 331 <DependentUpon>ProblemDataConstraintView.cs</DependentUpon> 332 332 </Compile> 333 333 <Compile Include="Plugin.cs" /> -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.cs
r17145 r17146 29 29 [View("ParsedConstraint View")] 30 30 [Content(typeof(ProblemDataConstraint), true)] 31 public partial class P arsedConstraintView : AsynchronousContentView {32 private CheckedItemList<IntervalConstraint> intervalConstraints;31 public partial class ProblemDataConstraintView : AsynchronousContentView { 32 private readonly CheckedItemList<IntervalConstraint> intervalConstraints = new CheckedItemList<IntervalConstraint>(); 33 33 public new ProblemDataConstraint Content { 34 34 get => (ProblemDataConstraint)base.Content; … … 36 36 } 37 37 38 public P arsedConstraintView() {38 public ProblemDataConstraintView() { 39 39 InitializeComponent(); 40 40 errorOutput.Text = ""; 41 intervalConstraints = new CheckedItemList<IntervalConstraint>();42 41 } 43 42 … … 88 87 if (Content == null) { 89 88 intervalConstraints.Clear(); 90 constraintsOutput.Content = intervalConstraints;89 intervalConstraintsView.Content = intervalConstraints; 91 90 } else { 92 91 intervalConstraints.Clear(); … … 96 95 } 97 96 98 constraintsOutput.Content = intervalConstraints;97 intervalConstraintsView.Content = intervalConstraints; 99 98 } 100 99 } 101 100 102 101 private void constraint_Changed(object sender, EventArgs e) { 103 var constraint = (IntervalConstraint) 102 var constraint = (IntervalConstraint)sender; 104 103 intervalConstraints.SetItemCheckedState(constraint, constraint.Enabled); 105 104 } … … 119 118 private void constraint_CheckedItemChanged(object sender, 120 119 CollectionItemsChangedEventArgs<IndexedItem<IntervalConstraint>> e) { 121 ICheckedItemList<IntervalConstraint> checkedItemList = (ICheckedItemList<IntervalConstraint>) 120 ICheckedItemList<IntervalConstraint> checkedItemList = (ICheckedItemList<IntervalConstraint>)sender; 122 121 foreach (var indexedItem in e.Items) { 123 122 indexedItem.Value.Enabled = checkedItemList.ItemChecked(indexedItem.Value); -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.designer.cs
r17145 r17146 22 22 23 23 namespace HeuristicLab.Problems.DataAnalysis.Views { 24 partial class P arsedConstraintView {24 partial class ProblemDataConstraintView { 25 25 /// <summary> 26 26 /// Required designer variable. … … 46 46 /// </summary> 47 47 private void InitializeComponent() { 48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(P arsedConstraintView));48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProblemDataConstraintView)); 49 49 this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 50 50 this.groupBox1 = new System.Windows.Forms.GroupBox(); … … 52 52 this.parseBtn = new System.Windows.Forms.Button(); 53 53 this.label1 = new System.Windows.Forms.Label(); 54 //this.constraintsOutput = new System.Windows.Forms.Label(); 55 this.constraintsOutput = new HeuristicLab.Core.Views.CheckedItemListView<IntervalConstraint>(); 54 this.intervalConstraintsView = new HeuristicLab.Core.Views.CheckedItemListView<IntervalConstraint>(); 56 55 this.errorOutput = new System.Windows.Forms.Label(); 57 56 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); … … 74 73 // splitContainer1.Panel2 75 74 // 76 this.splitContainer1.Panel2.Controls.Add(this. constraintsOutput);75 this.splitContainer1.Panel2.Controls.Add(this.intervalConstraintsView); 77 76 this.splitContainer1.Size = new System.Drawing.Size(888, 629); 78 77 this.splitContainer1.SplitterDistance = 296; … … 136 135 "5. Follow the steps 3-5 from above"; 137 136 // 138 // constraintsOutput137 // intervalConstraintsView 139 138 // 140 this. constraintsOutput.Dock = System.Windows.Forms.DockStyle.Fill;141 this. constraintsOutput.Location = new System.Drawing.Point(3, 16);142 this. constraintsOutput.Name = "constraintsOutput";143 this. constraintsOutput.Size = new System.Drawing.Size(582, 587);144 this. constraintsOutput.TabIndex = 2;139 this.intervalConstraintsView.Dock = System.Windows.Forms.DockStyle.Fill; 140 this.intervalConstraintsView.Location = new System.Drawing.Point(3, 16); 141 this.intervalConstraintsView.Name = "intervalConstraintsView"; 142 this.intervalConstraintsView.Size = new System.Drawing.Size(582, 587); 143 this.intervalConstraintsView.TabIndex = 2; 145 144 // 146 145 // errorOutput … … 178 177 private System.Windows.Forms.Button parseBtn; 179 178 private System.Windows.Forms.Label label1; 179 private HeuristicLab.Core.Views.CheckedItemListView<IntervalConstraint> intervalConstraintsView; 180 180 private System.Windows.Forms.TextBox constraintsInput; 181 181 private System.Windows.Forms.Label errorOutput; 182 182 183 //private System.Windows.Forms.Label constraintsOutput;184 private HeuristicLab.Core.Views.CheckedItemListView<IntervalConstraint> constraintsOutput;185 183 } 186 184 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs
r16957 r17146 28 28 public static class IntervalConstraintsParser { 29 29 30 public static IEnumerable<IntervalConstraint> ParseInput(string input, string target = "", IEnumerable<string> variables = null) { 31 var lines = input.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); 30 public static IEnumerable<IntervalConstraint> ParseInput(string inputText, string target, IEnumerable<string> variables) { 31 32 if (string.IsNullOrEmpty(inputText)) throw new ArgumentNullException("No input text has been provided."); 33 if (string.IsNullOrEmpty(target)) throw new ArgumentNullException("No target variable has been provided."); 34 if (variables == null) throw new ArgumentNullException("No variables have been provided."); 35 if (!variables.Any()) throw new ArgumentException("Varialbes are empty."); 36 37 var lines = inputText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); 32 38 foreach (var line in lines) { 33 39 var trimmedLine = line.TrimStart(); … … 36 42 var start = "Target:".Length; 37 43 var end = trimmedLine.Length; 38 var targetConstraint = trimmedLine.Substring(start, end -start);44 var targetConstraint = trimmedLine.Substring(start, end - start); 39 45 var match = Regex.Match(targetConstraint, 40 46 @"(['](.*)[']|(.*[^\s]))\s*(\bin\b)\s*([\[\]])\s*(\S*)\s*(\.{2})\s*(\S*)\s*([\[\]])"); 41 47 if (match.Success) { 42 48 if (match.Groups.Count != 10) { 43 throw new ArgumentException("The given target-constraint is not complete!");49 throw new ArgumentException("The target-constraint is not complete."); 44 50 } else { 45 51 var targetVariable = match.Groups[1].Value.Trim(); … … 47 53 targetVariable = targetVariable.Substring(1, targetVariable.Length - 2); 48 54 } 49 if (target != "") { 50 if (targetVariable != target) { 51 throw new ArgumentException("The given target variable is not in the given dataset!"); 52 } 55 56 if (targetVariable != target) { 57 throw new ArgumentException($"The target variable {targetVariable} does not match the provided target {target}."); 53 58 } 59 54 60 var lowerBound = ParseIntervalBounds(match.Groups[6].Value); 55 61 var upperBound = ParseIntervalBounds(match.Groups[8].Value); … … 68 74 } 69 75 } else { 70 throw new ArgumentException("The inserted target constraint is not valid !");76 throw new ArgumentException("The inserted target constraint is not valid."); 71 77 } 72 78 //Check for derivation … … 77 83 if (match.Success) { 78 84 if (match.Groups.Count != 17) { 79 throw new ArgumentException("The given derivation-constraint is not complete ");85 throw new ArgumentException("The given derivation-constraint is not complete."); 80 86 } else { 81 87 var derivationTarget = match.Groups[3].Value.Trim(); … … 88 94 derivationVariable = derivationVariable.Substring(1, derivationVariable.Length - 2); 89 95 } 90 if (target != "") { 91 if (derivationTarget != target)92 throw new ArgumentException("The given target variable is not given in the dataset!");96 97 if (derivationTarget != target) { 98 throw new ArgumentException($"The target variable {derivationTarget} does not match the provided target {target}."); 93 99 } 94 100 95 if (variables != null && variables.Any()) { 96 if (variables.All(v => v != derivationVariable)) { 97 throw new ArgumentException("The given variable does not exist in the dataset!"); 98 } 101 if (variables.All(v => v != derivationVariable)) { 102 throw new ArgumentException($"The given variable {derivationVariable} does not exist in the dataset."); 99 103 } 100 104 101 105 if (match.Groups[2].Value.Trim() != "" || match.Groups[11].Value.Trim() != "") { 102 106 if (match.Groups[2].Value.Trim() == "" || match.Groups[11].Value.Trim() == "") 103 throw new ArgumentException("Number of derivation has to be written on both sides !");107 throw new ArgumentException("Number of derivation has to be written on both sides."); 104 108 if (match.Groups[2].Value.Trim() != match.Groups[11].Value.Trim()) 105 throw new ArgumentException("Derivation number is not equal on both sides !");109 throw new ArgumentException("Derivation number is not equal on both sides."); 106 110 } 107 111 … … 122 126 } 123 127 } else { 124 throw new ArgumentException("The inserted derivation constraint is not valid !");128 throw new ArgumentException("The inserted derivation constraint is not valid."); 125 129 } 126 130 //Check for comment -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ProblemDataConstraint.cs
r16959 r17146 24 24 using System.Collections.Generic; 25 25 using System.Linq; 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 using HEAL.Attic;29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis { 31 31 [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")] 32 [Item("P arsedConstraint", "Represents parsed constraints.")]32 [Item("ProblemDataConstraints", "Represents constraints associated with a problem data.")] 33 33 public class ProblemDataConstraint : Item { 34 34 private static readonly string exampleInput = "# Example for a target variable constraint:" + Environment.NewLine + … … 76 76 } 77 77 78 public ProblemDataConstraint() : base() {78 public ProblemDataConstraint() : base() { 79 79 this.Input = exampleInput; 80 80 this.constraints = new List<IntervalConstraint>();
Note: See TracChangeset
for help on using the changeset viewer.