lppl  v2.0.0
graph.hpp File Reference
#include <initializer_list>
#include <optional>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <record.hpp>
#include <distributions/graph_distributions.hpp>

Classes

struct  gr_output< O, Ts >
 Product of a gr_pair and the output of a probabilistic program. More...
 
struct  gr_pair< Ts >
 
struct  graph_ir< Ts >
 A graph intermediate representation of a causal model. More...
 
struct  graph_node< D >
 A fundamental data structure of which a graph intermediate representation is composed. More...
 
struct  graph_node_construct< D, Ts >
 Finds and tracks parents/children of nodes involved in a sample or observe statement. More...
 
struct  graph_observe_node_construct< D, V, Ts >
 Creates an observe node in a graph_ir. More...
 
struct  graph_sample_node_construct< D, RNG, Ts >
 Creates a sample node in a graph_ir. More...
 

Macros

#define GLPPL_OPT_NULL   "GLPPL_OPT(NULL)"
 

Typedefs

template<typename I , typename O , typename... Ts>
using gpp_t = std::function< O(gr_pair< Ts... > &, I)>
 A shorthand for graph probabilistic program type. Graph probabilistic programs are callables that take a single input of type I, output a single value of type O, and contain an arbitrary positive number of distributions of type Ts... More...
 
template<typename... Ts>
using graph_node_map_t = std::unordered_map< std::string, var_graph_node_t< Ts... > >
 
using graph_repr_t = std::unordered_map< std::string, std::vector< std::string > >
 
template<typename... Ts>
using var_graph_node_t = std::variant< graph_node< Ts >... >
 
template<typename... Ts>
using var_graph_ret_t = std::variant< DSType< Ts >... >
 

Functions

std::vector< std::string > address_or_string_null (std::vector< std::optional< std::string >> maybe_strings)
 
template<typename... Ts>
std::string display (gr_pair< Ts... > &gr)
 
template<typename... Ts>
std::string display (graph_ir< Ts... > &g)
 Returns a human-readable string representation of the graph. More...
 
template<typename D >
std::optional< std::string > extract_address (graph_node< D > &v)
 
template<typename V >
std::optional< std::string > extract_address (V v)
 
template<typename D >
DSType< D > extract_value (graph_node< D > &v)
 
template<typename V >
extract_value (V v)
 
template<typename D , typename... Args>
make_from_args (Args... args)
 
template<typename D , typename V , typename... Ts>
graph_observe_node_construct< D, V, Ts... > observe_g (gr_pair< Ts... > &gr, std::string &&address, V value)
 Prepares an observe node for construction and placement in the graph. More...
 
template<typename D , typename RNG , typename... Ts>
graph_sample_node_construct< D, RNG, Ts... > sample_g (gr_pair< Ts... > &gr, std::string &&address, RNG &rng)
 Prepares a sample node for construction and placement in the graph. More...
 
template<typename T >
std::string stringify (std::optional< T > t)
 
template<>
std::string stringify (std::string t)
 
template<typename I , typename O , typename... Ts>
pp_t< I, gr_output< O, Ts... >, Ts... > to_pp (gpp_t< I, O, Ts... > &f)
 Convert a graph probabilistic program into a (record-based) probabilistic program. More...
 
template<typename V , typename... Ts>
graph_node< Value< V > > value_g (gr_pair< Ts... > &gr, std::string &&address, V value)
 Creates a value node and places it in the graph. More...
 

Detailed Description

Author
David Rushing Dewhurst (drd@d.nosp@m.avid.nosp@m.rushi.nosp@m.ngde.nosp@m.whurs.nosp@m.t.co.nosp@m.m)
Version
0.2.0
Date
2022-12-24