[5143] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[9456] | 3 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[5143] | 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 HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
| 25 | using HeuristicLab.Operators;
|
---|
| 26 | using HeuristicLab.Parameters;
|
---|
| 27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 28 | using HeuristicLab.Selection;
|
---|
| 29 |
|
---|
| 30 | namespace HeuristicLab.Optimization.Operators {
|
---|
| 31 | public class RankAndCrowdingSorter : AlgorithmOperator {
|
---|
| 32 | public ValueLookupParameter<BoolArray> MaximizationParameter {
|
---|
| 33 | get { return (ValueLookupParameter<BoolArray>)Parameters["Maximization"]; }
|
---|
| 34 | }
|
---|
| 35 | public ScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
|
---|
| 36 | get { return (ScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; }
|
---|
| 37 | }
|
---|
| 38 | public ScopeTreeLookupParameter<IntValue> RankParameter {
|
---|
| 39 | get { return (ScopeTreeLookupParameter<IntValue>)Parameters["Rank"]; }
|
---|
| 40 | }
|
---|
| 41 | public ScopeTreeLookupParameter<DoubleValue> CrowdingDistanceParameter {
|
---|
| 42 | get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["CrowdingDistance"]; }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | [StorableConstructor]
|
---|
| 46 | protected RankAndCrowdingSorter(bool deserializing) : base(deserializing) { }
|
---|
| 47 | protected RankAndCrowdingSorter(RankAndCrowdingSorter original, Cloner cloner) : base(original, cloner) { }
|
---|
| 48 | public RankAndCrowdingSorter()
|
---|
| 49 | : base() {
|
---|
| 50 | Parameters.Add(new ValueLookupParameter<BoolArray>("Maximization", "For each objective a value that is true if that objective should be maximized, or false if it should be minimized."));
|
---|
| 51 | Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The vector of quality values."));
|
---|
| 52 | Parameters.Add(new ScopeTreeLookupParameter<IntValue>("Rank", "The rank of a solution (to which front it belongs)."));
|
---|
| 53 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("CrowdingDistance", "The crowding distance of a solution in a population."));
|
---|
| 54 |
|
---|
| 55 | FastNonDominatedSort fastNonDominatedSort = new FastNonDominatedSort();
|
---|
| 56 | UniformSubScopesProcessor subScopesProcessor = new UniformSubScopesProcessor();
|
---|
| 57 | CrowdingDistanceAssignment crowdingDistanceAssignment = new CrowdingDistanceAssignment();
|
---|
| 58 | CrowdedComparisonSorter crowdedComparisonSorter = new CrowdedComparisonSorter();
|
---|
| 59 | MergingReducer mergingReducer = new MergingReducer();
|
---|
| 60 |
|
---|
| 61 | fastNonDominatedSort.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
| 62 | fastNonDominatedSort.QualitiesParameter.ActualName = QualitiesParameter.Name;
|
---|
| 63 | fastNonDominatedSort.RankParameter.ActualName = RankParameter.Name;
|
---|
| 64 |
|
---|
| 65 | crowdingDistanceAssignment.CrowdingDistanceParameter.ActualName = CrowdingDistanceParameter.Name;
|
---|
| 66 | crowdingDistanceAssignment.QualitiesParameter.ActualName = QualitiesParameter.Name;
|
---|
| 67 |
|
---|
| 68 | crowdedComparisonSorter.CrowdingDistanceParameter.ActualName = CrowdingDistanceParameter.Name;
|
---|
| 69 | crowdedComparisonSorter.RankParameter.ActualName = RankParameter.Name;
|
---|
| 70 |
|
---|
| 71 | OperatorGraph.InitialOperator = fastNonDominatedSort;
|
---|
| 72 | fastNonDominatedSort.Successor = subScopesProcessor;
|
---|
| 73 | subScopesProcessor.Operator = crowdingDistanceAssignment;
|
---|
| 74 | crowdingDistanceAssignment.Successor = crowdedComparisonSorter;
|
---|
| 75 | crowdedComparisonSorter.Successor = null;
|
---|
| 76 | subScopesProcessor.Successor = mergingReducer;
|
---|
| 77 | mergingReducer.Successor = null;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 81 | return new RankAndCrowdingSorter(this, cloner);
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|