Beispiel #1
0
 /// <summary>
 /// Samples the value space of one numeric option. The values are equal distributed. The number of values is defined by the <see cref="minNumberOfSamplingsPerNumericOption"/> field. The minimal and
 /// maximal value of the numeric option are not considered during the sampling.
 /// </summary>
 /// <param name="option">The numeric option to sample.</param>
 /// <returns>A list of equal distributed values for the numeric option. The list might be empty.</returns>
 public List <double> sampleOption(NumericOption option)
 {
     if (this.minNumberOfSamplingsPerNumericOption > option.getNumberOfSteps())
     {
         return(sampleOption(option, option.getNumberOfSteps(), false));
     }
     return(sampleOption(option, this.minNumberOfSamplingsPerNumericOption, false));
 }
Beispiel #2
0
        /*
         * in: VariableFeature vf; is the feature for which we have to know the sampling values
         * in: double percentage; range 0..1 the percentage of all values we need
         * out: void
         * Sets the maximum sampling size according to the percentage. The logarithm must be used, because the values of a single metric value multiplies with the values of all others leading to an exponential number
         * *****************/
        protected int setSamplingValue(NumericOption vf, double percentage)
        {
            double number = vf.getNumberOfSteps() * percentage;

            if (number < this.minNumberOfSamplingsPerNumericOption)
            {
                return(this.minNumberOfSamplingsPerNumericOption);
            }

            return(Convert.ToInt32(number));
        }
Beispiel #3
0
        /// <summary>
        /// Samples the value space of one numeric option. The values are equal distributed. If the numeric option has less values than the desired number of samplings, all values of the numeric option are
        /// returned.
        /// </summary>
        /// <param name="option">The numeric option to sample.</param>
        /// <param name="numberOfSamples">The number of different values of the numeric option.</param>
        /// <param name="useMinMaxValues">States whether the minimal and maximal value of the numeric option have to be considered during sampling.</param>
        /// <returns>A list of equal distributed values for the numeric option. The list might be empty.</returns>
        public static List <double> sampleOption(NumericOption option, long numberOfSamples, bool useMinMaxValues)
        {
            List <double> resultList = new List <double>();

            long numberOfValues = option.getNumberOfSteps();

            if (numberOfValues <= numberOfSamples)
            {
                double val = option.Min_value;
                for (int k = 0; k < numberOfValues; k++)
                {
                    resultList.Add(val);
                    val = option.getNextValue(val);
                }
                return(resultList);
            }

            if (useMinMaxValues)
            {
                resultList.Add(option.Min_value);
                resultList.Add(option.Max_value);

                numberOfSamples -= 2;
            }


            int offsetForOddNumberOfValues = 1;
            int offSetBetweenValues        = (int)Math.Round((double)(numberOfValues - 2 + offsetForOddNumberOfValues) / (double)(numberOfSamples + 1));

            double value = option.Min_value;

            for (int i = 0; i < numberOfSamples; i++)
            {
                int currNumSteps = 0;

                while (currNumSteps < offSetBetweenValues)
                {
                    value = option.getNextValue(value);
                    currNumSteps++;
                }
                resultList.Add(value);
            }
            resultList.Sort();
            return(resultList);
        }