#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 System.Linq; using HEAL.Attic; using HeuristicLab.Common; using HeuristicLab.Core; namespace HeuristicLab.Problems.DataAnalysis { [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")] [Item("ProblemDataConstraints", "Represents constraints associated with a problem data.")] public class ProblemDataConstraint : 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 + "d'y'/d'x' in [0 .. 10]" + Environment.NewLine + "∂²'y'/∂'x'² in ]-1 .. inf.["; [Storable] private string input; public string Input { get => input; set { if (input == value) return; input = value; OnChanged(); } } [Storable] private IEnumerable constraints; public IEnumerable Constraints { get => constraints; set { if (constraints == value) return; constraints = value.ToList(); OnChanged(); } } [Storable] public IRegressionProblemData ProblemData { get; private set; } [StorableConstructor] protected ProblemDataConstraint(StorableConstructorFlag _) : base(_) { } protected ProblemDataConstraint(ProblemDataConstraint original, Cloner cloner) : base(original, cloner) { this.Input = original.Input; this.constraints = original.Constraints.Select(cloner.Clone).ToList(); this.ProblemData = cloner.Clone(original.ProblemData); } public override IDeepCloneable Clone(Cloner cloner) { return new ProblemDataConstraint(this, cloner); } public ProblemDataConstraint() : base() { this.Input = exampleInput; this.constraints = new List(); this.ProblemData = null; } public ProblemDataConstraint(IRegressionProblemData problemData) : base() { this.Input = exampleInput; this.constraints = new List(); this.ProblemData = problemData; } public event EventHandler Changed; protected virtual void OnChanged() { EventHandler handlers = Changed; if (handlers != null) handlers(this, EventArgs.Empty); } } }