#region License Information /* HeuristicLab * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using HeuristicLab.Common; using HeuristicLab.Core; using HEAL.Attic; namespace HeuristicLab.Problems.DataAnalysis { [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")] [Item("ParsedConstraint", "Represents parsed constraints.")] public class ParsedConstraint : Item { private static readonly string exampleInput = "#Example for a target variable constraint:" + Environment.NewLine + "Target:y in [0 .. 100]" + Environment.NewLine + Environment.NewLine + "#Example for constraint on model parameter: " + Environment.NewLine + "dy / dx in [0 .. 10]" + Environment.NewLine + "\u2202²y / \u2202x² in ]-1 .. inf.["; public string Input { get; set; } private IEnumerable constraints; public IEnumerable Constraints { get => constraints; set { constraints = value; OnChanged(EventArgs.Empty); } } public IRegressionProblemData ProblemData { get; set; } [StorableConstructor] protected ParsedConstraint(StorableConstructorFlag _) : base(_) { } protected ParsedConstraint(ParsedConstraint original, Cloner cloner) : base(original, cloner) { this.Input = original.Input; this.constraints = original.Constraints; this.ProblemData = original.ProblemData; } public override IDeepCloneable Clone(Cloner cloner) { return new ParsedConstraint(this, cloner); } public ParsedConstraint() { this.Input = exampleInput; this.constraints = new CheckedItemList(); this.ProblemData = null; } public ParsedConstraint(IRegressionProblemData problemData) { this.Input = exampleInput; this.constraints = new List(); this.ProblemData = problemData; } public ParsedConstraint(string input, IRegressionProblemData problemData) { this.Input = input; this.constraints = new CheckedItemList(); this.ProblemData = problemData; } public ParsedConstraint(string input, IEnumerable constraints) { this.Input = input; this.constraints = constraints; } public event EventHandler Changed; protected virtual void OnChanged(EventArgs e) { EventHandler handlers = Changed; if (handlers != null) handlers(this, e); } } }