Example #1
0
        public static bool TestKExchange(string solver, int expected, int sampleSize, int k)
        {
            string loc = resolvePath(solver, "KexchangeSampling" + sampleSize + k + ".csv");
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("sampleSize", sampleSize.ToString());
            parameters.Add("k", k.ToString());
            KExchangeAlgorithm sampling = new KExchangeAlgorithm();

            sampling.setSamplingParameters(parameters);
            List <Configuration> result         = testNumeric(sampling);
            List <Configuration> expectedSample = ConfigurationReader.readConfigurations_Header_CSV(loc, GlobalState.varModel);

            return(containsAllMeasurements(result, expectedSample) && result.Count == expected);
        }
Example #2
0
        public void TestKExchange()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("sampleSize", "7");
            parameters.Add("k", "2");
            KExchangeAlgorithm sampling = new KExchangeAlgorithm();

            sampling.setSamplingParameters(parameters);
            testNumeric(sampling, EXPECTED_KEXCHANGE_7_2);
            parameters.Clear();
            sampling = new KExchangeAlgorithm();
            parameters.Add("sampleSize", "3");
            parameters.Add("k", "1");
            sampling.setSamplingParameters(parameters);
            testNumeric(sampling, EXPECTED_KEXCHANGE_3_1);
        }
Example #3
0
        /// <summary>
        ///
        /// Note: An experimental design might have parameters and also consider only a specific set of numeric options.
        ///         [option1,option3,...,optionN] param1:value param2:value
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public string performOneCommand_ExpDesign(string task)
        {
            // splits the task in design and parameters of the design
            string[] designAndParams = task.Split(new[] { ' ' }, 2);
            string   designName      = designAndParams[0];;



            // parsing of the parameters
            List <NumericOption>        optionsToConsider;
            Dictionary <string, string> parameter = new Dictionary <string, string>();
            List <ConfigurationOption>  temp      = new List <ConfigurationOption>();

            getParametersAndSamplingDomain(task, out parameter, out temp);
            optionsToConsider = temp.OfType <NumericOption>().ToList();

            if (optionsToConsider.Count == 0)
            {
                optionsToConsider = GlobalState.varModel.NumericOptions;
            }

            ExperimentalDesign expDesign;

            switch (designName.ToLower())
            {
            case COMMAND_EXPDESIGN_BOXBEHNKEN:
                expDesign = new BoxBehnkenDesign();
                break;

            case COMMAND_EXPDESIGN_CENTRALCOMPOSITE:
                expDesign = new CentralCompositeInscribedDesign();
                break;

            case COMMAND_EXPDESIGN_FULLFACTORIAL:
                expDesign = new FullFactorialDesign();
                break;

            case COMMAND_EXPDESIGN_FACTORIAL:
                expDesign = new FactorialDesign();
                break;

            case COMMAND_EXPDESIGN_HYPERSAMPLING:
                expDesign = new HyperSampling();
                break;

            case COMMAND_EXPDESIGN_ONEFACTORATATIME:
                expDesign = new OneFactorAtATime();
                break;

            case COMMAND_EXPDESIGN_KEXCHANGE:
                expDesign = new KExchangeAlgorithm();
                break;

            case COMMAND_EXPDESIGN_PLACKETTBURMAN:
                expDesign = new PlackettBurmanDesign();
                break;

            case COMMAND_EXPDESIGN_RANDOM:
                expDesign = new RandomSampling();
                break;

            //TODO:hybrids as bin/num
            //case COMMAND_HYBRID_DISTRIBUTION_AWARE:
            //    addHybridAsNumeric(new DistributionAware(), parameter.ContainsKey("validation"), parameter);
            //    return "";

            //case COMMAND_HYBRID_DISTRIBUTION_PRESERVING:
            //    addHybridAsNumeric(new DistributionPreserving(), parameter.ContainsKey("validation"), parameter);
            //    return "";

            default:
                return(task);
            }

            if (optionsToConsider.Count > 0)
            {
                expDesign.setSamplingDomain(optionsToConsider);
            }

            if ((expDesign is KExchangeAlgorithm || expDesign is RandomSampling) &&
                parameter.ContainsKey("sampleSize") && GlobalState.varModel != null)
            {
                int    maximumNumberNumVariants = computeNumberOfPossibleNumericVariants(GlobalState.varModel);
                String numberOfSamples;
                parameter.TryGetValue("sampleSize", out numberOfSamples);
                if (Double.Parse(numberOfSamples) > maximumNumberNumVariants)
                {
                    GlobalState.logInfo.logLine("The number of stated numeric variants exceeds the maximum number "
                                                + "of possible variants. Only " + maximumNumberNumVariants
                                                + " variants are possible. Switching to fullfactorial design.");
                    expDesign = new FullFactorialDesign();
                }
            }

            expDesign.setSamplingParameters(parameter);
            if (parameter.ContainsKey("validation"))
            {
                this.numericStrategiesValidation.Add(expDesign);
            }
            else
            {
                this.numericStrategies.Add(expDesign);
            }

            return("");
        }