Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/16/09 11:24:03 (15 years ago)
Author:
vdorfer
Message:

Created API documentation for HeuristicLab.Random, HeuristicLab.SGA and HeuristicLab.Selection.OffspringSelection namespace (#331)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Random/UniformRandomizer.cs

    r763 r1153  
    2828
    2929namespace HeuristicLab.Random {
     30  /// <summary>
     31  /// Uniformly distributed random number generator.
     32  /// </summary>
    3033  public class UniformRandomizer : OperatorBase {
    3134    private static int MAX_NUMBER_OF_TRIES = 100;
     35    /// <inheritdoc select="summary"/>
    3236    public override string Description {
    3337      get { return "Initializes the value of variable 'Value' to a random value uniformly distributed between 'Min' and 'Max' (exclusive)"; }
    3438    }
    3539
     40    /// <summary>
     41    /// Gets or sets the maximum value of the random number generator (exclusive).
     42    /// </summary>
     43    /// <remarks>Gets or sets the variable with name <c>Max</c> through the
     44    /// <see cref="OperatorBase.GetVariable"/> method of class <see cref="OperatorBase"/>.</remarks>
    3645    public double Max {
    3746      get { return ((DoubleData)GetVariable("Max").Value).Data; }
    3847      set { ((DoubleData)GetVariable("Max").Value).Data = value; }
    3948    }
     49    /// <summary>
     50    /// Gets or sets the minimum value of the random number generator.
     51    /// </summary>
     52    /// <remarks>Gets or sets the variable with name <c>Min</c> through the
     53    /// <see cref="OperatorBase.GetVariable"/> method of class <see cref="OperatorBase"/>.</remarks>
    4054    public double Min {
    4155      get { return ((DoubleData)GetVariable("Min").Value).Data; }
     
    4357    }
    4458
     59    /// <summary>
     60    /// Initializes a new instance of <see cref="UniformRandomizer"/> with four variable infos
     61    /// (<c>Value</c>, <c>Random</c>, <c>Max</c> and <c>Min</c>), being a random number generator
     62    /// between 0.0 and 1.0.
     63    /// </summary>
    4564    public UniformRandomizer() {
    4665      AddVariableInfo(new VariableInfo("Value", "The value to manipulate (type is one of: IntData, ConstrainedIntData, DoubleData, ConstrainedDoubleData)", typeof(IObjectData), VariableKind.In));
     
    5574    }
    5675
     76    /// <summary>
     77    /// Generates a new uniformly distributed random variable.
     78    /// </summary>
     79    /// <param name="scope">The scope where to apply the random number generator.</param>
     80    /// <returns>null.</returns>
    5781    public override IOperation Apply(IScope scope) {
    5882      IObjectData value = GetVariableValue<IObjectData>("Value", scope, false);
     
    6589    }
    6690
     91    /// <summary>
     92    /// Generates a new random number depending on the type of the <paramref name="value"/>.
     93    /// </summary>
     94    /// <exception cref="ArgumentException">Thrown when an unhandleable type appears.</exception>
     95    /// <param name="value">The object whose data should be a new randomly generated number.</param>
     96    /// <param name="mt">The MersenneTwister to generate a new random number.</param>
     97    /// <param name="min">The left border of the interval in which the next random number has to lie.</param>
     98    /// <param name="max">The right border (exclusive) of the interval in which the next random number
     99    /// has to lie.</param>
    67100    private void RandomizeUniform(IObjectData value, MersenneTwister mt, double min, double max) {
    68101      // Dispatch manually based on dynamic type,
     
    79112    }
    80113
    81 
     114      /// <summary>
     115      /// Generates a new double random number.
     116      /// </summary>
     117      /// <param name="data">The double object which the new value is assigned to.</param>
     118      /// <param name="mt">The random number generator.</param>
     119      /// <param name="min">The left border of the interval in which the next random number has to lie.</param>
     120      /// <param name="max">The right border (exclusive) of the interval in which the next random number
     121      /// has to lie.</param>
    82122      public void RandomizeUniform(DoubleData data, MersenneTwister mt, double min, double max) {
    83123        data.Data = mt.NextDouble() * (max - min) + min;
    84124      }
    85125
     126      /// <summary>
     127      /// Generates a new int random number.
     128      /// </summary>
     129      /// <param name="data">The int object which the new value is assigned to.</param>
     130      /// <param name="mt">The random number generator.</param>
     131      /// <param name="min">The left border of the interval in which the next random number has to lie.</param>
     132      /// <param name="max">The right border (exclusive) of the interval in which the next random number
     133      /// has to lie.</param>
    86134      public void RandomizeUniform(IntData data, MersenneTwister mt, double min, double max) {
    87135        data.Data = (int)Math.Floor(mt.NextDouble() * (max - min) + min);
    88136      }
    89137
     138      /// <summary>
     139      /// Generates a new double random number, being restricted to some constraints.
     140      /// </summary>
     141      /// <exception cref="InvalidOperationException">Thrown when no valid value could be found.</exception>
     142      /// <param name="data">The double object which the new value is assigned to and whose constraints
     143      /// must be fulfilled.</param>
     144      /// <param name="mt">The random number generator.</param>
     145      /// <param name="min">The left border of the interval in which the next random number has to lie.</param>
     146      /// <param name="max">The right border (exclusive) of the interval in which the next random number
     147      /// has to lie.</param>
    90148      public void RandomizeUniform(ConstrainedDoubleData data, MersenneTwister mt, double min, double max) {
    91149        for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) {
     
    100158        throw new InvalidOperationException("Couldn't find a valid value");
    101159      }
    102 
     160      /// <summary>
     161      /// Generates a new int random number, being restricted to some constraints.
     162      /// </summary>
     163      /// <exception cref="InvalidOperationException">Thrown when no valid value could be found.</exception>
     164      /// <param name="data">The int object which the new value is assigned to and whose constraints
     165      /// must be fulfilled.</param>
     166      /// <param name="mt">The random number generator.</param>
     167      /// <param name="min">The left border of the interval in which the next random number has to lie.</param>
     168      /// <param name="max">The right border (exclusive) of the interval in which the next random number
     169      /// has to lie.</param>
    103170      public void RandomizeUniform(ConstrainedIntData data, MersenneTwister mt, double min, double max) {
    104171        for(int tries = MAX_NUMBER_OF_TRIES; tries >= 0; tries--) {
Note: See TracChangeset for help on using the changeset viewer.