DecisionDiagrams 1.1.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package DecisionDiagrams --version 1.1.5
NuGet\Install-Package DecisionDiagrams -Version 1.1.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DecisionDiagrams" Version="1.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DecisionDiagrams --version 1.1.5
#r "nuget: DecisionDiagrams, 1.1.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DecisionDiagrams as a Cake Addin
#addin nuget:?package=DecisionDiagrams&version=1.1.5

// Install DecisionDiagrams as a Cake Tool
#tool nuget:?package=DecisionDiagrams&version=1.1.5

Introduction

This project is an implementation for various variants of binary decision diagrams that is used at Microsoft Research. It focuses on high performance, usability, and correctness. The library maintains 100% test coverage.

Installation

Just add the project to your visual studio solution or add the package from nuget.

Getting Started

To import the library, add the following line to your file:

using DecisionDiagrams;

A simple use of the library is shown shown below:

// create a manager that uses chain-reduced binary decision diagrams
var manager = new DDManager<CBDDNode>(new CBDDNodeFactory());

// alternatively using traditional BDDs
var manager2 = new DDManager<BDDNode>(new BDDNodeFactory());

// allocate three variables, two booleans and one 32-bit integer
// the internal ordering will match the order allocated from the manager.
var a = manager.CreateBool();
var b = manager.CreateBool();
var c = manager.CreateInt32();

// build formulas from the variables.
DD f1 = manager.Or(a.Id(), b.Id());
DD f2 = manager.And(c.GreaterOrEqual(1), c.LessOrEqual(4));

// get a satisfying assignment for a formula
var assignment = manager.Sat(manager.And(f1, f2));

// get the values as C# objects
bool valuea = assignment.Get(a);  // valuea = false
bool valueb = assignment.Get(b);  // valueb = true
int valuec = assignment.Get(c);   // valuec = 1

You can find more detailed examples in the tests.

Implementation

The library is based on the cache-optimized implementation of decision diagrams here, and implements two variants:

  • Binary decision diagrams (link)
  • Chain-reduced binary decision diagrams (link)

Data representation

Internally decision diagram nodes are represented using integer ids that are bit-packed with other metadata such as a garbage collection mark bit, and a complemented bit. User references to nodes (DD type) are maintained through a separate (smaller) table.

Garbage collection

The DD reference table uses WeakReference wrappers to integrate with the .NET garbage collector. This means that users of the library do not need to perform any reference counting, which is common in BDD libraries. Nodes are kept in a memory pool and the library maintains the invariant that a node allocated before another will appear earlier in this pool. This allows for various optimizations when looking up nodes in the unique table. To uphold this invariant, the library implements a mark, sweep, and shift garbage collector that compacts nodes when necessary.

Memory allocation

By hashconsing nodes in the unique table, the library ensures that two boolean functions are equal if and only if their pointers (indices) are equal. The unique table holds all nodes and is periodically resized when out of memory. For performance reasons, we ensure that this table is always a power of two size. This makes allocating new space a bit inflexible (harder to use all memory) but in return makes all operations faster. To compensate for this inflexible allocation scheme, the library becomes more reluctant to resize the table as the number of nodes grows.

Optimizations

The library makes use of "complement edges" (a single bit packed into the node id), which determines whether the formula represented by the node is negated. This ensures that all negation operations take constant time and also reduces memory consumption since a formula and its negation share the same representation. The implementation also includes a compressed node type CBDDNode that should offer lower memory use and often higher performance but comes with the restriction that you can not create more than 2^15-1 binary variables.

Operations

Internally, the manager supports several operations: conjunction, existential quantification, if-then-else and then leverages free negation to support other operations efficiently. It also leverages commutativity of conjunction + disjunction to further reduce memory by ordering the arguments to avoid redundant entries. Currently, the library does not support dynamic variable reordering as well as a number of operations such as functional composition.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DecisionDiagrams:

Package Downloads
ZenLib

A library that simplifies building verification tools in .NET

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 708 8/30/2023
1.2.2 140 8/28/2023
1.2.1 244 8/16/2023
1.2.0 3,166 6/1/2022
1.1.8 2,353 3/10/2022
1.1.7 400 3/10/2022
1.1.6 423 3/8/2022
1.1.5 3,297 10/22/2021
1.1.4 518 10/19/2021
1.1.3 415 10/18/2021
1.1.2 786 10/13/2021
1.1.1 469 10/11/2021
1.1.0 310 10/10/2021
1.0.6 351 2/11/2021
1.0.5 2,653 9/25/2020
1.0.4 1,665 6/19/2020
1.0.3 721 6/6/2020
1.0.2 1,173 5/3/2020
1.0.1 468 5/1/2020