Analysis_and_optimization.Factor_graph
type factor =
| TargetTerm of Middle.Expr.Typed.t
| Reject
| LPFunction of string * Middle.Expr.Typed.t list
val factor_of_sexp : Sexplib0.Sexp.t -> factor
val sexp_of_factor : factor -> Sexplib0.Sexp.t
val hash_fold_factor :
Ppx_hash_lib.Std.Hash.state ->
factor ->
Ppx_hash_lib.Std.Hash.state
val hash_factor : factor -> Ppx_hash_lib.Std.Hash.hash_value
type factor_graph = {
factor_map : (factor * Dataflow_types.label,
Dataflow_types.vexpr Core.Set.Poly.t)
Core.Map.Poly.t;
var_map : (Dataflow_types.vexpr,
(factor * Dataflow_types.label) Core.Set.Poly.t)
Core.Map.Poly.t;
}
val factor_graph_of_sexp : Sexplib0.Sexp.t -> factor_graph
val sexp_of_factor_graph : factor_graph -> Sexplib0.Sexp.t
val compare_factor_graph : factor_graph -> factor_graph -> int
val extract_factors_statement :
(Middle.Expr.Typed.t, 'a) Middle.Stmt.Fixed.Pattern.t ->
factor list
val extract_factors :
('a, (Middle.Expr.Typed.t, 'a) Middle.Stmt.Fixed.Pattern.t * 'b)
Core.Map.Poly.t ->
'a ->
('a * factor) list
val factor_rhs : factor -> Dataflow_types.vexpr Core.Set.Poly.t
val factor_var_dependencies :
(Dataflow_types.label,
(Middle.Expr.Typed.t, Dataflow_types.label) Middle.Stmt.Fixed.Pattern.t
* Dependence_analysis.node_dep_info)
Core.Map.Poly.t ->
Dataflow_types.vexpr Core.Set.Poly.t ->
(Dataflow_types.label * factor) ->
(Dataflow_types.vexpr, Core__.Comparator.Poly.comparator_witness) Core.Set.t
val build_adjacency_maps :
(Dataflow_types.label * factor * Dataflow_types.vexpr Core.Set.Poly.t)
Core.List.t ->
factor_graph
Helper function to generate the factor graph adjacency map representation from a factor-adjacency list
val fg_remove_fac :
(factor * Dataflow_types.cf_state) ->
factor_graph ->
factor_graph
val fg_remove_var : Dataflow_types.vexpr -> factor_graph -> factor_graph
val remove_touching :
Dataflow_types.vexpr Core.Set.Poly.t ->
factor_graph ->
factor_graph
val prog_factor_graph :
?exclude_data_facs:bool ->
Middle.Program.Typed.t ->
factor_graph
Build a factor graph from prog.log_prob using dependency analysis
val fg_reaches :
Dataflow_types.vexpr Core.Set.Poly.t ->
Dataflow_types.vexpr Core.Set.Poly.t ->
factor_graph ->
bool
BFS on 'fg' with initial frontier 'starts' and terminating at any element of 'goals'
val fg_factor_reaches :
(factor * Dataflow_types.label) ->
Dataflow_types.vexpr Core.Set.Poly.t ->
factor_graph ->
bool
val fg_factor_is_prior :
Dataflow_types.vexpr ->
(factor * Dataflow_types.label) ->
Dataflow_types.vexpr Core.Set.Poly.t ->
factor_graph ->
bool
val fg_var_priors :
Dataflow_types.vexpr ->
Dataflow_types.vexpr Core.Set.Poly.t ->
factor_graph ->
(factor * Dataflow_types.label) Core.Set.Poly.t option
Priors of V are neighbors of V which have no connection to any data except though V So for graph G and each parameter V: G' = G\V; For each neighbor F: Use BFS starting from F in G' and search for any data, if there is none, F is a prior
val list_priors :
?factor_graph:factor_graph option ->
Middle.Program.Typed.t ->
(Dataflow_types.vexpr,
(factor * Dataflow_types.label) Core.Set.Poly.t option)
Core.Map.Poly.t
val string_of_factor : factor -> string
val string_of_vexpr : Dataflow_types.vexpr -> string
val factor_graph_to_dot : factor_graph -> string
Utility to print a factor graph to the Graphviz dot language for visualization