[16756] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using HeuristicLab.Common;
|
---|
| 4 | using HeuristicLab.Core;
|
---|
[16778] | 5 | using HEAL.Attic;
|
---|
[16756] | 6 |
|
---|
| 7 | namespace HeuristicLab.Problems.DataAnalysis {
|
---|
[16778] | 8 | [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")]
|
---|
[16756] | 9 | [Item("ParsedConstraint", "Represents parsed constraints.")]
|
---|
| 10 | public class ParsedConstraint : Item {
|
---|
[16800] | 11 | private static readonly string exampleInput = "#Example for a target variable constraint:" + Environment.NewLine +
|
---|
| 12 | "Target:y in [0 .. 100]" + Environment.NewLine + Environment.NewLine +
|
---|
| 13 | "#Example for constraint on model parameter: " + Environment.NewLine +
|
---|
| 14 | "dy/dx in [0 .. 10]" + Environment.NewLine +
|
---|
| 15 | "\u2202²y/\u2202x² in ]-1 .. inf.[";
|
---|
| 16 |
|
---|
| 17 | public string Input { get; set; }
|
---|
[16756] | 18 |
|
---|
[16800] | 19 | private IEnumerable<IntervalConstraint> constraints;
|
---|
[16756] | 20 | public IEnumerable<IntervalConstraint> Constraints {
|
---|
| 21 | get => constraints;
|
---|
[16776] | 22 | set {
|
---|
| 23 | constraints = value;
|
---|
| 24 | OnChanged(EventArgs.Empty);
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
[16800] | 27 | public IRegressionProblemData ProblemData { get; set; }
|
---|
[16756] | 28 |
|
---|
[16800] | 29 | [StorableConstructor]
|
---|
| 30 | protected ParsedConstraint(StorableConstructorFlag _) : base(_) { }
|
---|
[16773] | 31 |
|
---|
[16756] | 32 | protected ParsedConstraint(ParsedConstraint original, Cloner cloner)
|
---|
| 33 | : base(original, cloner) {
|
---|
[16800] | 34 | this.Input = original.Input;
|
---|
| 35 | this.constraints = original.Constraints;
|
---|
| 36 | this.ProblemData = original.ProblemData;
|
---|
[16756] | 37 | }
|
---|
| 38 |
|
---|
| 39 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 40 | return new ParsedConstraint(this, cloner);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public ParsedConstraint() {
|
---|
[16800] | 44 | this.Input = exampleInput;
|
---|
[16776] | 45 | this.constraints = new CheckedItemList<IntervalConstraint>();
|
---|
[16800] | 46 | this.ProblemData = null;
|
---|
[16756] | 47 | }
|
---|
| 48 |
|
---|
[16800] | 49 | public ParsedConstraint(IRegressionProblemData problemData) {
|
---|
| 50 | this.Input = exampleInput;
|
---|
| 51 | this.constraints = new List<IntervalConstraint>();
|
---|
| 52 | this.ProblemData = problemData;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[16774] | 55 | public ParsedConstraint(string input, IRegressionProblemData problemData) {
|
---|
[16800] | 56 | this.Input = input;
|
---|
[16776] | 57 | this.constraints = new CheckedItemList<IntervalConstraint>();
|
---|
[16800] | 58 | this.ProblemData = problemData;
|
---|
[16759] | 59 | }
|
---|
| 60 |
|
---|
[16756] | 61 | public ParsedConstraint(string input, IEnumerable<IntervalConstraint> constraints) {
|
---|
[16800] | 62 | this.Input = input;
|
---|
[16756] | 63 | this.constraints = constraints;
|
---|
| 64 | }
|
---|
[16776] | 65 |
|
---|
| 66 | public event EventHandler Changed;
|
---|
| 67 | protected virtual void OnChanged(EventArgs e) {
|
---|
| 68 | EventHandler handlers = Changed;
|
---|
| 69 | if (handlers != null)
|
---|
| 70 | handlers(this, e);
|
---|
| 71 | }
|
---|
[16756] | 72 | }
|
---|
| 73 | }
|
---|