1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 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 System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 | using HeuristicLab.Core;
|
---|
26 | using HeuristicLab.Operators;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Selection {
|
---|
29 | /// <summary>
|
---|
30 | /// Reduces the sub scopes by one level, so that the right sub scope contains also the right child scopes
|
---|
31 | /// of the left sub scope and the left sub scope represents its left child scope.
|
---|
32 | ///
|
---|
33 | /// scope scope
|
---|
34 | /// / | \ / \
|
---|
35 | /// L ... R => A R
|
---|
36 | /// / | \ \ / /\ \
|
---|
37 | /// A ... LR C C D E F
|
---|
38 | /// /|\
|
---|
39 | /// D E F
|
---|
40 | /// </summary>
|
---|
41 | public class RightChildReducer : ReducerBase {
|
---|
42 | /// <inheritdoc select="summary"/>
|
---|
43 | public override string Description {
|
---|
44 | get { return @"TODO\r\nOperator description still missing ..."; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | /// <summary>
|
---|
48 | /// Reduces the right child of the left sub scope and adds its sub scopes to the right sub scope.
|
---|
49 | /// The left sub scope is also narrowed, which means it represents then its left child.
|
---|
50 | /// </summary>
|
---|
51 | /// <param name="scope">The current scope to reduce.</param>
|
---|
52 | /// <returns>A list of the new reduced sub scopes.</returns>
|
---|
53 | protected override ICollection<IScope> Reduce(IScope scope) {
|
---|
54 | IScope rightChild = scope.SubScopes[scope.SubScopes.Count - 1];
|
---|
55 | IScope leftChild = scope.SubScopes[0];
|
---|
56 | IScope leftRightChild = leftChild.SubScopes[leftChild.SubScopes.Count - 1];
|
---|
57 |
|
---|
58 | // merge right children
|
---|
59 | for (int i = 0; i < leftRightChild.SubScopes.Count; i++)
|
---|
60 | rightChild.AddSubScope(leftRightChild.SubScopes[i]);
|
---|
61 |
|
---|
62 | leftChild = leftChild.SubScopes[0];
|
---|
63 |
|
---|
64 | List<IScope> subScopes = new List<IScope>();
|
---|
65 | subScopes.Add(leftChild);
|
---|
66 | subScopes.Add(rightChild);
|
---|
67 | return subScopes;
|
---|
68 | }
|
---|
69 | }
|
---|
70 | }
|
---|