Changeset 16778


Ignore:
Timestamp:
04/12/19 13:09:17 (9 days ago)
Author:
chaider
Message:

#2971

  • Changed field numberOfDerivation
  • Added numberOfDerivation to Expression string
  • Added numberOfDerivation to parser
Location:
branches/2971_named_intervals
Files:
6 edited

Legend:

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

    r16777 r16778  
    3737      this.lowerboundInput = new System.Windows.Forms.TextBox();
    3838      this.variableInput = new System.Windows.Forms.TextBox();
    39       this.numberderivationInput = new System.Windows.Forms.TextBox();
    4039      this.groupBox1 = new System.Windows.Forms.GroupBox();
    4140      this.ischeckedCheckBox = new System.Windows.Forms.CheckBox();
     
    4645      this.derivationInput = new System.Windows.Forms.CheckBox();
    4746      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     47      this.numberderivationInput = new System.Windows.Forms.ComboBox();
    4848      this.groupBox1.SuspendLayout();
    4949      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     
    162162      this.variableInput.TabIndex = 15;
    163163      //
    164       // numberderivationInput
    165       //
    166       this.numberderivationInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    167             | System.Windows.Forms.AnchorStyles.Right)));
    168       this.numberderivationInput.Location = new System.Drawing.Point(111, 221);
    169       this.numberderivationInput.Name = "numberderivationInput";
    170       this.numberderivationInput.Size = new System.Drawing.Size(470, 20);
    171       this.numberderivationInput.TabIndex = 17;
    172       this.numberderivationInput.Validating += new System.ComponentModel.CancelEventHandler(this.numberderivationInput_Validating);
    173       this.numberderivationInput.Validated += new System.EventHandler(this.numberderivationInput_Validated);
    174       //
    175164      // groupBox1
    176165      //
     166      this.groupBox1.Controls.Add(this.numberderivationInput);
    177167      this.groupBox1.Controls.Add(this.ischeckedCheckBox);
    178168      this.groupBox1.Controls.Add(this.expressionInput);
     
    181171      this.groupBox1.Controls.Add(this.incllowerboundInput);
    182172      this.groupBox1.Controls.Add(this.derivationInput);
    183       this.groupBox1.Controls.Add(this.numberderivationInput);
    184173      this.groupBox1.Controls.Add(this.variableInput);
    185174      this.groupBox1.Controls.Add(this.lowerboundInput);
     
    217206      this.expressionInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    218207            | System.Windows.Forms.AnchorStyles.Right)));
    219       this.expressionInput.Location = new System.Drawing.Point(108, 17);
     208      this.expressionInput.Location = new System.Drawing.Point(111, 17);
    220209      this.expressionInput.Name = "expressionInput";
    221210      this.expressionInput.Size = new System.Drawing.Size(473, 20);
     
    264253      this.errorProvider.ContainerControl = this;
    265254      this.errorProvider.RightToLeft = true;
     255      //
     256      // numberderivationInput
     257      //
     258      this.numberderivationInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     259            | System.Windows.Forms.AnchorStyles.Right)));
     260      this.numberderivationInput.FormattingEnabled = true;
     261      this.numberderivationInput.Location = new System.Drawing.Point(111, 224);
     262      this.numberderivationInput.Name = "numberderivationInput";
     263      this.numberderivationInput.Size = new System.Drawing.Size(470, 21);
     264      this.numberderivationInput.TabIndex = 27;
     265      this.numberderivationInput.SelectedIndexChanged += new System.EventHandler(this.numberderivationInput_SelectedIndexChanged);
    266266      //
    267267      // IntervalConstraintView
     
    291291    private System.Windows.Forms.TextBox lowerboundInput;
    292292    private System.Windows.Forms.TextBox variableInput;
    293     private System.Windows.Forms.TextBox numberderivationInput;
    294293    private System.Windows.Forms.GroupBox groupBox1;
    295294    private System.Windows.Forms.CheckBox derivationInput;
     
    300299    private System.Windows.Forms.ErrorProvider errorProvider;
    301300    private System.Windows.Forms.CheckBox ischeckedCheckBox;
     301    private System.Windows.Forms.ComboBox numberderivationInput;
    302302  }
    303303}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs

    r16777 r16778  
    2525    public IntervalConstraintView() {
    2626      InitializeComponent();
     27      int [] items = {1, 2, 3};
    2728      expressionInput.ReadOnly = true;
    2829      definitionInput.ReadOnly = true;
    2930      derivationInput.Enabled = false;
    3031      derivationInput.Checked = Content?.IsDerivation ?? false;
    31       if (Content != null && !Content.IsDerivation)
    32         numberderivationInput.ReadOnly = true;
     32      numberderivationInput.DataSource = items;
    3333    }
    3434
     
    8585        derivationInput.Checked = Content.IsDerivation;
    8686        variableInput.Text = Content.Variable;
    87         numberderivationInput.Text = Content.NumberOfDerivation.ToString();
     87        if (!Content.IsDerivation) {
     88          numberderivationInput.Enabled = false;
     89        } else {
     90          numberderivationInput.Enabled = true;
     91          numberderivationInput.SelectedItem = Content.NumberOfDerivation;
     92        }
    8893        ischeckedCheckBox.Checked = Content.IsChecked;
    89         //Content.Changed += Content_Changed;
    90 
     94        Content.Changed += Content_Changed;
    9195      }
    9296      SetEnabledStateOfControls();
     
    104108          (Content.InclusiveUpperBound) ? "]" : "[");
    105109      } else {
    106         expression = string.Format("\u2202Target/\u2202{0} in {1}{2} .. {3}{4}",
     110        expression = string.Format("\u2202{5}Target/\u2202{0}{6} in {1}{2} .. {3}{4}",
    107111          Content.Variable,
    108112          (Content.InclusiveLowerBound) ? "[" : "]",
    109113          Content.Interval.LowerBound,
    110114          Content.Interval.UpperBound,
    111           (Content.InclusiveUpperBound) ? "]" : "[");
     115          (Content.InclusiveUpperBound) ? "]" : "[",
     116          PrintNumberOfDerivation(Content.numberOfDerivation),
     117          PrintNumberOfDerivation(Content.numberOfDerivation));
    112118      }
    113119
     
    117123    }
    118124
     125    private string PrintNumberOfDerivation(int derivation) {
     126      switch (derivation) {
     127        case 1:
     128          return "";
     129        case 2:
     130          return "²";
     131        case 3:
     132          return "³";
     133        default:
     134          return "";
     135      }
     136    }
     137
    119138    #endregion
    120139
    121140    #region control event handlers
    122 
    123     private void numberderivationInput_Validating(object sender, CancelEventArgs e) {
    124       if (int.TryParse(numberderivationInput.Text, out var derivation)) {
    125         if (derivation >= 0) {
    126           errorProvider.SetError(numberderivationInput, string.Empty);
    127           e.Cancel = false;
    128         } else {
    129           errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be positive!");
    130           e.Cancel = true;
    131         }
    132       } else {
    133         errorProvider.SetError(numberderivationInput, "Invalid Input: Derivation must be an integer!");
    134         e.Cancel = true;
    135       }
    136     }
    137 
    138     private void numberderivationInput_Validated(object sender, EventArgs e) {
    139       if (int.TryParse(numberderivationInput.Text, out var derivation)) {
    140         Content.NumberOfDerivation = derivation;
    141         UpdateExpression();
    142       }
    143     }
    144 
    145141    private void lowerboundInput_Validating(object sender, CancelEventArgs e) {
    146142      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
     
    212208    }
    213209
     210    private void numberderivationInput_SelectedIndexChanged(object sender, EventArgs e) {
     211      if ((int)numberderivationInput.SelectedItem == 1)
     212        Content.numberOfDerivation = 1;
     213      else if ((int)numberderivationInput.SelectedItem == 2)
     214        Content.numberOfDerivation = 2;
     215      else if ((int)numberderivationInput.SelectedItem == 3)
     216        Content.numberOfDerivation = 3;
     217
     218      UpdateExpression();
     219    }
     220
    214221    #endregion
    215222
     
    221228
    222229    #endregion
     230
     231
    223232  }
    224233}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs

    r16777 r16778  
    3535      if (constraintsInput.Text != null) {
    3636        intervalConstraints = ParseConstraints(constraintsInput.Text);
     37        intervalConstraints.CheckedItemsChanged -= constraints_CheckedItemsChanged;
    3738        intervalConstraints.CheckedItemsChanged += constraints_CheckedItemsChanged;
    3839        constraintsOutput.Content = intervalConstraints;
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraint.cs

    r16777 r16778  
    4747      }
    4848    }
    49     public int NumberOfDerivation { get; set; }
     49
     50    public int numberOfDerivation;
     51    public int NumberOfDerivation {
     52      get => numberOfDerivation;
     53      set {
     54        if (value != numberOfDerivation) {
     55          numberOfDerivation = value;
     56          OnChanged(EventArgs.Empty);
     57        }
     58      }
     59    }
    5060
    5161    private bool isChecked;
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraintsParser.cs

    r16774 r16778  
    7171              var upperBound = ParseIntervalBounds(match.Groups[6].Value);
    7272              var constraint = new IntervalConstraint(match.Groups[0].Value);
    73               constraint.Expression = match.Groups[0].Value;
    74               constraint.Definition = "";
     73              constraint.Expression = "Target " + match.Groups[0].Value;
     74              constraint.Definition = "Target " + match.Groups[1].Value.Trim();
    7575              constraint.Variable = match.Groups[1].Value.Trim();
    7676              constraint.InclusiveLowerBound = match.Groups[3].Value.Trim() == "[";
     
    122122              constraint.InclusiveUpperBound = match.Groups[12].Value.Trim() == "]";
    123123              constraint.Variable = match.Groups[6].Value.Trim();
    124               constraint.NumberOfDerivation = ParseDerivationCount(match.Groups[2].Value);
     124              constraint.NumberOfDerivation = ParseDerivationCount(match.Groups[2].Value.Trim());
    125125              constraint.Interval = new Interval(lowerBound, upperBound);
    126126
     
    160160    private static int ParseDerivationCount(string input) {
    161161      switch (input) {
     162        case "":
     163          return 1;
    162164        case "²":
    163165          return 2;
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ParsedConstraint.cs

    r16777 r16778  
    1010using HeuristicLab.Data;
    1111using HeuristicLab.Parameters;
     12using HEAL.Attic;
    1213
    1314namespace HeuristicLab.Problems.DataAnalysis {
     15  [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")]
    1416  [Item("ParsedConstraint", "Represents parsed constraints.")]
    1517  public class ParsedConstraint : Item {
     
    2224
    2325    protected IEnumerable<IntervalConstraint> constraints;
    24 
    2526    public IEnumerable<IntervalConstraint> Constraints {
    2627      get => constraints;
     
    3233
    3334    protected IRegressionProblemData problemData;
    34 
    3535    public IRegressionProblemData ProblemData {
    3636      get => problemData;
Note: See TracChangeset for help on using the changeset viewer.