Free cookie consent management tool by TermsFeed Policy Generator

Changeset 788


Ignore:
Timestamp:
11/20/08 11:27:51 (16 years ago)
Author:
vdorfer
Message:

Fixed bug of ticket #375

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators/SubScopesMixer.cs

    r2 r788  
    2727
    2828namespace HeuristicLab.Operators {
     29  /// <summary>
     30  /// Mixes the sub scopes of a specified scope according to a specified number of partitions.
     31  /// </summary>
    2932  public class SubScopesMixer : OperatorBase {
     33    /// <inheritdoc select="summary"/>
    3034    public override string Description {
    3135      get { return @"TODO\r\nOperator description still missing ..."; }
    3236    }
    33 
     37    /// <summary>
     38    /// Initializes a new instance of <see cref="SubScopesMixer"/> with one variable infos
     39    /// (<c>Partitions</c>) and the <c>Local</c> flag set to <c>true</c>.
     40    /// </summary>
    3441    public SubScopesMixer()
    3542      : base() {
     
    3946    }
    4047
     48    /// <summary>
     49    /// Mixes the subscopes of the given <paramref name="scope"/>.
     50    /// </summary>
     51    /// <remarks>Calls <see cref="IScope.ReorderSubScopes"/>.<br/>
     52    /// Mixing of sub scopes is based on the number of partitions.
     53    /// <example>12 sub scopes and 3 partitions:<br/>
     54    /// Partition 1 contains sub scopes 1-4, partition 2 sub scopes 5-8 and partition 3 sub scopes 9-12. <br/>
     55    /// Mixing is realized by selecting at the beginning the first sub scope from partition one, then the
     56    /// first sub scope from partition 2, afterwards first sub scope from partition 3,
     57    /// then the second sub scope from the first partition and so on. <br/>
     58    /// In the end the new sorting of the sub scopes is 1-5-9-2-6-10-3-7-11-4-8-12.
     59    /// </example>
     60    /// </remarks>
     61    /// <param name="scope">The scope whose sub scopes should be mixed.</param>
     62    /// <returns><c>null</c>.</returns>
    4163    public override IOperation Apply(IScope scope) {
    4264      int partitions = GetVariableValue<IntData>("Partitions", scope, true).Data;
    4365      int[] sequence = new int[scope.SubScopes.Count];
     66      if ((sequence.Length % partitions) != 0)
     67        throw new ArgumentException("The number of subScopes is not divisible by the number of partitions without remainder.");
    4468      int partitionSize = sequence.Length / partitions;
    4569
Note: See TracChangeset for help on using the changeset viewer.