[17438] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using HEAL.Attic;
|
---|
| 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 |
|
---|
| 26 | namespace HeuristicLab.Algorithms.DynamicALPS
|
---|
| 27 | {
|
---|
| 28 | [StorableType("F405DFE4-CCC9-4CAF-9EFC-1AF45DC81FE6")]
|
---|
| 29 |
|
---|
| 30 | public interface IDynamicALPSSolution : IItem {
|
---|
| 31 | IItem Individual { get; set; }
|
---|
| 32 | double[] Qualities { get; set; }
|
---|
| 33 | double[] Constraints { get; set; }
|
---|
| 34 | // KF, SMS-EMOA
|
---|
| 35 | double[] HypervolumeContribution { get; set; }
|
---|
| 36 | int[] NondominanceRanking { get; set; }
|
---|
| 37 |
|
---|
| 38 | // KF, DynamicALPS, could also be used for any self-adpative EA
|
---|
| 39 | double IndividualPc { get; set; } // individual crossover rate
|
---|
| 40 | double IndividualPm { get; set; } // individual mutation rate
|
---|
| 41 | int Age { get; set; } // age info for ALPS
|
---|
| 42 |
|
---|
| 43 | int Dimensions { get; }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | [Item("DynamicALPSSolution", "Represents a solution inside the DynamicALPS population")]
|
---|
| 49 | [StorableType("457A8E67-2B70-4767-896B-47056BD89732")]
|
---|
| 50 | public class DynamicALPSSolution : Item, IDynamicALPSSolution
|
---|
| 51 | {
|
---|
| 52 | [Storable]
|
---|
| 53 | public IItem Individual { get; set; }
|
---|
| 54 |
|
---|
| 55 | [Storable]
|
---|
| 56 | public double[] Qualities { get; set; }
|
---|
| 57 |
|
---|
| 58 | [Storable]
|
---|
| 59 | public double[] Constraints { get; set; }
|
---|
| 60 |
|
---|
| 61 | //kf, sms-emoa
|
---|
| 62 | [Storable]
|
---|
| 63 | public double[] HypervolumeContribution { get; set; }
|
---|
| 64 |
|
---|
| 65 | [Storable]
|
---|
| 66 | public int[] NondominanceRanking { get; set; }
|
---|
| 67 |
|
---|
| 68 | [Storable]
|
---|
| 69 | public double IndividualPc { get; set; }
|
---|
| 70 |
|
---|
| 71 | [Storable]
|
---|
| 72 | public double IndividualPm { get; set; }
|
---|
| 73 |
|
---|
| 74 | [Storable]
|
---|
| 75 | public int Age { get; set; }
|
---|
| 76 |
|
---|
| 77 | public DynamicALPSSolution(int nObjectives, int nConstraints)
|
---|
| 78 | {
|
---|
| 79 | Qualities = new double[nObjectives];
|
---|
| 80 | Constraints = new double[nConstraints];
|
---|
| 81 | HypervolumeContribution = new double[1];
|
---|
| 82 | NondominanceRanking = new int[1];
|
---|
| 83 | IndividualPc = 0;
|
---|
| 84 | IndividualPm = 0;
|
---|
| 85 | Age = 0;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | public DynamicALPSSolution(IItem individual, int nObjectives, int nConstraints) : this(nObjectives, nConstraints)
|
---|
| 89 | {
|
---|
| 90 | Individual = individual;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | public DynamicALPSSolution(IItem individual, double[] qualities, double[] constraints, double[] hypervolumecontribution, int[] nondominanceranking)
|
---|
| 94 | {
|
---|
| 95 | Individual = individual;
|
---|
| 96 | Qualities = qualities;
|
---|
| 97 | Constraints = constraints;
|
---|
| 98 | HypervolumeContribution = hypervolumecontribution;
|
---|
| 99 | NondominanceRanking = nondominanceranking;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | public DynamicALPSSolution(double[] qualities)
|
---|
| 103 | {
|
---|
| 104 | Qualities = (double[])qualities.Clone();
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | public int Dimensions => Qualities == null ? 0 : Qualities.Length;
|
---|
| 108 |
|
---|
| 109 | public override IDeepCloneable Clone(Cloner cloner)
|
---|
| 110 | {
|
---|
| 111 | return new DynamicALPSSolution(this, cloner);
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | protected DynamicALPSSolution(DynamicALPSSolution original, Cloner cloner) : base(original, cloner)
|
---|
| 115 | {
|
---|
| 116 | Qualities = (double[])original.Qualities.Clone();
|
---|
[17479] | 117 | Constraints = (double[])original.Constraints.Clone();
|
---|
| 118 | if (original.HypervolumeContribution != null) {
|
---|
| 119 | HypervolumeContribution = (double[])original.HypervolumeContribution.Clone(); // kf, sms-emoa
|
---|
| 120 | }
|
---|
| 121 | if (original.NondominanceRanking != null) {
|
---|
| 122 | NondominanceRanking = (int[])original.NondominanceRanking.Clone(); // kf, sms-emoa
|
---|
| 123 | }
|
---|
| 124 | if (original.Individual != null) {
|
---|
| 125 | Individual = (IItem)original.Individual.Clone(cloner);
|
---|
| 126 | }
|
---|
[17438] | 127 | }
|
---|
| 128 |
|
---|
| 129 | [StorableConstructor]
|
---|
| 130 | protected DynamicALPSSolution(StorableConstructorFlag deserializing) : base(deserializing) { }
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | [Item("DynamicALPSSolution", "Represents a solution inside the DynamicALPS population")]
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | [StorableType("1EFC2459-C52E-4F95-9E14-23E69DCB23E0")]
|
---|
| 138 | public class DynamicALPSSolution<T> : DynamicALPSSolution where T : class, IItem
|
---|
| 139 | {
|
---|
| 140 | public new T Individual
|
---|
| 141 | {
|
---|
| 142 | get { return (T)base.Individual; }
|
---|
| 143 | set { base.Individual = value; }
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | public DynamicALPSSolution(T individual, int nObjectives, int nConstraints) : base(individual, nObjectives, nConstraints) { }
|
---|
| 147 |
|
---|
| 148 | protected DynamicALPSSolution(DynamicALPSSolution<T> original, Cloner cloner) : base(original, cloner) { }
|
---|
| 149 |
|
---|
| 150 | public override IDeepCloneable Clone(Cloner cloner)
|
---|
| 151 | {
|
---|
| 152 | return new DynamicALPSSolution<T>(this, cloner);
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | [StorableConstructor]
|
---|
| 156 | protected DynamicALPSSolution(StorableConstructorFlag deserializing) : base(deserializing) { }
|
---|
| 157 | }
|
---|
| 158 | }
|
---|