Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ParsedConstraint.cs @ 16830

Last change on this file since 16830 was 16830, checked in by chaider, 6 years ago

#2971 Fixed review comments

File size: 3.5 KB
RevLine 
[16830]1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#endregion
23using System;
[16756]24using System.Collections.Generic;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
[16778]27using HEAL.Attic;
[16756]28
29namespace HeuristicLab.Problems.DataAnalysis {
[16778]30  [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")]
[16756]31  [Item("ParsedConstraint", "Represents parsed constraints.")]
32  public class ParsedConstraint : Item {
[16800]33    private static readonly string exampleInput = "#Example for a target variable constraint:" + Environment.NewLine +
34                                                  "Target:y in [0 .. 100]" + Environment.NewLine + Environment.NewLine +
35                                                  "#Example for constraint on model parameter: " + Environment.NewLine +
36                                                  "dy/dx in [0 .. 10]" + Environment.NewLine +
37                                                  "\u2202²y/\u2202x² in ]-1 .. inf.[";
38     
39    public string Input { get; set; }
[16756]40
[16800]41    private IEnumerable<IntervalConstraint> constraints;
[16756]42    public IEnumerable<IntervalConstraint> Constraints {
43      get => constraints;
[16776]44      set {
45        constraints = value;
46        OnChanged(EventArgs.Empty);
47      }
48  }
[16800]49    public IRegressionProblemData ProblemData { get; set; }
[16756]50
[16800]51    [StorableConstructor]
52    protected ParsedConstraint(StorableConstructorFlag _) : base(_) { }
[16773]53
[16756]54    protected ParsedConstraint(ParsedConstraint original, Cloner cloner)
55      : base(original, cloner) {
[16800]56      this.Input = original.Input;
57      this.constraints = original.Constraints;
58      this.ProblemData = original.ProblemData;
[16756]59    }
60
61    public override IDeepCloneable Clone(Cloner cloner) {
62      return new ParsedConstraint(this, cloner);
63    }
64
65    public ParsedConstraint() {
[16800]66      this.Input = exampleInput;
[16776]67      this.constraints = new CheckedItemList<IntervalConstraint>();
[16800]68      this.ProblemData = null;
[16756]69    }
70
[16800]71    public ParsedConstraint(IRegressionProblemData problemData) {
72      this.Input = exampleInput;
73      this.constraints = new List<IntervalConstraint>();
74      this.ProblemData = problemData;
75    }
76
[16774]77    public ParsedConstraint(string input, IRegressionProblemData problemData) {
[16800]78      this.Input = input;
[16776]79      this.constraints = new CheckedItemList<IntervalConstraint>();
[16800]80      this.ProblemData = problemData;
[16759]81    }
82
[16756]83    public ParsedConstraint(string input, IEnumerable<IntervalConstraint> constraints) {
[16800]84      this.Input = input;
[16756]85      this.constraints = constraints;
86    }
[16776]87
88    public event EventHandler Changed;
89    protected virtual void OnChanged(EventArgs e) {
90      EventHandler handlers = Changed;
91      if (handlers != null)
92        handlers(this, e);
93    }
[16756]94  }
95}
Note: See TracBrowser for help on using the repository browser.