示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MTree{T}"/> class.
 /// </summary>
 /// <param name="minChildren">The minimum number of children nodes for a node.</param>
 /// <param name="maxChildren">The maximum number of children nodes for a node.</param>
 /// <param name="distanceMetric">
 ///     The distance metric to be used to calculate distances between data points.
 ///
 ///     The distance metric must satisfy the following properties:
 ///     <list type="bullet">
 ///         <item>
 ///             <description><c>d(a,b) = d(b,a)</c> for every <c>a</c> and <c>b</c> points (symmetry)</description>
 ///         </item>
 ///         <item>
 ///             <description><c>d(a,a) = 0</c> and <c>d(a,b) &gt; 0</c> for every <c>a != b</c> points (non-negativity)</description>
 ///         </item>
 ///         <item>
 ///             <description><c>d(a,b) &lt;= d(a,c) + d(c,b)</c> for every <c>a</c>, <c>b</c> and <c>c</c> points (triangle inequality)</description>
 ///         </item>
 ///     </list>
 /// </param>
 /// <param name="splitPolicy">The split policy to use. It consist of a partition and a promotion policy. <see cref="SplitPolicy{DATA}"/></param>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <c>minChildren</c> is less than 1
 /// or
 /// <c>maxChildren</c> is less than <c>minChildren</c>
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// <c>distanceMetric</c> is missing
 /// or
 /// <c>splitPolicy</c> is missing
 /// </exception>
 public MTree(
     Int32 minChildren,
     Int32 maxChildren,
     DistanceMetric <T> distanceMetric,
     ISplitPolicy <T> splitPolicy)
 {
     if (minChildren < 1)
     {
         throw new ArgumentOutOfRangeException(nameof(minChildren), CoreMessages.MinimumNumberOfChildNodesIsLessThan1);
     }
     if (minChildren >= maxChildren)
     {
         throw new ArgumentOutOfRangeException(nameof(maxChildren), CoreMessages.MaximumNumberOfChildNodesIsEqualToMinimum);
     }
     this.MinChildren       = minChildren;
     this.MaxChildren       = maxChildren;
     this.distanceMetric    = distanceMetric ?? throw new ArgumentNullException(nameof(distanceMetric));
     this.splitPolicy       = splitPolicy ?? throw new ArgumentNullException(nameof(splitPolicy));
     this.NumberOfDataItems = 0;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MTree{T}"/> class.
 /// </summary>
 /// <param name="distanceMetric">
 ///     The distance metric to be used to calculate distances between data points.
 ///
 ///     The distance metric must satisfy the following properties:
 ///     <list type="bullet">
 ///         <item>
 ///             <description><c>d(a,b) = d(b,a)</c> for every <c>a</c> and <c>b</c> points (symmetry)</description>
 ///         </item>
 ///         <item>
 ///             <description><c>d(a,a) = 0</c> and <c>d(a,b) &gt; 0</c> for every <c>a != b</c> points (non-negativity)</description>
 ///         </item>
 ///         <item>
 ///             <description><c>d(a,b) &lt;= d(a,c) + d(c,b)</c> for every <c>a</c>, <c>b</c> and <c>c</c> points (triangle inequality)</description>
 ///         </item>
 ///     </list>
 /// </param>
 /// <param name="splitPolicy">The split policy to use. It consist of a partition and a promotion policy. <see cref="SplitPolicy{DATA}"/></param>
 /// <exception cref="ArgumentNullException">
 /// <c>distanceMetric</c> is missing
 /// or
 /// <c>splitPolicy</c> is missing
 /// </exception>
 public MTree(DistanceMetric <T> distanceMetric, ISplitPolicy <T> splitPolicy)
     : this(DefaultMinChildren, 2 * DefaultMinChildren + 1, distanceMetric, splitPolicy)
 {
 }