public void TestSamplingDomain() { List <BinaryOption> samplingDomainBinary = new List <BinaryOption>(); samplingDomainBinary.Add(GlobalState.varModel.getBinaryOption("binOpt1")); samplingDomainBinary.Add(GlobalState.varModel.getBinaryOption("binOpt2")); samplingDomainBinary.Add(GlobalState.varModel.getBinaryOption("binOpt6")); ConfigurationBuilder.optionsToConsider.Add(SamplingStrategies.PAIRWISE, samplingDomainBinary); List <NumericOption> samplingDomainNumeric = new List <NumericOption>(); samplingDomainNumeric.Add(GlobalState.varModel.getNumericOption("numOpt1")); ExperimentalDesign exp = new CentralCompositeInscribedDesign(); exp.setSamplingDomain(samplingDomainNumeric); List <SamplingStrategies> binaryStrat = new List <SamplingStrategies>(); binaryStrat.Add(SamplingStrategies.PAIRWISE); List <ExperimentalDesign> exps = new List <ExperimentalDesign>(); exps.Add(exp); List <Configuration> confs = ConfigurationBuilder .buildConfigs(GlobalState.varModel, binaryStrat, exps, new List <HybridStrategy>()); Assert.AreEqual(6, confs.Count); // Due to how the space is modeled valid options can only contain root or in sampling // domain specified options foreach (Configuration conf in confs) { foreach (BinaryOption binOpt in conf.BinaryOptions.Keys) { if (binOpt.Name != "root") { Assert.True(samplingDomainBinary.Contains(binOpt)); } } foreach (NumericOption numOpt in conf.NumericOptions.Keys) { Assert.True(numOpt.Name == "numOpt1"); } } }
/// <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(""); }