Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 16881 was 16881, checked in by chaider, 5 years ago

#2971

  • removed unused constructors
  • changed creation of IntervalConstraint in IntervalConstraintParser
File size: 3.1 KB
Line 
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;
24using System.Collections.Generic;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HEAL.Attic;
28
29namespace HeuristicLab.Problems.DataAnalysis {
30  [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")]
31  [Item("ParsedConstraint", "Represents parsed constraints.")]
32  public class ParsedConstraint : Item {
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                                                  "d'y'/d'x' in [0 .. 10]" + Environment.NewLine +
37                                                  "\u2202²'y'/\u2202'x'² in ]-1 .. inf.[";
38     
39    public string Input { get; set; }
40
41    private IEnumerable<IntervalConstraint> constraints;
42    public IEnumerable<IntervalConstraint> Constraints {
43      get => constraints;
44      set {
45        constraints = value;
46        OnChanged(EventArgs.Empty);
47      }
48  }
49    public IRegressionProblemData ProblemData { get; set; }
50
51    [StorableConstructor]
52    protected ParsedConstraint(StorableConstructorFlag _) : base(_) { }
53
54    protected ParsedConstraint(ParsedConstraint original, Cloner cloner)
55      : base(original, cloner) {
56      this.Input = original.Input;
57      this.constraints = original.Constraints;
58      this.ProblemData = original.ProblemData;
59    }
60
61    public override IDeepCloneable Clone(Cloner cloner) {
62      return new ParsedConstraint(this, cloner);
63    }
64
65    public ParsedConstraint() :base () {
66      this.Input = exampleInput;
67      this.constraints = new CheckedItemList<IntervalConstraint>();
68      this.ProblemData = null;
69    }
70
71    public ParsedConstraint(IRegressionProblemData problemData) : base() {
72      this.Input = exampleInput;
73      this.constraints = new List<IntervalConstraint>();
74      this.ProblemData = problemData;
75    }
76
77    public event EventHandler Changed;
78    protected virtual void OnChanged(EventArgs e) {
79      EventHandler handlers = Changed;
80      if (handlers != null)
81        handlers(this, e);
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.