当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.setMeasuredValue方法代码示例

本文整理汇总了C#中Configuration.setMeasuredValue方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.setMeasuredValue方法的具体用法?C# Configuration.setMeasuredValue怎么用?C# Configuration.setMeasuredValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Configuration的用法示例。


在下文中一共展示了Configuration.setMeasuredValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: performOneCommand


//.........这里部分代码省略.........
                            exp.addBinarySelection_Validation(vg.generateRandomVariants(GlobalState.varModel, treshold, modulu));
                            exp.addBinarySampling_Validation("random " + task);
                        }
                        else
                        {
                            exp.addBinarySelection_Learning(vg.generateRandomVariants(GlobalState.varModel, treshold, modulu));
                            exp.addBinarySampling_Learning("random " + task);
                        }
                        break;
                    }
                case COMMAND_START_LEARNING:
                    {
                        InfluenceModel infMod = new InfluenceModel(GlobalState.varModel, GlobalState.currentNFP);

                        List<Configuration> configurations_Learning = new List<Configuration>();

                        List<Configuration> configurations_Validation = new List<Configuration>();

                        if (exp.TrueModel == null)
                        {
                            //List<List<BinaryOption>> availableBinary
                            //configurations_Learning = GlobalState.getMeasuredConfigs(exp.BinarySelections_Learning, exp.NumericSelection_Learning);
                            configurations_Learning = GlobalState.getMeasuredConfigs(Configuration.getConfigurations(exp.BinarySelections_Learning, exp.NumericSelection_Learning));
                            configurations_Learning = configurations_Learning.Distinct().ToList();

                            configurations_Validation = GlobalState.getMeasuredConfigs(Configuration.getConfigurations(exp.BinarySelections_Validation, exp.NumericSelection_Validation));
                            configurations_Validation = configurations_Validation.Distinct().ToList();
                            //break;//todo only to get the configurations that we haven't measured
                        } else
                        {
                            foreach (List<BinaryOption> binConfig in exp.BinarySelections_Learning)
                            {
                                if (exp.NumericSelection_Learning.Count == 0)
                                {
                                    Configuration c = new Configuration(binConfig);
                                    c.setMeasuredValue(GlobalState.currentNFP, exp.TrueModel.eval(c));
                                    if (!configurations_Learning.Contains(c))
                                        configurations_Learning.Add(c);
                                    continue;
                                }
                                foreach (Dictionary<NumericOption, double> numConf in exp.NumericSelection_Learning)
                                {

                                    Configuration c = new Configuration(binConfig, numConf);
                                    c.setMeasuredValue(GlobalState.currentNFP, exp.TrueModel.eval(c));
                                    if(GlobalState.varModel.configurationIsValid(c))
                //                    if (!configurations_Learning.Contains(c))
                                        configurations_Learning.Add(c);
                                }
                            }

                        }
                            if (configurations_Learning.Count == 0)
                            {
                                configurations_Learning = configurations_Validation;
                            }

                            if (configurations_Learning.Count == 0)
                            {
                                GlobalState.logInfo.log("The learning set is empty! Cannot start learning!");
                                break;
                            }

                            if (configurations_Validation.Count == 0)
                            {
                                configurations_Validation = configurations_Learning;
                            }
                            //break;
                            GlobalState.logInfo.log("Learning: " + "NumberOfConfigurationsLearning:" + configurations_Learning.Count + " NumberOfConfigurationsValidation:" + configurations_Validation.Count
                            + " UnionNumberOfConfigurations:" + (configurations_Learning.Union(configurations_Validation)).Count());

                        // prepare the machine learning
                        exp.learning.init(infMod, exp.mlSettings);
                        exp.learning.setLearningSet(configurations_Learning);
                        exp.learning.setValidationSet(configurations_Validation);
                        exp.learning.learn();

                    }
                    break;

                case COMMAND_SAMPLE_NEGATIVE_OPTIONWISE:
                    // TODO there are two different variants in generating NegFW configurations.
                    NegFeatureWise neg = new NegFeatureWise();

                    if (taskAsParameter.Contains(COMMAND_VALIDATION))
                    {
                        exp.addBinarySelection_Validation(neg.generateNegativeFW(GlobalState.varModel));
                        exp.addBinarySampling_Validation("newFW");
                    }
                    else
                    {
                        exp.addBinarySelection_Learning(neg.generateNegativeFW(GlobalState.varModel));//neg.generateNegativeFWAllCombinations(GlobalState.varModel));
                        exp.addBinarySampling_Learning("newFW");
                    }
                    break;
                default:
                    return command;
            }
            return "";
        }
