Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/13/20 14:20:24 (4 years ago)
Author:
dleko
Message:

#2825 Bugfix: The correct number of reference points are returned on ReferencePoint.GetNumberOfGeneratedReferencePoints.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/Utility.cs

    r17664 r17667  
    66namespace HeuristicLab.Algorithms.NSGA3
    77{
    8     internal static class Utility
     8    public static class Utility
    99    {
    10         internal static List<T> Concat<T>(List<T> list1, List<T> list2)
     10        public static List<T> Concat<T>(List<T> list1, List<T> list2)
    1111        {
    1212            List<T> resultList = new List<T>(list1.Count + list2.Count);
     
    2525        /// <param name="r"></param>
    2626        /// <returns></returns>
    27         /// <exception cref="ArgumentException">
     27        /// <exception cref="InvalidOperationException">
    2828        /// Thrown, when <paramref name="r" /> &gt; <paramref name="n" /> or when <paramref name="r"
    2929        /// /> &lt; 1.
    3030        /// </exception>
    31         internal static int NCR(int n, int r)
     31        public static int NCR(int n, int r)
    3232        {
    33             if (n < r) throw new ArgumentException($"Constraint was not met: n >= r (n = {n}, r = {r})");
    34             if (r < 1) throw new ArgumentException($"Constraint was not met: r >= 1 (r = {r})");
    35             if (n == r) return n;
    36             return Factorial(n) / (Factorial(r) * Factorial(n - r));
     33            if (n < r) throw new InvalidOperationException($"Constraint was not met: n >= r (n = {n}, r = {r})");
     34            if (r < 1) throw new InvalidOperationException($"Constraint was not met: r >= 1 (r = {r})");
     35            if (n == r) return 1;
     36            return (int)(Factorial(n) / (Factorial(r) * Factorial(n - r)));
    3737        }
    3838
    39         internal static int Factorial(int n)
     39        public static long Factorial(int n)
    4040        {
    41             if (n <= 0) throw new ArgumentException($"Constraint for n was not met: 0 < n <= 30 (n = {n})");
    42             int product = 1;
     41            if (n < 0 || n > 30) throw new InvalidOperationException($"Constraint for n was not met: 0 <= n <= 30 (n = {n})");
     42            long product = 1;
    4343            for (int i = 2; i <= n; i++)
    4444                product *= i;
     
    4747        }
    4848
    49         internal static DoubleMatrix ConvertToDoubleMatrix(List<ReferencePoint> referencePoints)
     49        public static DoubleMatrix ConvertToDoubleMatrix(List<ReferencePoint> referencePoints)
    5050        {
    5151            return new DoubleMatrix(ToArray(referencePoints));
    5252        }
    5353
    54         internal static double[][] ToFitnessMatrix(this List<Solution> solutions)
     54        public static double[][] ToFitnessMatrix(this List<Solution> solutions)
    5555        {
    5656            double[][] data = new double[solutions.Count][];
     
    6868        }
    6969
    70         internal static DoubleMatrix ToMatrix(this IEnumerable<IReadOnlyList<double>> data)
     70        public static DoubleMatrix ToMatrix(this IEnumerable<IReadOnlyList<double>> data)
    7171        {
    7272            var d2 = data.ToArray();
     
    9292        }
    9393
    94         internal static TOut Min<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
     94        public static TOut Min<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
    9595        {
    9696            return MinArgMin(func, inputs).Item2;
    9797        }
    9898
    99         internal static TIn ArgMin<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
     99        public static TIn ArgMin<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
    100100        {
    101101            return MinArgMin(func, inputs).Item1;
     
    114114        /// </param>
    115115        /// <returns></returns>
    116         internal static Tuple<TIn, TOut> MinArgMin<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
     116        public static Tuple<TIn, TOut> MinArgMin<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
    117117        {
    118118            if (func == null) throw new ArgumentNullException(nameof(func));
     
    139139        }
    140140
    141         internal static TOut Max<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
     141        public static TOut Max<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
    142142        {
    143143            return MaxArgMax(func, inputs).Item2;
    144144        }
    145145
    146         internal static TIn ArgMax<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
     146        public static TIn ArgMax<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
    147147        {
    148148            return MaxArgMax(func, inputs).Item1;
     
    161161        /// </param>
    162162        /// <returns></returns>
    163         internal static Tuple<TIn, TOut> MaxArgMax<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
     163        public static Tuple<TIn, TOut> MaxArgMax<TIn, TOut>(Func<TIn, TOut> func, IEnumerable<TIn> inputs) where TOut : IComparable
    164164        {
    165165            if (func == null) throw new ArgumentNullException(nameof(func));
Note: See TracChangeset for help on using the changeset viewer.