本文整理汇总了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;
}
示例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;
}