#region License Information /* HeuristicLab * Copyright (C) 2002-2016 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 HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.GoalSeeking { [Item("InputParameter", "An object describing a target for the goal seeking.")] [StorableClass] public class InputParameter : NamedItem { [Storable] private double min; public double Min { get { return min; } set { if (double.IsNaN(value) || double.IsInfinity(value)) return; if (min.IsAlmost(value)) return; min = value; OnChanged(this, EventArgs.Empty); } } [Storable] private double max; public double Max { get { return max; } set { if (double.IsNaN(value) || double.IsInfinity(value)) return; if (max.IsAlmost(value)) return; max = value; OnChanged(this, EventArgs.Empty); } } [Storable] private double step; public double Step { get { return step; } set { if (double.IsNaN(value) || double.IsInfinity(value)) return; if (step.IsAlmost(value)) return; step = value; OnChanged(this, EventArgs.Empty); } } [Storable] private double value; public double Value { get { return value; } set { if (double.IsNaN(value) || double.IsInfinity(value)) return; if (this.value.IsAlmost(value)) return; this.value = value; OnChanged(this, EventArgs.Empty); } } [Storable] private bool active; public bool Active { get { return active; } set { if (active == value) return; active = value; OnChanged(this, EventArgs.Empty); } } public override string ToString() { return string.Format("{0} [active: {1}; value: {2}; min: {3}; max: {4}; step: {5}]", Name, Active, Value, Min, Max, Step); } protected InputParameter(InputParameter original, Cloner cloner) : base(original, cloner) { name = original.name; min = original.min; max = original.max; step = original.step; value = original.value; active = original.active; } public override IDeepCloneable Clone(Cloner cloner) { return new InputParameter(this, cloner); } [StorableConstructor] protected InputParameter(bool deserializing) : base(deserializing) { } public InputParameter(string name, double value, double min, double max, double step, bool active = true) { this.name = name; this.value = value; this.min = min; this.max = max; this.step = step; this.active = active; } public event EventHandler Changed; private void OnChanged(object sender, EventArgs args) { var changed = Changed; if (changed == null) return; changed(sender, args); } } }