开发者ID:AlexanderGrebhahn,项目名称:SPLConqueror,代码行数:101,代码来源:Commands.cs

示例2: readCSVBinaryOptFormat

        private static List<Configuration> readCSVBinaryOptFormat(string file, VariabilityModel model)
        {
            List<Configuration> result = new List<Configuration>();
            StreamReader sr = new StreamReader(file);
            while (!sr.EndOfStream)
            {
                var line = sr.ReadLine().Split(';');
                List<BinaryOption> temp = new List<BinaryOption>();
                for (int i = 0; i < line.Length - 1; i++)
                {
                    BinaryOption b = model.getBinaryOption(line[i]);
                    temp.Add(b);
                }
                double value = Double.Parse(line[line.Length - 1].Replace(',', '.'));
                var c = new Configuration(temp);
                c.setMeasuredValue(GlobalState.currentNFP, value);
                result.Add(c);

            }
            sr.Close();
            return result;
        }
开发者ID:ChristianKapfhammer,项目名称:SPLConqueror,代码行数:22,代码来源:ConfigurationReader.cs

示例3: computeEvaluationDataSetBasedOnTrueModel

        /// <summary>
        /// The methods generates based on all binary sampling and 50% hyper sampling configurations for the validation set.
        /// If we have the true model, we can just compute the true value of the nonfunctional property for a given configuration. 
        /// </summary>
        private void computeEvaluationDataSetBasedOnTrueModel()
        {
            VariantGenerator vg = new VariantGenerator(null);
            List<List<BinaryOption>> temp = vg.generateAllVariantsFast(GlobalState.varModel);
            List<List<BinaryOption>> binaryConfigs = new List<List<BinaryOption>>();
            //take only 10k
            if (temp.Count > 1000)
            {
                GlobalState.logInfo.log("Found " + temp.Count + " configurations. Use only 1000.");
                HashSet<int> picked = new HashSet<int>();
                Random r = new Random(1);
                for (int i = 0; i < 1000; i++)
                {
                    int x = 0;
                    do
                    {
                        x = r.Next(1, temp.Count);
                    } while (picked.Contains(x));
                    picked.Add(x);
                    binaryConfigs.Add(temp[x]);
                }
                temp.Clear();
            }
            else
                binaryConfigs = temp;
            exp.addBinarySelection_Validation(binaryConfigs);
            var expDesign = new HyperSampling(GlobalState.varModel.NumericOptions);
            expDesign.Precision = 10;
            expDesign.computeDesign();
            exp.addNumericalSelection_Validation(expDesign.SelectedConfigurations);
            var numericConfigs = expDesign.SelectedConfigurations;
            foreach (List<BinaryOption> binConfig in binaryConfigs)
            {
                if (numericConfigs.Count == 0)
                {
                    Configuration c = new Configuration(binConfig);
                    c.setMeasuredValue(GlobalState.currentNFP, exp.TrueModel.eval(c));
                    GlobalState.addConfiguration(c);
                }
                foreach (Dictionary<NumericOption, double> numConf in numericConfigs)
                {

                    Configuration c = new Configuration(binConfig, numConf);
                    c.setMeasuredValue(GlobalState.currentNFP, exp.TrueModel.eval(c));
                    GlobalState.addConfiguration(c);
                }
            }
        }
开发者ID:AlexanderGrebhahn,项目名称:SPLConqueror,代码行数:52,代码来源:Commands.cs


注:本文中的Configuration.setMeasuredValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。