- Timestamp:
- 11/26/08 10:29:34 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/Interfaces/IRandom.cs
r776 r817 48 48 /// Gets a new random number between 0 and <paramref name="maxVal"/>. 49 49 /// </summary> 50 /// <param name="maxVal">The maximal value of the random number .</param>51 /// <returns>A random integer number smaller than or equal to<paramref name="maxVal"/>.</returns>50 /// <param name="maxVal">The maximal value of the random number (exclusive).</param> 51 /// <returns>A random integer number smaller than <paramref name="maxVal"/>.</returns> 52 52 int Next(int maxVal); 53 53 /// <summary> 54 54 /// Gets a new random number between <paramref name="minVal"/> and <paramref name="maxVal"/>. 55 55 /// </summary> 56 /// <param name="maxVal">The maximal value of the random number .</param>57 /// <param name="minVal">The minimal value of the random number .</param>58 /// <returns>A random integer number. (<paramref name="minVal"/> <= x < = <paramref name="maxVal"/>.</returns>56 /// <param name="maxVal">The maximal value of the random number (exclusive).</param> 57 /// <param name="minVal">The minimal value of the random number (inclusive).</param> 58 /// <returns>A random integer number. (<paramref name="minVal"/> <= x < <paramref name="maxVal"/>).</returns> 59 59 int Next(int minVal, int maxVal); 60 60 /// <summary> -
trunk/sources/HeuristicLab.Selection/HeuristicLabSelectionPlugin.cs
r582 r817 26 26 27 27 namespace HeuristicLab.Selection { 28 /// <summary> 29 /// Plugin class for HeuristicLab.Selection plugin. 30 /// </summary> 28 31 [ClassInfo(Name = "HeuristicLab.Selection-3.2")] 29 32 [PluginFile(Filename = "HeuristicLab.Selection-3.2.dll", Filetype = PluginFileType.Assembly)] -
trunk/sources/HeuristicLab.Selection/LeftReducer.cs
r2 r817 27 27 28 28 namespace HeuristicLab.Selection { 29 /// <summary> 30 /// Takes only sub scopes from the left child of the tree. 31 /// </summary> 29 32 public class LeftReducer : ReducerBase { 33 /// <inheritdoc select="summary"/> 30 34 public override string Description { 31 35 get { return @"TODO\r\nOperator description still missing ..."; } 32 36 } 33 37 38 /// <summary> 39 /// Takes only the sub scopes from the left sub scope of the tree. 40 /// </summary> 41 /// <param name="scope">The current scope.</param> 42 /// <returns>All sub scopes from the left part of the tree.</returns> 34 43 protected override ICollection<IScope> Reduce(IScope scope) { 35 44 List<IScope> subScopes = new List<IScope>(); -
trunk/sources/HeuristicLab.Selection/LeftSelector.cs
r2 r817 26 26 27 27 namespace HeuristicLab.Selection { 28 /// <summary> 29 /// Copies or moves a defined number of sub scopes from a source scope to a target scope, starting at 30 /// the left side of the tree. 31 /// </summary> 28 32 public class LeftSelector : StochasticSelectorBase { 33 /// <inheritdoc select="summary"/> 29 34 public override string Description { 30 35 get { return @"TODO\r\nOperator description still missing ..."; } 31 36 } 32 37 38 /// <summary> 39 /// Copies or moves a number of sub scopes (<paramref name="selected"/>) from <paramref name="source"/> 40 /// starting at the left end to the <paramref name="target"/>. 41 /// </summary> 42 /// <param name="random">A random number generator.</param> 43 /// <param name="source">The source scope from which to copy/move the sub scopes.</param> 44 /// <param name="selected">The number of sub scopes to move. Can be also bigger than the total 45 /// number of sub scopes in <paramref name="source"/>, then the copying process starts again from the 46 /// beginning.</param> 47 /// <param name="target">The target where to copy/move the sub scopes.</param> 48 /// <param name="copySelected">Boolean flag whether the sub scopes shall be copied or moved.</param> 33 49 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 34 50 int index = 0; -
trunk/sources/HeuristicLab.Selection/LinearRankSelector.cs
r2 r817 27 27 28 28 namespace HeuristicLab.Selection { 29 /// <summary> 30 /// Selects scopes based on their rank, which has been determined through their quality. 31 /// </summary> 29 32 public class LinearRankSelector : StochasticSelectorBase { 33 /// <inheritdoc select="summary"/> 30 34 public override string Description { 31 35 get { return @"TODO\r\nOperator description still missing ..."; } 32 36 } 33 37 38 /// <summary> 39 /// Initializes a new instance of <see cref="LinearRankSelector"/> with the <c>CopySelected</c> flag 40 /// set to <c>true</c>. 41 /// </summary> 34 42 public LinearRankSelector() { 35 43 GetVariable("CopySelected").GetValue<BoolData>().Data = true; 36 44 } 37 45 46 /// <summary> 47 /// Copies or moves sub scopes from the given <paramref name="source"/> to the specified 48 /// <paramref name="target"/> according to their rank which is determined through their quality. 49 /// </summary> 50 /// <exception cref="InvalidOperationException">Thrown when no source sub scopes are available.</exception> 51 /// <param name="random">The random number generator.</param> 52 /// <param name="source">The source scope from where to copy/move the sub scopes.</param> 53 /// <param name="selected">The number of sub scopes to copy/move.</param> 54 /// <param name="target">The target scope where to add the sub scopes.</param> 55 /// <param name="copySelected">Boolean flag whether the sub scopes shall be moved or copied.</param> 38 56 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 39 57 int subScopes = source.SubScopes.Count; -
trunk/sources/HeuristicLab.Selection/MergingReducer.cs
r2 r817 27 27 28 28 namespace HeuristicLab.Selection { 29 /// <summary> 30 /// Merges all sub scopes of the children to one list. 31 /// </summary> 29 32 public class MergingReducer : ReducerBase { 33 /// <inheritdoc select="summary"/> 30 34 public override string Description { 31 35 get { return @"TODO\r\nOperator description still missing ..."; } 32 36 } 33 37 38 /// <summary> 39 /// Merges all sub scopes of the sub scopes of the current <paramref name="scope"/>. 40 /// </summary> 41 /// <param name="scope">The current scope whose sub scopes to merge.</param> 42 /// <returns>A list of all merged subscopes of the given <paramref name="scope"/>.</returns> 34 43 protected override ICollection<IScope> Reduce(IScope scope) { 35 44 List<IScope> subScopes = new List<IScope>(); -
trunk/sources/HeuristicLab.Selection/ProportionalSelector.cs
r772 r817 27 27 28 28 namespace HeuristicLab.Selection { 29 /// <summary> 30 /// Copies or moves a number of sub scopes from a source scope to a target scope, their probability 31 /// to be selected depending on their quality. 32 /// </summary> 29 33 public class ProportionalSelector : StochasticSelectorBase { 34 /// <inheritdoc select="summary"/> 30 35 public override string Description { 31 36 get { return @"TODO\r\nOperator description still missing ..."; } 32 37 } 33 38 39 /// <summary> 40 /// Initializes a new instance of <see cref="ProportionalSelector"/> with three variable infos 41 /// (<c>Maximization</c>, <c>Quality</c> and <c>Windowing</c>, being a local variable and initialized 42 /// with <c>true</c>) and the <c>CopySelected</c> flag set to <c>true</c>. 43 /// </summary> 34 44 public ProportionalSelector() { 35 45 AddVariableInfo(new VariableInfo("Maximization", "Maximization problem", typeof(BoolData), VariableKind.In)); … … 41 51 } 42 52 53 /// <summary> 54 /// Copies or movies a number of sub scopes (<paramref name="selected"/>) in the given 55 /// <paramref name="source"/> to the given <paramref name="target"/>, selection takes place with respect 56 /// to the quality of the scope. 57 /// </summary> 58 /// <param name="random">The random number generator.</param> 59 /// <param name="source">The source scope from where to copy/move the sub scopes.</param> 60 /// <param name="selected">The number of sub scopes to copy/move.</param> 61 /// <param name="target">The target scope where to add the sub scopes.</param> 62 /// <param name="copySelected">Boolean flag whether the sub scopes shall be moved or copied.</param> 43 63 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 44 64 bool maximization = GetVariableValue<BoolData>("Maximization", source, true).Data; … … 74 94 } 75 95 96 /// <summary> 97 /// Calculates the qualities of the sub scopes of the given <paramref name="source"/>. 98 /// </summary> 99 /// <exception cref="InvalidOperationException">Thrown when the sub scopes are not sorted according 100 /// to their solution qualities or if the quality value is beyond zero and the <c>windowing</c> 101 /// flag is set to <c>false</c>.</exception> 102 /// <param name="source">The scource scope where to calculate the qualities.</param> 103 /// <param name="maximization">Boolean flag whether is a maximization problem.</param> 104 /// <param name="qualityInfo">The quality variable info.</param> 105 /// <param name="windowing">Boolean flag whether the windowing strategy shall be applied.</param> 106 /// <param name="qualities">Output parameter; contains all qualities of the sub scopes.</param> 107 /// <param name="qualitySum">Output parameter; the sum of all qualities.</param> 76 108 private void GenerateQualitiesArray(IScope source, bool maximization, IVariableInfo qualityInfo, bool windowing, out double[] qualities, out double qualitySum) { 77 109 int subScopes = source.SubScopes.Count; -
trunk/sources/HeuristicLab.Selection/RandomSelector.cs
r2 r817 26 26 27 27 namespace HeuristicLab.Selection { 28 /// <summary> 29 /// Copies or moves a defined number of sub scopes from a source scope to a target scope, being selected 30 /// randomly. 31 /// </summary> 28 32 public class RandomSelector : StochasticSelectorBase { 33 /// <inheritdoc select="summary"/> 29 34 public override string Description { 30 35 get { return @"TODO\r\nOperator description still missing ..."; } 31 36 } 32 37 38 /// <summary> 39 /// Copies or moves a number of sub scopes (<paramref name="selected"/>) from <paramref name="source"/> 40 /// to the <paramref name="target"/>, chosen randomly. 41 /// </summary> 42 /// <param name="random">The random number generator.</param> 43 /// <param name="source">The source scope from which to copy/move the sub scopes.</param> 44 /// <param name="selected">The number of sub scopes to move.</param> 45 /// <param name="target">The target where to copy/move the sub scopes.</param> 46 /// <param name="copySelected">Boolean flag whether the sub scopes shall be copied or moved.</param> 33 47 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 34 48 for (int i = 0; i < selected; i++) { -
trunk/sources/HeuristicLab.Selection/ReducerBase.cs
r2 r817 27 27 28 28 namespace HeuristicLab.Selection { 29 /// <summary> 30 /// Base class for all reducers. 31 /// </summary> 29 32 public abstract class ReducerBase : OperatorBase { 33 /// <summary> 34 /// Reduces the given <paramref name="scope"/> so that it contains in the end only the reduced 35 /// elements. 36 /// </summary> 37 /// <remarks>Calls <see cref="Reduce"/>.</remarks> 38 /// <param name="scope">The scope to reduce.</param> 39 /// <returns><c>null</c>.</returns> 30 40 public override IOperation Apply(IScope scope) { 31 41 ICollection<IScope> subScopes = Reduce(scope); … … 40 50 } 41 51 52 /// <summary> 53 /// Reduces the current <paramref name="scope"/>. 54 /// </summary> 55 /// <param name="scope">The scope to reduce.</param> 56 /// <returns>The reduced list of scopes, that should be kept.</returns> 42 57 protected abstract ICollection<IScope> Reduce(IScope scope); 43 58 } -
trunk/sources/HeuristicLab.Selection/RightChildReducer.cs
r2 r817 27 27 28 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 /// </summary> 29 33 public class RightChildReducer : ReducerBase { 34 /// <inheritdoc select="summary"/> 30 35 public override string Description { 31 36 get { return @"TODO\r\nOperator description still missing ..."; } 32 37 } 33 38 39 /// <summary> 40 /// Reduces the right child of the left sub scope and adds its sub scopes to the right sub scope. 41 /// The left sub scope is also narrowed, which means it represents then its left child. 42 /// </summary> 43 /// <param name="scope">The current scope to reduce.</param> 44 /// <returns>A list of the new reduced sub scopes.</returns> 34 45 protected override ICollection<IScope> Reduce(IScope scope) { 35 46 IScope rightChild = scope.SubScopes[scope.SubScopes.Count - 1]; -
trunk/sources/HeuristicLab.Selection/RightReducer.cs
r2 r817 27 27 28 28 namespace HeuristicLab.Selection { 29 /// <summary> 30 /// Takes only sub scopes from the right child of the tree. 31 /// </summary> 29 32 public class RightReducer : ReducerBase { 33 /// <inheritdoc select="summary"/> 30 34 public override string Description { 31 35 get { return @"TODO\r\nOperator description still missing ..."; } 32 36 } 33 37 38 /// <summary> 39 /// Takes only the sub scopes from the right part of the tree. 40 /// </summary> 41 /// <param name="scope">The current scope.</param> 42 /// <returns>All sub scopes from the right sub scope of the tree.</returns> 34 43 protected override ICollection<IScope> Reduce(IScope scope) { 35 44 List<IScope> subScopes = new List<IScope>(); -
trunk/sources/HeuristicLab.Selection/RightSelector.cs
r2 r817 26 26 27 27 namespace HeuristicLab.Selection { 28 /// <summary> 29 /// Copies or moves a defined number of sub scopes from a source scope to a target scope, starting at 30 /// the right side of the tree. 31 /// </summary> 28 32 public class RightSelector : StochasticSelectorBase { 33 /// <inheritdoc select="summary"/> 29 34 public override string Description { 30 35 get { return @"TODO\r\nOperator description still missing ..."; } 31 36 } 32 37 38 /// <summary> 39 /// Copies or moves a number of sub scopes (<paramref name="selected"/>) from <paramref name="source"/> 40 /// starting at the right end to the <paramref name="target"/>. 41 /// </summary> 42 /// <param name="random">A random number generator.</param> 43 /// <param name="source">The source scope from which to copy/move the sub scopes.</param> 44 /// <param name="selected">The number of sub scopes to move. Can be also bigger than the total 45 /// number of sub scopes in <paramref name="source"/>, then the copying process starts again from the 46 /// beginning.</param> 47 /// <param name="target">The target where to copy/move the sub scopes.</param> 48 /// <param name="copySelected">Boolean flag whether the sub scopes shall be copied or moved.</param> 33 49 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 34 50 int index = source.SubScopes.Count - 1; -
trunk/sources/HeuristicLab.Selection/SelectorBase.cs
r2 r817 28 28 29 29 namespace HeuristicLab.Selection { 30 /// <summary> 31 /// Base class for all selectors. 32 /// </summary> 30 33 public abstract class SelectorBase : OperatorBase { 34 /// <summary> 35 /// Initializes a new instance of <see cref="SelectorBase"/> with one variable infos 36 /// (<c>CopySelected</c>), which is a local one. 37 /// </summary> 31 38 public SelectorBase() 32 39 : base() { … … 36 43 } 37 44 45 /// <summary> 46 /// Inserts a new level of sub scopes in the given <paramref name="scope"/> with a scope containing the 47 /// remaining sub scopes and another with the selected ones. 48 /// </summary> 49 /// <remarks>Calls <see cref="Select"/>.</remarks> 50 /// <param name="scope">The scope where to select the sub scopes.</param> 51 /// <returns><c>null</c>.</returns> 38 52 public override IOperation Apply(IScope scope) { 39 53 BoolData copySelected = GetVariableValue<BoolData>("CopySelected", scope, true); … … 54 68 } 55 69 70 /// <summary> 71 /// Selects sub scopes from the specified <paramref name="source"/> and moves or copies it to the 72 /// specified <paramref name="target"/>. 73 /// </summary> 74 /// <param name="source">The source scope where to select the sub scopes.</param> 75 /// <param name="target">The target where to add the sub scopes.</param> 76 /// <param name="copySelected">Boolean flag whether to copy or move the selected sub scopes.</param> 56 77 protected abstract void Select(IScope source, IScope target, bool copySelected); 57 78 } -
trunk/sources/HeuristicLab.Selection/StochasticSelectorBase.cs
r2 r817 28 28 29 29 namespace HeuristicLab.Selection { 30 /// <summary> 31 /// Base class for all selectors that use a random number generator. 32 /// </summary> 30 33 public abstract class StochasticSelectorBase : SelectorBase { 34 /// <summary> 35 /// Initializes a new instance of <see cref="StochasticSelectorBase"/> with two variable infos 36 /// (<c>Random</c> and <c>Selected</c>). 37 /// </summary> 31 38 public StochasticSelectorBase() 32 39 : base() { … … 35 42 } 36 43 44 /// <summary> 45 /// Copies or moves randomly chosen sub scopes from the given <paramref name="source"/> to the specified 46 /// <paramref name="target"/>. 47 /// </summary> 48 /// <remarks>Calls <see cref="Select(HeuristicLab.Core.IRandom, HeuristicLab.Core.IScope, int, 49 /// HeuristicLab.Core.IScope, bool)"/></remarks> 50 /// <param name="source">The source scope from where to copy/move the sub scopes.</param> 51 /// <param name="target">The target scope where to add the sub scopes.</param> 52 /// <param name="copySelected">Boolean flag whether the sub scopes shall be moved or copied.</param> 37 53 protected sealed override void Select(IScope source, IScope target, bool copySelected) { 38 54 IRandom random = GetVariableValue<IRandom>("Random", source, true); … … 42 58 } 43 59 60 /// <summary> 61 /// Copies or moves randomly chosen sub scopes from the given <paramref name="source"/> to the specified 62 /// <paramref name="target"/>. 63 /// </summary> 64 /// <param name="random">The random number generator.</param> 65 /// <param name="source">The source scope from where to copy/move the sub scopes.</param> 66 /// <param name="selected">The number of sub scopes to copy/move.</param> 67 /// <param name="target">The target scope where to add the sub scopes.</param> 68 /// <param name="copySelected">Boolean flag whether the sub scopes shall be moved or copied.</param> 44 69 protected abstract void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected); 45 70 } -
trunk/sources/HeuristicLab.Selection/TournamentSelector.cs
r77 r817 27 27 28 28 namespace HeuristicLab.Selection { 29 /// <summary> 30 /// Moves or copies a defined number of the best sub scopes from a source scope to a target scope. 31 /// </summary> 29 32 public class TournamentSelector : StochasticSelectorBase { 33 /// <inheritdoc select="summary"/> 30 34 public override string Description { 31 35 get { return @"TODO\r\nOperator description still missing ..."; } 32 36 } 33 37 38 /// <summary> 39 /// Initializes a new instance of <see cref="TournamentSelector"/> with three variable infos 40 /// (<c>Maximization</c>, <c>Quality</c> and <c>GroupSize</c>, being a local variable and set to 41 /// <c>2</c>) with <c>CopySelected</c> set to <c>true</c>. 42 /// </summary> 34 43 public TournamentSelector() { 35 44 AddVariableInfo(new VariableInfo("Maximization", "Maximization problem", typeof(BoolData), VariableKind.In)); … … 41 50 } 42 51 52 /// <summary> 53 /// Copies or moves the best sub scopes from the given <paramref name="source"/> to the specified 54 /// <paramref name="target"/>. 55 /// </summary> 56 /// <exception cref="InvalidOperationException">Thrown when no source sub scopes are available.</exception> 57 /// <param name="random">The random number generator.</param> 58 /// <param name="source">The source scope from where to copy/move the sub scopes.</param> 59 /// <param name="selected">The number of sub scopes to copy/move.</param> 60 /// <param name="target">The target scope where to add the sub scopes.</param> 61 /// <param name="copySelected">Boolean flag whether the sub scopes shall be moved or copied.</param> 43 62 protected override void Select(IRandom random, IScope source, int selected, IScope target, bool copySelected) { 44 63 IVariableInfo qualityInfo = GetVariableInfo("Quality");
Note: See TracChangeset
for help on using the changeset viewer.