ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
provsql::ProbabilityMethod Class Referenceabstract

Strategy interface: one concrete subclass per probability method. More...

#include "ProbabilityMethod.h"

Public Member Functions

virtual ~ProbabilityMethod ()=default
virtual std::string name () const =0
 Stable identifier used for byName lookup and the provsql.last_eval_method report.
virtual ToleranceKind guaranteeKind () const =0
 Which user-facing path this method can serve.
virtual bool inDefaultChain () const
 True iff this method participates in the auto-chooser's portfolio (vs being reachable only byName).
virtual bool isDeterministic () const
 True iff the method's guarantee holds with CERTAINTY (no failure probability).
virtual std::vector< FeaturerequiredFeatures () const
 Features the method's estimatedCost / applicable need acquired before they are meaningful (empty = a free estimate).
virtual double estimatedCost (const EvalContext &, const Tolerance &) const
 Heuristic estimate of this method's cost on the current circuit (lower is cheaper).
virtual bool applicable (const EvalContext &, const Tolerance &) const
 Cheap admissibility check for the portfolio (e.g.
virtual bool handlesMultivalued () const
 True iff the method evaluates the raw circuit, including multivalued (BID / gate_mulinput) gates, and must therefore NOT have them rewritten to independent Booleans first.
virtual double evaluate (EvalContext &ctx, const Tolerance &tol) const =0
 Run the method, returning the probability.
virtual bool producesDD () const
 True iff this method constructs a d-DNNF artifact (and so can serve the makeDD route-chooser via buildDD).
virtual dDNNF buildDD (EvalContext &ctx) const
 Build the d-DNNF this method constructs (only when producesDD()).

Detailed Description

Strategy interface: one concrete subclass per probability method.

evaluate throws CircuitException when the method cannot be applied to the circuit; chooseAndRun relies on that to fall through the default ladder, while byName lets it propagate (an explicitly named method reports the failure instead of silently falling back).

Definition at line 91 of file ProbabilityMethod.h.

Constructor & Destructor Documentation

◆ ~ProbabilityMethod()

virtual provsql::ProbabilityMethod::~ProbabilityMethod ( )
virtualdefault

Member Function Documentation

◆ applicable()

virtual bool provsql::ProbabilityMethod::applicable ( const EvalContext & ,
const Tolerance &  ) const
inlinevirtual

Cheap admissibility check for the portfolio (e.g.

an inversion-free certificate must be present, or a 2^N method's N is within a sanity bound). byName ignores it.

Definition at line 135 of file ProbabilityMethod.h.

◆ buildDD()

dDNNF provsql::ProbabilityMethod::buildDD ( EvalContext & ctx) const
virtual

Build the d-DNNF this method constructs (only when producesDD()).

evaluate() of a d-D method is exactly buildDD(ctx).probabilityEvaluation(), so the cost/route logic stays single-sourced. Sets ctx.actual_method.

Definition at line 1613 of file probability_evaluate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ estimatedCost()

virtual double provsql::ProbabilityMethod::estimatedCost ( const EvalContext & ,
const Tolerance &  ) const
inlinevirtual

Heuristic estimate of this method's cost on the current circuit (lower is cheaper).

Only called once requiredFeatures are acquired. The chooser sorts admissible portfolio members by this and tries them cheapest-first – there is deliberately NO fixed ordinal: the order emerges from the estimates, and a calibrated cost model can later replace the heuristic bodies without touching the chooser. Only consulted for portfolio members; by-name-only methods keep the default.

Definition at line 129 of file ProbabilityMethod.h.

◆ evaluate()

virtual double provsql::ProbabilityMethod::evaluate ( EvalContext & ctx,
const Tolerance & tol ) const
pure virtual

Run the method, returning the probability.

May mutate ctx (build the Boolean view lazily, trigger the multivalued rewrite, set the reported method name).

Here is the caller graph for this function:

◆ guaranteeKind()

virtual ToleranceKind provsql::ProbabilityMethod::guaranteeKind ( ) const
pure virtual

Which user-facing path this method can serve.

◆ handlesMultivalued()

virtual bool provsql::ProbabilityMethod::handlesMultivalued ( ) const
inlinevirtual

True iff the method evaluates the raw circuit, including multivalued (BID / gate_mulinput) gates, and must therefore NOT have them rewritten to independent Booleans first.

The dispatcher rewrites multivalued gates (EvalContext::ensureMultivaluedRewritten) before every method that returns false, so a Boolean-only method needs no per-evaluate rewrite of its own and a new one is BID-correct by default. Only "independent" overrides this: it interprets a mulinput block natively (summing the mutually-exclusive alternatives) to keep the exact disjoint-OR structure the rewrite would dissolve. (Methods gated to TID-only circuits – the DNF samplers via Feature::DnfShape, inversion-free via its certificate – never see a mulinput, so the central rewrite is a no-op for them and they keep the default.)

Definition at line 150 of file ProbabilityMethod.h.

Here is the caller graph for this function:

◆ inDefaultChain()

virtual bool provsql::ProbabilityMethod::inDefaultChain ( ) const
inlinevirtual

True iff this method participates in the auto-chooser's portfolio (vs being reachable only byName).

Definition at line 104 of file ProbabilityMethod.h.

◆ isDeterministic()

virtual bool provsql::ProbabilityMethod::isDeterministic ( ) const
inlinevirtual

True iff the method's guarantee holds with CERTAINTY (no failure probability).

The exact methods and the d-tree's certified interval are deterministic; the (eps,delta) samplers are not. A request with delta == 0 ("deterministic") admits only deterministic methods – the samplers cannot honour it (their sample count is proportional to ln(1/delta), so delta = 0 is infeasible, and their cost model masks this by falling back to a finite delta). For delta > 0 the samplers stay admissible but their cost grows as delta shrinks, so the chooser already migrates to the (delta-independent) d-tree well before delta reaches 0.

Definition at line 115 of file ProbabilityMethod.h.

◆ name()

virtual std::string provsql::ProbabilityMethod::name ( ) const
pure virtual

Stable identifier used for byName lookup and the provsql.last_eval_method report.

Here is the caller graph for this function:

◆ producesDD()

virtual bool provsql::ProbabilityMethod::producesDD ( ) const
inlinevirtual

True iff this method constructs a d-DNNF artifact (and so can serve the makeDD route-chooser via buildDD).

The three d-D constructors – interpret-as-dd, tree-decomposition, compilation – override this; the scalar methods (independent, possible-worlds, the samplers, the d-tree) do not. This is the producesDD() portfolio chooseAndBuildDD ranks.

Definition at line 162 of file ProbabilityMethod.h.

◆ requiredFeatures()

virtual std::vector< Feature > provsql::ProbabilityMethod::requiredFeatures ( ) const
inlinevirtual

Features the method's estimatedCost / applicable need acquired before they are meaningful (empty = a free estimate).

The chooser will not call estimatedCost / applicable until these are acquired, and acquires them lazily per the cost rule above.

Definition at line 121 of file ProbabilityMethod.h.


The documentation for this class was generated from the following files: