Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

TableFactor

A TableFactor is an alternative to a DecisionTreeFactor, using a sparse matrix to represent factors with many zeros. It stores a discrete potential indexed by an ordered sequence of discrete keys and supports efficient lookup of the stored entries.

Open In Colab

Constructing a table

The order of DiscreteKeys determines how the flat value sequence maps to assignments. The example has two binary variables and therefore four table entries.

Lookup and error

evaluate(values) returns the stored potential. error(values) returns its negative logarithm, the additive objective used by discrete optimization. keys(), size(), and empty() inspect the factor scope.

Converting from a decision tree

Constructing from DecisionTreeFactor preserves the potential while changing its storage. This is useful after symbolic operations have created a compact tree but a dense downstream calculation is preferred.

Source

TableFactor.h

AI assistance caveat

AI was used to help draft this documentation, and inaccuracies could be present.