本文整理汇总了C#中Predicate.Negate方法的典型用法代码示例。如果您正苦于以下问题:C# Predicate.Negate方法的具体用法?C# Predicate.Negate怎么用?C# Predicate.Negate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predicate
的用法示例。
在下文中一共展示了Predicate.Negate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KnowWhetherPredicate
public KnowWhetherPredicate(Predicate p)
: base("KW" + p.Name)
{
if (p.Negation)
{
Knowledge = p.Negate();
}
else
{
Knowledge = p;
}
}
示例2: KnowPredicate
public KnowPredicate(Predicate p, bool bValue, bool bParametrized)
: base("K" + p.Name)
{
Parametrized = bParametrized;
Value = bValue;
if (p.Negation)
{
Knowledge = p.Negate();
}
else
{
Knowledge = p;
}
}
示例3: ConsistentWith
public bool ConsistentWith(Predicate p, bool bCheckingActionPreconditions)
{
Predicate pNegate = p.Negate();
if (Observed.Contains(p))
return true;
if(Observed.Contains(pNegate))
return false;
if(m_sPredecessor == null)
return m_bsInitialBelief.ConsistentWith(p, true);
List<Formula> lRemovingPreconditions = new List<Formula>();
foreach (CompoundFormula cfCondition in GeneratingAction.GetConditions())
{
HashSet<Predicate> lEffects = new HashSet<Predicate>();
cfCondition.Operands[1].GetAllPredicates(lEffects);
if (lEffects.Contains(p))
{
if (m_sPredecessor.ConsistentWith(cfCondition.Operands[0], bCheckingActionPreconditions))
return true;
}
/*
if (lEffects.Contains(pNegate))
{
//condition removes p
//if condition must have happened, then p cannot be true
//if the negation of the condition is not consistent, then the condition must have happened
//if the negation of the condition is not consistent, p cannot be true
Formula fNegate = cfCondition.Operands[0].Negate();
bool bCnsistent = m_sPredecessor.ConsistentWith(fNegate);
if (!bCnsistent)
return false;
}
*/
if (lEffects.Contains(pNegate))
{
lRemovingPreconditions.Add(cfCondition.Operands[0]);
}
}
if (lRemovingPreconditions.Count > 0)
{
//if one of the removing conditions must have happened, then p cannot be true
//if the negation of (or f1 f2 ... fk) is not consistent, then one of f1 ... fk must be true
//if (and ~f1 ... ~fk) is not consistent then one of f1 ... fk must be true
//if (and ~f1 ... ~fk) is not consistent then p cannot be true
CompoundFormula cfAnd = new CompoundFormula("and");
foreach (Formula f in lRemovingPreconditions)
cfAnd.AddOperand(f.Negate());
bool bConsistent = m_sPredecessor.ConsistentWith(cfAnd, bCheckingActionPreconditions);
if (!bConsistent)
return false;
}
return m_sPredecessor.ConsistentWith(p, bCheckingActionPreconditions);
}
示例4: AddToObservedList
private bool AddToObservedList(Predicate p)
{
#if DEBUG
if (p.Name != "Choice" && !p.Negation)
{
Debug.Assert(UnderlyingEnvironmentState == null || (UnderlyingEnvironmentState.Contains(p)), "Adding a predicate that does not exist");
if (UnderlyingEnvironmentState != null && !UnderlyingEnvironmentState.Contains(p))
Console.WriteLine("Adding a predicate that does not exist");
}
#endif
if (m_lObserved.Contains(p))
return false;
Predicate pNegate = p.Negate();
if (m_lObserved.Contains(pNegate))
m_lObserved.Remove(pNegate);
m_lObserved.Add(p);
if (p.Negation)
p = pNegate;
Predicate pCanonical = p.Canonical();
if (m_lHidden.Contains(pCanonical))
m_lHidden.Remove(pCanonical);
return true;
}
示例5: AddEffect
private void AddEffect(Predicate pEffect)
{
if (Problem.Domain.IsFunctionExpression(pEffect.Name))
{
GroundedPredicate gpIncreaseDecrease = (GroundedPredicate)pEffect;
double dPreviousValue = m_sPredecessor.FunctionValues[gpIncreaseDecrease.Constants[0].Name];
double dDiff = double.Parse(gpIncreaseDecrease.Constants[1].Name);
double dNewValue = double.NaN;
if (gpIncreaseDecrease.Name.ToLower() == "increase")
dNewValue = dPreviousValue + dDiff;
else if (gpIncreaseDecrease.Name.ToLower() == "decrease")
dNewValue = dPreviousValue + dDiff;
else
throw new NotImplementedException();
FunctionValues[gpIncreaseDecrease.Constants[0].Name] = dNewValue;
}
else if (!Observed.Contains(pEffect))
{
Predicate pNegateEffect = pEffect.Negate();
if (Observed.Contains(pNegateEffect))
{
//Debug.WriteLine("Removing " + pNegateEffect);
m_lObserved.Remove(pNegateEffect);
}
//Debug.WriteLine("Adding " + pEffect);
AddObserved(pEffect);
}
}
示例6: AddEffect
private void AddEffect(Predicate pEffect)
{
if (pEffect.Name == Domain.FALSE_PREDICATE)
Debug.WriteLine("BUGBUG");
if (Problem.Domain.IsFunctionExpression(pEffect.Name))
{
GroundedPredicate gpIncreaseDecrease = (GroundedPredicate)pEffect;
double dPreviousValue = m_sPredecessor.FunctionValues[gpIncreaseDecrease.Constants[0].Name];
double dDiff = double.Parse(gpIncreaseDecrease.Constants[1].Name);
double dNewValue = double.NaN;
if (gpIncreaseDecrease.Name.ToLower() == "increase")
dNewValue = dPreviousValue + dDiff;
else if (gpIncreaseDecrease.Name.ToLower() == "decrease")
dNewValue = dPreviousValue + dDiff;
else
throw new NotImplementedException();
FunctionValues[gpIncreaseDecrease.Constants[0].Name] = dNewValue;
}
else if (!m_lPredicates.Contains(pEffect))
{
Predicate pNegateEffect = pEffect.Negate();
if (m_lPredicates.Contains(pNegateEffect))
{
//Debug.WriteLine("Removing " + pNegateEffect);
m_lPredicates.Remove(pNegateEffect);
}
/*
if (!pEffect.Negation)
{
//Debug.WriteLine("Adding " + pEffect);
m_lPredicates.Add(pEffect);
}
* */
m_lPredicates.Add(pEffect);//we are maintaining complete state information
}
}
示例7: Contains
public bool Contains(Predicate p)
{
if (p.Negation)
return !Predicates.Contains(p.Negate());
return Predicates.Contains(p);
}
示例8: GetPredicateIndex
private int GetPredicateIndex(Predicate p)
{
bool bNegate = p.Negation;
if (bNegate)
p = p.Negate();
if (!m_dSATVariables.ContainsKey(p))
{
m_dSATVariables[p] = m_dSATVariables.Count + 1;
m_lSATVariables.Add(p);
}
int idx = m_dSATVariables[p];
return idx;
}
示例9: AddObserved
public bool AddObserved(Predicate p)
{
bool bNew = false;
if (p.Name == Domain.TRUE_PREDICATE)
return false;
Debug.Assert(p.Name != Domain.FALSE_PREDICATE, "Adding P_FALSE");
#if DEBUG
if (UnderlyingEnvironmentState != null &&
((p.Negation == false && !UnderlyingEnvironmentState.Contains(p)) ||
(p.Negation == true && UnderlyingEnvironmentState.Contains(p.Negate()))))
Console.WriteLine("Adding a predicate that doesn't exist");
#endif
Unknown.Remove(p.Canonical());
if (!m_lObserved.Contains(p))
{
Predicate pNegate = p.Negate();
if(m_lObserved.Contains(pNegate))
m_lObserved.Remove(pNegate);
bNew = true;
}
m_lObserved.Add(p);
return bNew;
}
示例10: AddReasonedPredicate
private void AddReasonedPredicate(Predicate p)
{
if (p.Name == Domain.TRUE_PREDICATE)
return;
Debug.Assert(p.Name != Domain.FALSE_PREDICATE, "Adding P_FALSE to the state");
if (!m_lObserved.Contains(p))
{
if (p.Name != "Choice" && UnderlyingEnvironmentState != null)
{
if (p.Negation)
Debug.Assert(!UnderlyingEnvironmentState.Predicates.Contains(p.Negate()), "Adding the negation of a state variable" );
else
Debug.Assert(UnderlyingEnvironmentState.Predicates.Contains(p), "Adding the negation of a state variable");
}
AddObserved(p);
Debug.WriteLine("Reasoned: " + p);
Reasoned.Add(p.ToString());
}
}