SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
ConflictGraph.h
Go to the documentation of this file.
1 /**
2  * @file ConflictGraph.h
3  * @ingroup cad
4  * @author Gereon Kremer <gereon.kremer@cs.rwth-aachen.de>
5  */
6 
7 #pragma once
8 
10 
11 #include <iostream>
12 #include <vector>
13 
14 namespace smtrat {
15 namespace cad {
16 
17 /**
18  * Representation of a bipartite graph (C+S, E) of vertices C and S, representing the constraints and samples, respectively.
19  *
20  * A vertex from C and a vertex from S are connected by an edge in E iff the corresponding constraint conflicts with the corresponding sample point.
21  */
22 
24 public:
25  friend std::ostream& operator<<(std::ostream& os, const ConflictGraph& cg);
26 private:
27  /// Stores for each constraints, which sample points violate the constraint.
28  std::vector<carl::Bitset> mData;
29  std::size_t mNextSID = 0;
30 public:
31  ConflictGraph(std::size_t constraints): mData(constraints) {}
32  std::size_t coveredSamples(std::size_t id) const {
33  return mData[id].count();
34  }
35  void addSample(const Sample& sample);
36 
37  /**
38  * Retrieves the constraint that covers the most samples.
39  */
40  std::size_t getMaxDegreeConstraint() const;
41 
42  /**
43  * Removes the given constraint and disable all sample points covered by this constraint.
44  */
45  void selectConstraint(std::size_t id);
46 
47  /**
48  * Selects all essential constraints and
49  * returns their indices
50  */
51  std::vector<size_t> selectEssentialConstraints();
52 
53  /**
54  * Returns a new ConflictGraph whose adjacency matrix consists
55  * only of the unique columns of the adjacency matrix of this graph.
56  */
58 
59  /**
60  * Checks if there are samples still uncovered.
61  */
62  bool hasRemainingSamples() const;
63 
64  std::size_t numSamples() const;
65 
66  std::size_t numRemainingConstraints() const;
67 
68  carl::Bitset getData(std::size_t id);
69 
70  std::vector<std::pair<std::size_t, carl::Bitset>> getRemainingConstraints();
71 
72 };
73 
74 std::ostream& operator<<(std::ostream& os, const ConflictGraph& cg);
75 
76 }
77 }
Representation of a bipartite graph (C+S, E) of vertices C and S, representing the constraints and sa...
Definition: ConflictGraph.h:23
ConflictGraph removeDuplicateColumns()
Returns a new ConflictGraph whose adjacency matrix consists only of the unique columns of the adjacen...
std::vector< std::pair< std::size_t, carl::Bitset > > getRemainingConstraints()
std::vector< size_t > selectEssentialConstraints()
Selects all essential constraints and returns their indices.
std::size_t numSamples() const
std::vector< carl::Bitset > mData
Stores for each constraints, which sample points violate the constraint.
Definition: ConflictGraph.h:28
friend std::ostream & operator<<(std::ostream &os, const ConflictGraph &cg)
void addSample(const Sample &sample)
ConflictGraph(std::size_t constraints)
Definition: ConflictGraph.h:31
bool hasRemainingSamples() const
Checks if there are samples still uncovered.
carl::Bitset getData(std::size_t id)
void selectConstraint(std::size_t id)
Removes the given constraint and disable all sample points covered by this constraint.
std::size_t numRemainingConstraints() const
std::size_t coveredSamples(std::size_t id) const
Definition: ConflictGraph.h:32
std::size_t getMaxDegreeConstraint() const
Retrieves the constraint that covers the most samples.
std::ostream & operator<<(std::ostream &os, const SampleIteratorQueue< I, C > &siq)
Class to create the formulas for axioms.