Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16774


Ignore:
Timestamp:
04/10/19 16:46:46 (6 years ago)
Author:
chaider
Message:

#2971 Changed Parser and IntevalConstraint View

Location:
branches/2971_named_intervals
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.Designer.cs

    r16772 r16774  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      this.components = new System.ComponentModel.Container();
    2627      this.expressionLabel = new System.Windows.Forms.Label();
    2728      this.definitionLabel = new System.Windows.Forms.Label();
     
    3940      this.variableInput = new System.Windows.Forms.TextBox();
    4041      this.numberderivationInput = new System.Windows.Forms.TextBox();
     42      this.upperCombo = new System.Windows.Forms.ComboBox();
     43      this.lowerCombo = new System.Windows.Forms.ComboBox();
     44      this.derivationInput = new System.Windows.Forms.TextBox();
    4145      this.groupBox1 = new System.Windows.Forms.GroupBox();
    42       this.lowerCombo = new System.Windows.Forms.ComboBox();
    43       this.upperCombo = new System.Windows.Forms.ComboBox();
    44       this.derivationInput = new System.Windows.Forms.TextBox();
     46      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    4547      this.groupBox1.SuspendLayout();
     48      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4649      this.SuspendLayout();
    4750      //
     
    129132      // definitionInput
    130133      //
     134      this.definitionInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     135            | System.Windows.Forms.AnchorStyles.Right)));
    131136      this.definitionInput.Location = new System.Drawing.Point(111, 42);
    132137      this.definitionInput.Name = "definitionInput";
     
    136141      // expressionInput
    137142      //
     143      this.expressionInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     144            | System.Windows.Forms.AnchorStyles.Right)));
    138145      this.expressionInput.Location = new System.Drawing.Point(111, 17);
    139146      this.expressionInput.Name = "expressionInput";
    140147      this.expressionInput.Size = new System.Drawing.Size(473, 20);
    141148      this.expressionInput.TabIndex = 10;
     149      this.expressionInput.TextChanged += new System.EventHandler(this.expressionInput_TextChanged);
    142150      //
    143151      // upperboundInput
    144152      //
     153      this.upperboundInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     154            | System.Windows.Forms.AnchorStyles.Right)));
    145155      this.upperboundInput.Location = new System.Drawing.Point(111, 93);
    146156      this.upperboundInput.Name = "upperboundInput";
     
    150160      // lowerboundInput
    151161      //
     162      this.lowerboundInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     163            | System.Windows.Forms.AnchorStyles.Right)));
    152164      this.lowerboundInput.Location = new System.Drawing.Point(111, 68);
    153165      this.lowerboundInput.Name = "lowerboundInput";
    154166      this.lowerboundInput.Size = new System.Drawing.Size(473, 20);
    155167      this.lowerboundInput.TabIndex = 12;
     168      this.lowerboundInput.TextChanged += new System.EventHandler(this.lowerboundInput_TextChanged);
    156169      //
    157170      // variableInput
    158171      //
     172      this.variableInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     173            | System.Windows.Forms.AnchorStyles.Right)));
    159174      this.variableInput.Location = new System.Drawing.Point(111, 195);
    160175      this.variableInput.Name = "variableInput";
    161176      this.variableInput.Size = new System.Drawing.Size(473, 20);
    162177      this.variableInput.TabIndex = 15;
     178      this.variableInput.TextChanged += new System.EventHandler(this.variableInput_TextChanged);
    163179      //
    164180      // numberderivationInput
    165181      //
     182      this.numberderivationInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     183            | System.Windows.Forms.AnchorStyles.Right)));
    166184      this.numberderivationInput.Location = new System.Drawing.Point(111, 221);
    167185      this.numberderivationInput.Name = "numberderivationInput";
    168186      this.numberderivationInput.Size = new System.Drawing.Size(473, 20);
    169187      this.numberderivationInput.TabIndex = 17;
     188      this.numberderivationInput.TextChanged += new System.EventHandler(this.numberderivationInput_TextChanged);
     189      //
     190      // upperCombo
     191      //
     192      this.upperCombo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     193            | System.Windows.Forms.AnchorStyles.Right)));
     194      this.upperCombo.FormattingEnabled = true;
     195      this.upperCombo.Items.AddRange(new object[] {
     196            "True",
     197            "False"});
     198      this.upperCombo.Location = new System.Drawing.Point(111, 146);
     199      this.upperCombo.Name = "upperCombo";
     200      this.upperCombo.Size = new System.Drawing.Size(473, 21);
     201      this.upperCombo.TabIndex = 19;
     202      //
     203      // lowerCombo
     204      //
     205      this.lowerCombo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     206            | System.Windows.Forms.AnchorStyles.Right)));
     207      this.lowerCombo.FormattingEnabled = true;
     208      this.lowerCombo.Items.AddRange(new object[] {
     209            "True",
     210            "False"});
     211      this.lowerCombo.Location = new System.Drawing.Point(111, 119);
     212      this.lowerCombo.Name = "lowerCombo";
     213      this.lowerCombo.Size = new System.Drawing.Size(473, 21);
     214      this.lowerCombo.TabIndex = 20;
     215      //
     216      // derivationInput
     217      //
     218      this.derivationInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     219            | System.Windows.Forms.AnchorStyles.Right)));
     220      this.derivationInput.Location = new System.Drawing.Point(111, 170);
     221      this.derivationInput.Name = "derivationInput";
     222      this.derivationInput.Size = new System.Drawing.Size(473, 20);
     223      this.derivationInput.TabIndex = 21;
    170224      //
    171225      // groupBox1
     
    197251      this.groupBox1.Text = "Interval Constraints Detail";
    198252      //
    199       // lowerCombo
    200       //
    201       this.lowerCombo.FormattingEnabled = true;
    202       this.lowerCombo.Items.AddRange(new object[] {
    203             "True",
    204             "False"});
    205       this.lowerCombo.Location = new System.Drawing.Point(111, 119);
    206       this.lowerCombo.Name = "lowerCombo";
    207       this.lowerCombo.Size = new System.Drawing.Size(473, 21);
    208       this.lowerCombo.TabIndex = 20;
    209       //
    210       // upperCombo
    211       //
    212       this.upperCombo.FormattingEnabled = true;
    213       this.upperCombo.Items.AddRange(new object[] {
    214             "True",
    215             "False"});
    216       this.upperCombo.Location = new System.Drawing.Point(111, 146);
    217       this.upperCombo.Name = "upperCombo";
    218       this.upperCombo.Size = new System.Drawing.Size(473, 21);
    219       this.upperCombo.TabIndex = 19;
    220       //
    221       // derivationInput
    222       //
    223       this.derivationInput.Location = new System.Drawing.Point(111, 170);
    224       this.derivationInput.Name = "derivationInput";
    225       this.derivationInput.Size = new System.Drawing.Size(473, 20);
    226       this.derivationInput.TabIndex = 21;
     253      // errorProvider
     254      //
     255      this.errorProvider.ContainerControl = this;
    227256      //
    228257      // IntervalConstraintView
     
    234263      this.groupBox1.ResumeLayout(false);
    235264      this.groupBox1.PerformLayout();
     265      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    236266      this.ResumeLayout(false);
    237267
     
    255285    private System.Windows.Forms.TextBox variableInput;
    256286    private System.Windows.Forms.TextBox numberderivationInput;
     287    private System.Windows.Forms.ComboBox upperCombo;
     288    private System.Windows.Forms.ComboBox lowerCombo;
     289    private System.Windows.Forms.TextBox derivationInput;
    257290    private System.Windows.Forms.GroupBox groupBox1;
    258     private System.Windows.Forms.ComboBox lowerCombo;
    259     private System.Windows.Forms.ComboBox upperCombo;
    260     private System.Windows.Forms.TextBox derivationInput;
     291    private System.Windows.Forms.ErrorProvider errorProvider;
    261292  }
    262293}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs

    r16772 r16774  
    2222      set { base.Content = value; }
    2323    }
     24
    2425    public IntervalConstraintView() {
    2526      InitializeComponent();
     
    2728      definitionInput.ReadOnly = true;
    2829      derivationInput.ReadOnly = true;
     30      if (derivationInput.Text == "False")
     31        numberderivationInput.ReadOnly = true;
    2932    }
    3033
     
    4649      base.OnContentChanged();
    4750      UpdateControls();
    48       UpdateValues();
    4951    }
     52
    5053
    5154    protected override void SetEnabledStateOfControls() {
     
    7881    }
    7982
    80     private void UpdateValues() {
     83    private void expressionInput_TextChanged(object sender, EventArgs e) {
    8184
     85    }
     86
     87    private void variableInput_TextChanged(object sender, EventArgs e) {
     88     
     89    }
     90
     91    private void numberderivationInput_TextChanged(object sender, EventArgs e) {
     92      if (int.TryParse(numberderivationInput.Text, out var derivation)) {
     93        if (derivation >= 0) {
     94          Content.NumberOfDerivation = derivation;
     95          errorProvider.SetError(numberderivationInput, string.Empty);
     96        } else {
     97          errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be positive!");
     98        }
     99      } else {
     100        errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be an integer!");
     101      }
     102    }
     103
     104    private void lowerboundInput_TextChanged(object sender, EventArgs e) {
     105      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
     106      if (!double.IsNaN(value)) {
     107        if (value <= Content.Interval.UpperBound) {
     108          Content.Interval = new Interval(value, Content.Interval.UpperBound);
     109          errorProvider.SetError(lowerboundInput, string.Empty);
     110        } else {
     111          errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be smaller than Upperbound!");
     112        }
     113      }
     114    }
     115
     116    private double ParseDoubleValue(string input, Control control) {
     117      input = input.ToLower();
     118      switch (input) {
     119        case "inf.":
     120        case "+inf.":
     121          return double.PositiveInfinity;
     122        case "-inf.":
     123          return double.NegativeInfinity;
     124        default: {
     125          if (double.TryParse(input, out var value))
     126            return value;
     127          else {
     128            errorProvider.SetError(control, "Invalid Input: Value must be a double!");
     129            return double.NaN;
     130          }
     131        }
     132      }
    82133    }
    83134  }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.resx

    r16772 r16774  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
     123  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     124    <value>57</value>
     125  </metadata>
    120126</root>
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs

    r16773 r16774  
    3232
    3333    private ItemList<IntervalConstraint> ParseConstraints(string input) {
    34       ItemList<IntervalConstraint> constraints = new ItemList<IntervalConstraint>(IntervalConstraintsParser.ParseInput(input, Content.TargetVariable, Content.AllowedVariables));
     34      ItemList<IntervalConstraint> constraints = new ItemList<IntervalConstraint>(IntervalConstraintsParser.ParseInput(input, Content.ProblemData.TargetVariable, Content.ProblemData.AllowedInputVariables));
    3535      return constraints;
    3636    }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.designer.cs

    r16772 r16774  
    3030      this.parseBtn = new System.Windows.Forms.Button();
    3131      this.label1 = new System.Windows.Forms.Label();
    32       this.groupBox2 = new System.Windows.Forms.GroupBox();
    3332      //this.constraintsOutput = new System.Windows.Forms.Label();
    3433      this.constraintsOutput = new HeuristicLab.Core.Views.ItemListView<IntervalConstraint>();
     
    3938      this.splitContainer1.SuspendLayout();
    4039      this.groupBox1.SuspendLayout();
    41       this.groupBox2.SuspendLayout();
    4240      this.SuspendLayout();
    4341      //
     
    5452      // splitContainer1.Panel2
    5553      //
    56       this.splitContainer1.Panel2.Controls.Add(this.groupBox2);
     54      this.splitContainer1.Panel2.Controls.Add(this.constraintsOutput);
    5755      this.splitContainer1.Size = new System.Drawing.Size(888, 629);
    5856      this.splitContainer1.SplitterDistance = 296;
     
    105103      this.label1.Text = resources.GetString("label1.Text");
    106104      //
    107       // groupBox2
    108       //
    109       this.groupBox2.Controls.Add(this.constraintsOutput);
    110       this.groupBox2.Controls.Add(this.errorOutput);
    111       this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
    112       this.groupBox2.Location = new System.Drawing.Point(0, 0);
    113       this.groupBox2.Name = "groupBox2";
    114       this.groupBox2.Size = new System.Drawing.Size(588, 629);
    115       this.groupBox2.TabIndex = 0;
    116       this.groupBox2.TabStop = false;
    117       this.groupBox2.Text = "Parsed Constraints";
    118       //
    119105      // constraintsOutput
    120106      //
     
    149135      this.groupBox1.ResumeLayout(false);
    150136      this.groupBox1.PerformLayout();
    151       this.groupBox2.ResumeLayout(false);
    152137      this.ResumeLayout(false);
    153138
     
    161146    private System.Windows.Forms.Label label1;
    162147    private System.Windows.Forms.TextBox constraintsInput;
    163     private System.Windows.Forms.GroupBox groupBox2;
    164148    private System.Windows.Forms.Label errorOutput;
    165149
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraint.cs

    r16773 r16774  
    1818    public bool InclusiveUpperBound { get; set; }
    1919    public bool IsDerivation { get; set; }
    20     public string Variable { get; set; }
     20
     21    private string variable;
     22    public string Variable {
     23      get => variable;
     24      set {
     25        if (value != variable) {
     26          variable = value;
     27          OnChanged(EventArgs.Empty);
     28        }
     29      }
     30    }
    2131    public int NumberOfDerivation { get; set; }
    2232
     
    5363      this.IsDerivation = original.IsDerivation;
    5464      this.Variable = original.Variable;
    55       this.NumberOfDerivation = NumberOfDerivation;
     65      this.NumberOfDerivation = original.NumberOfDerivation;
    5666    }
    5767
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraintsParser.cs

    r16773 r16774  
    4747    }
    4848
     49   
    4950    public static IEnumerable<IntervalConstraint> ParseInput(string input, string target = "", IEnumerable<string> variables = null) {
    5051      var lines = input.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
     
    132133        } else if (trimmedLine.StartsWith("#") || trimmedLine == "") {
    133134          //If it is a comment just continue without saving anything
    134           //TODO maybe save comment too.
    135135          continue;
    136136        } else {
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r16773 r16774  
    192192
    193193      Parameters.Add(new FixedValueParameter<NamedIntervals>(VariableRangesParameterName, namedIntervals));
    194       Parameters.Add(new FixedValueParameter<ParsedConstraint>(IntervalConstraintsParameterName, new ParsedConstraint(commentMessage, targetVariable, allowedInputVariables)));
     194      Parameters.Add(new FixedValueParameter<ParsedConstraint>(IntervalConstraintsParameterName, new ParsedConstraint(commentMessage, this)));
    195195      RegisterParameterEvents();
    196196    }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ParsedConstraint.cs

    r16773 r16774  
    2828    }
    2929
    30     protected string targetVariable;
    31     public string TargetVariable {
    32       get => targetVariable;
    33       set => targetVariable = value;
    34     }
     30    protected IRegressionProblemData problemData;
    3531
    36     protected IEnumerable<string> allowedVariables;
    37 
    38     public IEnumerable<string> AllowedVariables {
    39       get => allowedVariables;
    40       set => allowedVariables = value;
     32    public IRegressionProblemData ProblemData {
     33      get => problemData;
     34      set => problemData = value;
    4135    }
    4236
     
    5751    }
    5852
    59     public ParsedConstraint(string input, string targetVariable, IEnumerable<string> allowedVariables) {
     53    public ParsedConstraint(string input, IRegressionProblemData problemData) {
    6054      this.input = input;
    6155      this.constraints = new ItemList<IntervalConstraint>();
    62       this.targetVariable = targetVariable;
    63       this.allowedVariables = allowedVariables;
     56      this.problemData = problemData;
    6457    }
    6558
Note: See TracChangeset for help on using the changeset viewer.