#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 HEAL.Attic; using HeuristicLab.Common; using HeuristicLab.Core; namespace HeuristicLab.Algorithms.DynamicALPS { [StorableType("F405DFE4-CCC9-4CAF-9EFC-1AF45DC81FE6")] public interface IDynamicALPSSolution : IItem { IItem Individual { get; set; } double[] Qualities { get; set; } double[] Constraints { get; set; } // KF, SMS-EMOA double[] HypervolumeContribution { get; set; } int[] NondominanceRanking { get; set; } // KF, DynamicALPS, could also be used for any self-adpative EA double IndividualPc { get; set; } // individual crossover rate double IndividualPm { get; set; } // individual mutation rate int Age { get; set; } // age info for ALPS int Dimensions { get; } } [Item("DynamicALPSSolution", "Represents a solution inside the DynamicALPS population")] [StorableType("457A8E67-2B70-4767-896B-47056BD89732")] public class DynamicALPSSolution : Item, IDynamicALPSSolution { [Storable] public IItem Individual { get; set; } [Storable] public double[] Qualities { get; set; } [Storable] public double[] Constraints { get; set; } //kf, sms-emoa [Storable] public double[] HypervolumeContribution { get; set; } [Storable] public int[] NondominanceRanking { get; set; } [Storable] public double IndividualPc { get; set; } [Storable] public double IndividualPm { get; set; } [Storable] public int Age { get; set; } public DynamicALPSSolution(int nObjectives, int nConstraints) { Qualities = new double[nObjectives]; Constraints = new double[nConstraints]; HypervolumeContribution = new double[1]; NondominanceRanking = new int[1]; IndividualPc = 0; IndividualPm = 0; Age = 0; } public DynamicALPSSolution(IItem individual, int nObjectives, int nConstraints) : this(nObjectives, nConstraints) { Individual = individual; } public DynamicALPSSolution(IItem individual, double[] qualities, double[] constraints, double[] hypervolumecontribution, int[] nondominanceranking) { Individual = individual; Qualities = qualities; Constraints = constraints; HypervolumeContribution = hypervolumecontribution; NondominanceRanking = nondominanceranking; } public DynamicALPSSolution(double[] qualities) { Qualities = (double[])qualities.Clone(); } public int Dimensions => Qualities == null ? 0 : Qualities.Length; public override IDeepCloneable Clone(Cloner cloner) { return new DynamicALPSSolution(this, cloner); } protected DynamicALPSSolution(DynamicALPSSolution original, Cloner cloner) : base(original, cloner) { Qualities = (double[])original.Qualities.Clone(); Constraints = (double[])original.Qualities.Clone(); HypervolumeContribution = (double[])original.HypervolumeContribution.Clone(); // kf, sms-emoa NondominanceRanking = (int[])original.NondominanceRanking.Clone(); // kf, sms-emoa Individual = (IItem)original.Individual.Clone(cloner); } [StorableConstructor] protected DynamicALPSSolution(StorableConstructorFlag deserializing) : base(deserializing) { } } [Item("DynamicALPSSolution", "Represents a solution inside the DynamicALPS population")] [StorableType("1EFC2459-C52E-4F95-9E14-23E69DCB23E0")] public class DynamicALPSSolution : DynamicALPSSolution where T : class, IItem { public new T Individual { get { return (T)base.Individual; } set { base.Individual = value; } } public DynamicALPSSolution(T individual, int nObjectives, int nConstraints) : base(individual, nObjectives, nConstraints) { } protected DynamicALPSSolution(DynamicALPSSolution original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new DynamicALPSSolution(this, cloner); } [StorableConstructor] protected DynamicALPSSolution(StorableConstructorFlag deserializing) : base(deserializing) { } } }