#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.SMSEMOA { [StorableType("A232DF5F-1499-4BED-A80F-8EE090F6F1F7")] public interface ISMSEMOASolution : IItem { IItem Individual { get; set; } double[] Qualities { get; set; } double[] Constraints { get; set; } // KF, SMS-EMOA double[] HypervolumeContribution { get; set; } int[] NondominanceRanking { get; set; } int Dimensions { get; } } [Item("SMSEMOASolution", "Represents a solution inside the SMSEMOA population")] [StorableType("DC19B54D-7D95-4CA0-83A0-2F9893064C23")] public class SMSEMOASolution : Item, ISMSEMOASolution { [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; } public SMSEMOASolution(int nObjectives, int nConstraints) { Qualities = new double[nObjectives]; Constraints = new double[nConstraints]; HypervolumeContribution = new double[1]; NondominanceRanking = new int[1]; } public SMSEMOASolution(IItem individual, int nObjectives, int nConstraints) : this(nObjectives, nConstraints) { Individual = individual; } public SMSEMOASolution(IItem individual, double[] qualities, double[] constraints, double[] hypervolumecontribution, int[] nondominanceranking) { Individual = individual; Qualities = qualities; Constraints = constraints; HypervolumeContribution = hypervolumecontribution; NondominanceRanking = nondominanceranking; } public SMSEMOASolution(double[] qualities) { Qualities = (double[])qualities.Clone(); } public int Dimensions => Qualities == null ? 0 : Qualities.Length; public override IDeepCloneable Clone(Cloner cloner) { return new SMSEMOASolution(this, cloner); } protected SMSEMOASolution(SMSEMOASolution 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 SMSEMOASolution(StorableConstructorFlag deserializing) : base(deserializing) { } } [Item("SMSEMOASolution", "Represents a solution inside the SMSEMOA population")] [StorableType("F33FFA68-9E0A-4C1B-964B-4F35BC6D78FC")] public class SMSEMOASolution : SMSEMOASolution where T : class, IItem { public new T Individual { get { return (T)base.Individual; } set { base.Individual = value; } } public SMSEMOASolution(T individual, int nObjectives, int nConstraints) : base(individual, nObjectives, nConstraints) { } protected SMSEMOASolution(SMSEMOASolution original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new SMSEMOASolution(this, cloner); } [StorableConstructor] protected SMSEMOASolution(StorableConstructorFlag deserializing) : base(deserializing) { } } }