23 #ifndef CNormalLogical_H__
24 #define CNormalLogical_H__
39 template<
typename TYPE>
48 const std::pair<TYPE*, bool>& rhs)
const
55 if (lhs.second == rhs.second)
57 result = ((*lhs.first) < (*rhs.first));
59 else if (lhs.second ==
true)
71 bool isEqual(
const std::pair<TYPE*, bool>& lhs,
72 const std::pair<TYPE*, bool>& rhs)
const
76 if (!(lhs.second == rhs.second && (*lhs.first) == (*rhs.first)))
86 public std::set< std::pair< TYPE *, bool >, SetSorter< TYPE > > {};
88 template<
typename TYPE>
100 if (lhs.second == rhs.second)
102 if (lhs.first.size() == rhs.first.size())
104 typename std::set<std::pair<TYPE*, bool>,
CNormalLogical::SetSorter<TYPE> >::const_iterator it = lhs.first.begin(), endit = lhs.first.end(), it2 = rhs.first.begin();
107 while (it != endit && result ==
false)
111 if (sorter(*it2, *it) ==
true)
116 result = sorter(*it, *it2);
121 else if (lhs.first.size() < rhs.first.size())
126 else if (lhs.second ==
true)
143 if (lhs.second == rhs.second)
145 if (lhs.first.size() == rhs.first.size())
148 it = lhs.first.begin(),
149 endit = lhs.first.end(),
150 it2 = rhs.first.begin();
154 while (it != endit && result ==
true)
156 result = sorter.
isEqual(*it, *it2);
176 public std::set< std::pair< TemplateSet< TYPE >, bool >, SetOfSetsSorter< TYPE > > {};
215 virtual std::string
toString()
const;
236 template<
typename TYPE>
255 template<
typename TYPE>
262 bool tmpRes = target.insert(std::make_pair(
new TYPE(*it->first), it->second)).second;
263 assert(tmpRes ==
true);
271 template<
typename TYPE>
291 template<
typename TYPE>
300 if (it->second ==
false)
302 TYPE* pItem =
new TYPE(*it->first);
304 target.insert(std::make_pair(pItem,
false));
308 target.insert(std::make_pair(
new TYPE(*it->first),
false));
325 template<
typename TYPE>
332 while (it != endit && result ==
true)
336 if (it->second ==
false)
344 while (it2 != endit2)
346 tmpTarget.insert(std::make_pair(
new TYPE(*it2->first), it2->second));
351 target.insert(std::make_pair(tmpTarget,
false));
358 it = target.begin(), endit = target.end();
364 while (it2 != endit2)
383 template<
typename TYPE>
389 if (source.size() > 1)
392 tmpSourceSet.erase(tmpSourceSet.begin());
395 result = ((*source.begin()).second ==
false);
413 while (it2 != endit2)
416 TYPE* pNewItem =
new TYPE(*it->first);
418 if (tmpSet.insert(std::make_pair(pNewItem,
false)).second ==
false)
425 while (it3 != endit3)
427 pNewItem =
new TYPE(*(*it3).first);
429 if (tmpSet.insert(std::make_pair(pNewItem,
false)).second ==
false)
439 if (target.insert(std::make_pair(tmpSet,
false)).second ==
false)
453 else if (source.size() == 1)
456 if ((*source.begin()).second ==
true)
468 while (it != endit && result ==
true)
470 if (it->second ==
true)
477 TYPE* pNewItem =
new TYPE(*it->first);
478 tmpSet.insert(std::make_pair(pNewItem,
false));
480 if (target.insert(std::make_pair(tmpSet,
false)).second ==
false)
501 while (it2 != endit2)
520 template<
typename TYPE>
530 bool tmpRes = target.insert(std::make_pair(tmpSet, it->second)).second;
531 assert(tmpRes ==
true);
549 bool evaluateExpression(
const std::map<CNormalLogicalItem, bool>& truthValueMap)
const;
564 static void printSetElement(
const ItemSetOfSets& set,
unsigned int index1,
unsigned int index2);
565 #endif // COPASI_DEBUG
bool operator()(const std::pair< TemplateSet< TYPE >, bool > &lhs, const std::pair< TemplateSet< TYPE >, bool > &rhs) const
bool isEqual(const std::pair< TYPE *, bool > &lhs, const std::pair< TYPE *, bool > &rhs) const
static bool negateSets(const TemplateSet< TYPE > &source, TemplateSet< TYPE > &target)
ChoiceSetOfSets & getChoices()
static void eliminateNullItems(const ItemSetOfSets &source, ItemSetOfSets &target, bool orSet)
TemplateSet< CNormalLogicalItem > ItemSet
CNormalLogical & operator=(const CNormalLogical &src)
static void cleanSetOfSets(TemplateSetOfSets< TYPE > &s)
TemplateSetOfSets< CNormalChoiceLogical > ChoiceSetOfSets
bool evaluateExpression(const std::map< CNormalLogicalItem, bool > &truthValueMap) const
TemplateSetOfSets< CNormalLogicalItem > ItemSetOfSets
bool generateCanonicalDNF(ItemSetOfSets &tmpAndSet) const
virtual std::string toString() const
virtual ~CNormalLogical()
void setAndSets(const ItemSetOfSets &set)
static bool negateSetOfSets(const TemplateSetOfSets< TYPE > &source, TemplateSetOfSets< TYPE > &target)
static bool convertAndOrToOrAnd(const TemplateSetOfSets< TYPE > &source, TemplateSetOfSets< TYPE > &target)
void setChoices(const ChoiceSetOfSets &set)
static void cleanSet(const TemplateSet< TYPE > &s)
std::ostream & operator<<(std::ostream &os, const CNormalLogical &logical)
bool isEqual(const std::pair< TemplateSet< TYPE >, bool > &lhs, const std::pair< TemplateSet< TYPE >, bool > &rhs) const
static void copySetOfSets(const TemplateSetOfSets< TYPE > &source, TemplateSetOfSets< TYPE > &target)
bool operator<(const CNormalLogical &rhs) const
bool operator()(const std::pair< TYPE *, bool > &lhs, const std::pair< TYPE *, bool > &rhs) const
void setIsNegated(bool negate)
virtual CNormalBase * copy() const
static void copySet(const TemplateSet< TYPE > &source, TemplateSet< TYPE > &target)
TemplateSet< CNormalChoiceLogical > ChoiceSet
bool operator==(const CNormalLogical &rhs) const
ItemSetOfSets & getAndSets()