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); } } }