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


C# Configuration.getBinaryOptions方法代码示例

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


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

示例1: checkConfigurationSAT

        /// <summary>
        /// Checks whether the boolean selection of a configuration is valid w.r.t. the variability model. Does not check for numeric options' correctness.
        /// </summary>
        /// <param name="c">The configuration that needs to be checked.</param>
        /// <param name="vm">The variability model that represents the context of the configuration.</param>
        /// <returns>True if it is a valid selection w.r.t. the VM, false otherwise</returns>
        public bool checkConfigurationSAT(Configuration c, VariabilityModel vm)
        {
            List<CspTerm> variables = new List<CspTerm>();
            Dictionary<BinaryOption, CspTerm> elemToTerm = new Dictionary<BinaryOption, CspTerm>();
            Dictionary<CspTerm, BinaryOption> termToElem = new Dictionary<CspTerm, BinaryOption>();
            ConstraintSystem S = CSPsolver.getConstraintSystem(out variables, out elemToTerm, out termToElem, vm);

            //Feature Selection
            foreach (BinaryOption binayOpt in elemToTerm.Keys)
            {
                CspTerm term = elemToTerm[binayOpt];
                if (c.getBinaryOptions(BinaryOption.BinaryValue.Selected).Contains(binayOpt))
                {
                    S.AddConstraints(S.Implies(S.True, term));
                }
                else
                {
                    S.AddConstraints(S.Implies(S.True, S.Not(term)));
                }
            }

            ConstraintSolverSolution sol = S.Solve();
            if (sol.HasFoundSolution)
            {
                int count = 0;
                foreach (CspTerm cT in variables)
                {
                    if (sol.GetIntegerValue(cT) == 1)
                        count++;
                }
                //-1??? Needs testing TODO
                if (count - 1 != c.getBinaryOptions(BinaryOption.BinaryValue.Selected).Count)
                {
                    return false;
                }
                return true;
            }
            else
                return false;
        }
开发者ID:ChristianKapfhammer,项目名称:SPLConqueror,代码行数:46,代码来源:CheckConfigurationSAT.cs

示例2: isInConfiguration

 /// <summary>
 /// Checks whether the interaction occurs in the configuration. Checks only for binary options, because numeric options are assumed to be always present
 /// </summary>
 /// <param name="c">The configuration for which we check whether it contains the interaction.</param>
 /// <returns>True if the interaction is present in the configuration, false otherwise.</returns>
 public bool isInConfiguration(Configuration c)
 {
     var selectedBinOptions = c.getBinaryOptions(BinaryOption.BinaryValue.Selected);
     foreach (var binOpt in this.binaryOptions)
     {
         if (!selectedBinOptions.Contains(binOpt))
             return false;
     }
     foreach (ConfigurationOption confOpt in this.binNumOptions)
     {
         if (confOpt is BinaryOption && selectedBinOptions.Contains(confOpt) == false)
             return false;
     }
     return true;
 }
开发者ID:AlexanderGrebhahn,项目名称:SPLConqueror,代码行数:20,代码来源:Interaction.cs


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