DecisionDiagrams 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package DecisionDiagrams --version 1.0.6                
NuGet\Install-Package DecisionDiagrams -Version 1.0.6                
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.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DecisionDiagrams --version 1.0.6                
#r "nuget: DecisionDiagrams, 1.0.6"                
#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.0.6

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

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 currently maintains 100% code 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());

// 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 three variants:

  • Binary decision diagrams (link)
  • Zero-suppressed 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 maintained 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 maintain 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 maintains 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 which can offer large memory savings in many cases.

Operations

Internally, the manager only supports a single operation: and, but then leverages free negation to support other operations efficiently. This does make some operations such as ite and iff more costly, but can improve cache behavior since there is now only a single operation cache. Because "and" is commutative, the cache can further order 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 1,168 8/30/2023
1.2.2 168 8/28/2023
1.2.1 284 8/16/2023
1.2.0 3,316 6/1/2022
1.1.8 2,592 3/10/2022
1.1.7 431 3/10/2022
1.1.6 459 3/8/2022
1.1.5 3,450 10/22/2021
1.1.4 565 10/19/2021
1.1.3 459 10/18/2021
1.1.2 853 10/13/2021
1.1.1 509 10/11/2021
1.1.0 337 10/10/2021
1.0.6 376 2/11/2021
1.0.5 2,805 9/25/2020
1.0.4 1,741 6/19/2020
1.0.3 767 6/6/2020
1.0.2 1,247 5/3/2020
1.0.1 495 5/1/2020