#region License Information /* HeuristicLab * Copyright (C) 2002-2015 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.Data; using HeuristicLab.Operators; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Algorithms.ALPS { [Item("OpenNewLayerCalculator", "")] [StorableClass] public class OpenNewLayerCalculator : SingleSuccessorOperator { private ILookupParameter AgeLimitsParameter { get { return (ILookupParameter)Parameters["AgeLimits"]; } } private ILookupParameter GenerationsParameter { get { return (ILookupParameter)Parameters["Generations"]; } } private ILookupParameter NumberOfLayersParameter { get { return (ILookupParameter)Parameters["NumberOfLayers"]; } } private ILookupParameter OpenLayersParameter { get { return (ILookupParameter)Parameters["OpenLayers"]; } } private ILookupParameter OpenNewLayerParameter { get { return (ILookupParameter)Parameters["OpenNewLayer"]; } } [StorableConstructor] private OpenNewLayerCalculator(bool deserializing) : base(deserializing) { } private OpenNewLayerCalculator(OpenNewLayerCalculator original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new OpenNewLayerCalculator(this, cloner); } public OpenNewLayerCalculator() : base() { Parameters.Add(new LookupParameter("AgeLimits")); Parameters.Add(new LookupParameter("Generations")); Parameters.Add(new LookupParameter("NumberOfLayers")); Parameters.Add(new LookupParameter("OpenLayers")); Parameters.Add(new LookupParameter("OpenNewLayer")); } public override IOperation Apply() { var ageLimits = AgeLimitsParameter.ActualValue; int generations = GenerationsParameter.ActualValue.Value; int numberOfLayers = NumberOfLayersParameter.ActualValue.Value; int openLayers = OpenLayersParameter.ActualValue.Value; var openNewLayer = OpenNewLayerParameter; openNewLayer.ActualValue = new BoolValue(openLayers < numberOfLayers && generations >= ageLimits[openLayers - 1]); return base.Apply(); } } }