souffle  2.0.2-371-g6315b36
Public Member Functions | Static Public Attributes | Protected Attributes
souffle::ram::analysis::ComplexityAnalysis Class Reference

A Ram Analysis for determining the number of relational operations in a condition / expression. More...

#include <Complexity.h>

Inheritance diagram for souffle::ram::analysis::ComplexityAnalysis:
Inheritance graph
Collaboration diagram for souffle::ram::analysis::ComplexityAnalysis:
Collaboration graph

Public Member Functions

 ComplexityAnalysis (const char *id)
 
int getComplexity (const Node *value) const
 Get complexity of a RAM expression/condition. More...
 
void run (const TranslationUnit &tUnit) override
 Run analysis for a RAM translation unit. More...
 
- Public Member Functions inherited from souffle::ram::analysis::Analysis
 Analysis (const char *id)
 
virtual const std::string & getName () const
 get name of the analysis More...
 
virtual void print (std::ostream &) const
 Print the analysis result in HTML format. More...
 
virtual ~Analysis ()=default
 

Static Public Attributes

static constexpr const char * name = "complexity-analysis"
 

Protected Attributes

RelationAnalysisra {nullptr}
 
- Protected Attributes inherited from souffle::ram::analysis::Analysis
std::string identifier
 name of analysis instance More...
 

Detailed Description

A Ram Analysis for determining the number of relational operations in a condition / expression.

Definition at line 41 of file Complexity.h.

Constructor & Destructor Documentation

◆ ComplexityAnalysis()

souffle::ram::analysis::ComplexityAnalysis::ComplexityAnalysis ( const char *  id)
inline

Definition at line 43 of file Complexity.h.

49 :
50  RelationAnalysis* ra{nullptr};

Member Function Documentation

◆ getComplexity()

int souffle::ram::analysis::ComplexityAnalysis::getComplexity ( const Node value) const

Get complexity of a RAM expression/condition.

Definition at line 38 of file Complexity.cpp.

39  {
40  return visit(conj.getLHS()) + visit(conj.getRHS());
41  }
42 
43  // negation
44  int visitNegation(const Negation& neg) override {
45  return visit(neg.getOperand());
46  }
47 
48  // existence check
49  int visitExistenceCheck(const ExistenceCheck&) override {
50  return 2;
51  }
52 
53  // provenance existence check
54  int visitProvenanceExistenceCheck(const ProvenanceExistenceCheck&) override {
55  return 2;
56  }
57 
58  // emptiness check
59  int visitEmptinessCheck(const EmptinessCheck& emptiness) override {
60  // emptiness check for nullary relations is for free; others have weight one
61  return (ra->lookup(emptiness.getRelation()).getArity() > 0) ? 1 : 0;
62  }
63 
64  // default rule
65  int visitNode(const Node&) override {
66  return 0;
67  }
68 
69  protected:
70  RelationAnalysis* ra{nullptr};
71  };
72 
73  assert((isA<Expression>(node) || isA<Condition>(node)) && "not an expression/condition/operation");
74  return ValueComplexityVisitor(ra).visit(node);
75 }
76 
77 } // namespace souffle::ram::analysis

References souffle::ram::Conjunction::getLHS(), and souffle::ram::Conjunction::getRHS().

Here is the call graph for this function:

◆ run()

void souffle::ram::analysis::ComplexityAnalysis::run ( const TranslationUnit translationUnit)
inlineoverridevirtual

Run analysis for a RAM translation unit.

Implements souffle::ram::analysis::Analysis.

Definition at line 47 of file Complexity.h.

49  :
50  RelationAnalysis* ra{nullptr};

Field Documentation

◆ name

constexpr const char* souffle::ram::analysis::ComplexityAnalysis::name = "complexity-analysis"
staticconstexpr

Definition at line 45 of file Complexity.h.

◆ ra

RelationAnalysis* souffle::ram::analysis::ComplexityAnalysis::ra {nullptr}
protected

Definition at line 57 of file Complexity.h.


The documentation for this class was generated from the following files:
souffle::ram::Relation::getArity
unsigned getArity() const
Get arity of relation.
Definition: Relation.h:86
souffle::ram::analysis::ComplexityAnalysis::ra
RelationAnalysis * ra
Definition: Complexity.h:57
souffle::ram::analysis::RelationAnalysis::lookup
const ram::Relation & lookup(const std::string &name) const
Definition: Relation.cpp:33