23#ifndef GENERIC_CIRCUIT_H
24#define GENERIC_CIRCUIT_H
29#include <boost/archive/binary_oarchive.hpp>
30#include <boost/serialization/unordered_map.hpp>
31#include <boost/serialization/map.hpp>
32#include <boost/serialization/set.hpp>
33#include <boost/serialization/vector.hpp>
51std::map<gate_t, std::pair<unsigned,unsigned> >
infos;
52std::map<gate_t, std::string>
extra;
63 return "<GenericCircuit>";
74 infos[g]=std::make_pair(info1, info2);
84 auto it =
infos.find(g);
86 return std::make_pair(-1, -1);
107 auto it =
extra.find(g);
135 prob[
static_cast<std::underlying_type<gate_t>::type
>(g)]=p;
144 return prob[
static_cast<std::underlying_type<gate_t>::type
>(g)];
152template<
class Archive>
153void serialize (Archive & ar,
const unsigned int version)
182template<
typename S, std::enable_if_t<std::is_base_of_v<semiring::Semiring<
typename S::value_type>, S>,
int> = 0>
183typename S::value_type
evaluate(
gate_t g, std::unordered_map<gate_t, typename S::value_type> &provenance_mapping, S
semiring)
const;
Generic directed-acyclic-graph circuit template and gate identifier.
gate_t
Strongly-typed gate identifier.
Abstract semiring interface for provenance evaluation.
Generic template base class for provenance circuits.
std::string uuid
UUID type used in this circuit (always std::string).
std::unordered_map< gate_t, uuid > id2uuid
Gate index → UUID string.
std::unordered_map< uuid, gate_t > uuid2id
UUID string → gate index.
std::vector< gate_type > gates
Gate type for each gate.
std::vector< std::vector< gate_t > > wires
Child wire lists for each gate.
In-memory provenance circuit with semiring-generic evaluation.
std::map< gate_t, std::pair< unsigned, unsigned > > infos
Per-gate (info1, info2) annotations.
S::value_type evaluate(gate_t g, std::unordered_map< gate_t, typename S::value_type > &provenance_mapping, S semiring) const
Evaluate the sub-circuit rooted at gate g over semiring semiring.
std::map< gate_t, std::string > extra
Per-gate string extras.
gate_t addGate() override
Allocate a new gate with a default-initialised type.
std::set< gate_t > inputs
Set of input (leaf) gate IDs.
void serialize(Archive &ar, const unsigned int version)
Boost serialisation support.
std::vector< double > prob
Per-gate probability values.
void setInfos(gate_t g, unsigned info1, unsigned info2)
Set the integer annotation pair for gate g.
std::string getExtra(gate_t g) const
Return the string extra for gate g.
gate_t setGate(gate_type type) override
Allocate a new gate with type type and no UUID.
double getProb(gate_t g) const
Return the probability for gate g.
friend class boost::serialization::access
const std::set< gate_t > & getInputs() const
Return the set of input (leaf) gates.
std::pair< unsigned, unsigned > getInfos(gate_t g) const
Return the integer annotation pair for gate g.
void setExtra(gate_t g, const std::string &ex)
Attach a string extra to gate g.
virtual std::string toString(gate_t g) const override
Return a placeholder debug string (not intended for display).
void setProb(gate_t g, double p)
Set the probability for gate g.
Builds a d-DNNF from a Boolean circuit using a tree decomposition.
Core types, constants, and utilities shared across ProvSQL.
gate_type
Possible gate type in the provenance circuit.