COPASI API
4.16.103
|
#include <CNormalLogical.h>
Classes | |
class | SetOfSetsSorter |
class | SetSorter |
class | TemplateSet |
class | TemplateSetOfSets |
Public Types | |
typedef TemplateSet < CNormalChoiceLogical > | ChoiceSet |
typedef TemplateSetOfSets < CNormalChoiceLogical > | ChoiceSetOfSets |
typedef TemplateSet < CNormalLogicalItem > | ItemSet |
typedef TemplateSetOfSets < CNormalLogicalItem > | ItemSetOfSets |
Public Member Functions | |
CNormalLogical () | |
CNormalLogical (const CNormalLogical &src) | |
virtual CNormalBase * | copy () const |
ItemSetOfSets & | getAndSets () |
const ItemSetOfSets & | getAndSets () const |
ChoiceSetOfSets & | getChoices () |
const ChoiceSetOfSets & | getChoices () const |
bool | isNegated () const |
void | negate () |
bool | operator< (const CNormalLogical &rhs) const |
CNormalLogical & | operator= (const CNormalLogical &src) |
bool | operator== (const CNormalLogical &rhs) const |
void | setAndSets (const ItemSetOfSets &set) |
void | setChoices (const ChoiceSetOfSets &set) |
void | setIsNegated (bool negate) |
virtual bool | simplify () |
virtual std::string | toString () const |
virtual | ~CNormalLogical () |
![]() | |
virtual bool | areEqual (const CNormalBase &rhs) const |
virtual | ~CNormalBase () |
Static Public Member Functions | |
template<typename TYPE > | |
static void | cleanSet (const TemplateSet< TYPE > &s) |
template<typename TYPE > | |
static void | cleanSetOfSets (TemplateSetOfSets< TYPE > &s) |
template<typename TYPE > | |
static void | copySet (const TemplateSet< TYPE > &source, TemplateSet< TYPE > &target) |
Protected Member Functions | |
bool | evaluateExpression (const std::map< CNormalLogicalItem, bool > &truthValueMap) const |
bool | generateCanonicalDNF (ItemSetOfSets &tmpAndSet) const |
Static Protected Member Functions | |
template<typename TYPE > | |
static bool | convertAndOrToOrAnd (const TemplateSetOfSets< TYPE > &source, TemplateSetOfSets< TYPE > &target) |
template<typename TYPE > | |
static void | copySetOfSets (const TemplateSetOfSets< TYPE > &source, TemplateSetOfSets< TYPE > &target) |
static void | eliminateNullItems (const ItemSetOfSets &source, ItemSetOfSets &target, bool orSet) |
template<typename TYPE > | |
static bool | negateSetOfSets (const TemplateSetOfSets< TYPE > &source, TemplateSetOfSets< TYPE > &target) |
template<typename TYPE > | |
static bool | negateSets (const TemplateSet< TYPE > &source, TemplateSet< TYPE > &target) |
Protected Attributes | |
ItemSetOfSets | mAndSets |
ChoiceSetOfSets | mChoices |
bool | mNot |
Definition at line 36 of file CNormalLogical.h.
Definition at line 178 of file CNormalLogical.h.
Definition at line 179 of file CNormalLogical.h.
typedef TemplateSet< CNormalLogicalItem > CNormalLogical::ItemSet |
Definition at line 180 of file CNormalLogical.h.
Definition at line 181 of file CNormalLogical.h.
CNormalLogical::CNormalLogical | ( | ) |
Definition at line 33 of file CNormalLogical.cpp.
Referenced by copy().
CNormalLogical::CNormalLogical | ( | const CNormalLogical & | src | ) |
Definition at line 36 of file CNormalLogical.cpp.
References cleanSetOfSets(), copySetOfSets(), mAndSets, and mChoices.
|
virtual |
Definition at line 54 of file CNormalLogical.cpp.
References cleanSetOfSets(), mAndSets, and mChoices.
|
inlinestatic |
This routine calls delete an all pointers in the set.
Definition at line 272 of file CNormalLogical.h.
Referenced by cleanSetOfSets(), convertAndOrToOrAnd(), eliminateNullItems(), and simplify().
|
inlinestatic |
This routine calls cleanSet on all inner sets.
Definition at line 237 of file CNormalLogical.h.
References cleanSet().
Referenced by CNormalLogical(), convertAndOrToOrAnd(), eliminateNullItems(), normalize_variable_names(), operator=(), setAndSets(), setChoices(), simplify(), and ~CNormalLogical().
|
inlinestaticprotected |
Converts a set of AND combined sets of OR combined elements into a target set of OR combined sets of AND combined elements.
Definition at line 384 of file CNormalLogical.h.
References cleanSet(), and cleanSetOfSets().
Referenced by simplify().
|
virtual |
Implements CNormalBase.
Definition at line 60 of file CNormalLogical.cpp.
References CNormalLogical().
|
inlinestatic |
This routine makes a deep copy of all elements in the souce set and appends them to the target set.
Definition at line 256 of file CNormalLogical.h.
Referenced by copySetOfSets(), createLogical(), eliminateNullItems(), and simplify().
|
inlinestaticprotected |
This routine makes deep copies of all inner sets and appends them to the target set.
Definition at line 521 of file CNormalLogical.h.
References copySet().
Referenced by CNormalLogical(), operator=(), setAndSets(), setChoices(), and simplify().
|
staticprotected |
This methods checks wether there is something like A and !A in a set, if such an occurance is found, the whole set is converted to a set with either a false or a true item. For or combined items, this would be true, for and combined sets, it would be false. If there already are sets in the outer set, this set could be eliminated altogether.
Definition at line 1014 of file CNormalLogical.cpp.
References cleanSet(), cleanSetOfSets(), copySet(), CNormalLogicalItem::FALSE, CNormalLogicalItem::getType(), CNormalLogicalItem::negate(), CNormalLogicalItem::setType(), CNormalLogicalItem::simplify(), and CNormalLogicalItem::TRUE.
Referenced by simplify().
|
protected |
Given a map that associates each logical element with a truth value, this method evaluates the whole logical expression.
Definition at line 960 of file CNormalLogical.cpp.
References mAndSets.
Referenced by generateCanonicalDNF().
|
protected |
This method creates the canonical disjunctive normalform for a logical expression. The expression must not contain choices and no negated item sets or items. Since the method scales with exponentially, the number of logical individual logical items in the expression is limited to 16. The return value is true if the call succeeded and false otherwise.
Definition at line 845 of file CNormalLogical.cpp.
References evaluateExpression(), mAndSets, mChoices, CNormalLogicalItem::negate(), and CNormalLogicalItem::simplify().
Referenced by simplify().
CNormalLogical::ItemSetOfSets & CNormalLogical::getAndSets | ( | ) |
Definition at line 190 of file CNormalLogical.cpp.
References mAndSets.
Referenced by convertToCEvaluationNode(), createLogical(), normalize_variable_names(), and simplify().
const CNormalLogical::ItemSetOfSets & CNormalLogical::getAndSets | ( | ) | const |
CNormalLogical::ChoiceSetOfSets & CNormalLogical::getChoices | ( | ) |
Definition at line 180 of file CNormalLogical.cpp.
References mChoices.
Referenced by convertToCEvaluationNode(), createLogical(), normalize_variable_names(), and simplify().
const CNormalLogical::ChoiceSetOfSets & CNormalLogical::getChoices | ( | ) | const |
bool CNormalLogical::isNegated | ( | ) | const |
Definition at line 159 of file CNormalLogical.cpp.
References mNot.
Referenced by convertToCEvaluationNode(), and simplify().
void CNormalLogical::negate | ( | ) |
Definition at line 169 of file CNormalLogical.cpp.
References mNot.
Referenced by createLogical(), setIsNegated(), and simplify().
|
inlinestaticprotected |
Negates a set of sets with elements. The result of the operation is returned in target. The type of the result depends on the source. If the source was a set of AND combined sets of OR combined elements, the rersult will be a set of OR combined sets with AND combined elements.
Definition at line 326 of file CNormalLogical.h.
References negateSets().
Referenced by simplify().
|
inlinestaticprotected |
Negates a set of elements. The result of the operation is returned in target. The type of result depends on the source. If the source was a set of AND combined elements, the result is a set of OR combined elements and vice versa. target set.
Definition at line 292 of file CNormalLogical.h.
Referenced by negateSetOfSets(), and simplify().
bool CNormalLogical::operator< | ( | const CNormalLogical & | rhs | ) | const |
Definition at line 716 of file CNormalLogical.cpp.
CNormalLogical & CNormalLogical::operator= | ( | const CNormalLogical & | src | ) |
Definition at line 44 of file CNormalLogical.cpp.
References cleanSetOfSets(), copySetOfSets(), mAndSets, mChoices, and mNot.
bool CNormalLogical::operator== | ( | const CNormalLogical & | rhs | ) | const |
Converts a set of AND combined sets of OR combined elements into a target set of OR combined sets of AND combined elements. Negates a set of elements. The result of the operation is returned in target. The type of result depends on the source. If the source was a set of AND combined elements, the result is a set of OR combined elements and vice versa. target set. Negates a set of sets with elements. The result of the operation is returned in target. The type of the result depends on the source. If the source was a set of AND combined sets of OR combined elements, the rersult will be a set of OR combined sets with AND combined elements.
Definition at line 665 of file CNormalLogical.cpp.
References CNormalLogical::SetOfSetsSorter< TYPE >::isEqual(), mAndSets, mChoices, and mNot.
void CNormalLogical::setAndSets | ( | const ItemSetOfSets & | set | ) |
Definition at line 777 of file CNormalLogical.cpp.
References cleanSetOfSets(), copySetOfSets(), and mAndSets.
Referenced by normalize_variable_names().
void CNormalLogical::setChoices | ( | const ChoiceSetOfSets & | set | ) |
Definition at line 784 of file CNormalLogical.cpp.
References cleanSetOfSets(), copySetOfSets(), and mChoices.
Referenced by normalize_variable_names().
void CNormalLogical::setIsNegated | ( | bool | negate | ) |
|
virtual |
Out of some reason, I can not use the insert method becasuse this seems to lead to different results in certain cases. E.g. I had a itemSetOfSets with 17 entries and if I used the insert, only 15 eneded up in mAndItems, whereas when I copied them in a loop, all 17 ended up in mAndItems. This is strange and unsatisfying, but since sets can't be debuged that well, I didn't feel like digging into this. RG
Implements CNormalBase.
Definition at line 200 of file CNormalLogical.cpp.
References cleanSet(), cleanSetOfSets(), convertAndOrToOrAnd(), copySet(), copySetOfSets(), eliminateNullItems(), CNormalLogicalItem::FALSE, generateCanonicalDNF(), getAndSets(), getChoices(), CNormalLogicalItem::getType(), isNegated(), mAndSets, mChoices, mNot, CNormalLogicalItem::negate(), negate(), negateSetOfSets(), negateSets(), CNormalLogicalItem::setType(), and CNormalLogicalItem::TRUE.
Referenced by createLogical(), CNormalChoiceLogical::simplify(), and CNormalChoice::simplify().
|
virtual |
Implements CNormalBase.
Definition at line 65 of file CNormalLogical.cpp.
References mAndSets, mChoices, and mNot.
Referenced by operator<<(), CNormalChoiceLogical::toString(), and CNormalChoice::toString().
|
protected |
Definition at line 195 of file CNormalLogical.h.
Referenced by CNormalLogical(), evaluateExpression(), generateCanonicalDNF(), getAndSets(), operator<(), operator=(), operator==(), setAndSets(), simplify(), toString(), and ~CNormalLogical().
|
protected |
Definition at line 202 of file CNormalLogical.h.
Referenced by CNormalLogical(), generateCanonicalDNF(), getChoices(), operator<(), operator=(), operator==(), setChoices(), simplify(), toString(), and ~CNormalLogical().
|
protected |
Flag to specify whether the whole logical expression has to be negated.
Definition at line 188 of file CNormalLogical.h.
Referenced by isNegated(), negate(), operator<(), operator=(), operator==(), setIsNegated(), simplify(), and toString().