knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of zddr
is to enable definition, manipulation, and solving of fault
tree problems using an implementation of
zero-suppressed binary decision diagram
algorithms in R.
Install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("jordagaman/zddr")
IMPORTANT: The functions from this package will not work properly if invoked
without a library(zddr)
call first. For example, calling zddr::zdd(1L)
should not work. Sorry.
This is a simple cutset.
library(zddr) zdd(1) * zdd(2) * zdd(3)
You can create the same cutset above with a simpler call:
zdd_and(1, 2, 3)
Multiple cutsets look like this:
zdd_and(1, 2, 3) | zdd_and(4, 5) | zdd(6)
The real magic is ensuring that when you add a new cutset, you check if either
that one or the existing ones are nonminimal. For example, {1,2,3}
is
nonminimal to {1}
. Check this out:
zdd_and(1, 2, 3) | zdd_and(4, 5) | zdd(6) | zdd(1)
This package is in a developmental state. The ultimate dream is to simplify the
user interface using the increasingly robust as_zdd()
function.
The most basic use of as_zdd()
accepts numeric and integer inputs.
as_zdd(10) as_zdd(10L)
The function also assumes that vectors are meant to represent a cutset.
as_zdd( c(1,2,3) )
And lists are meant to represent a collection of cutsets.
as_zdd( list(1,2,3) )
One can combine the two to produce a ZDD representation of cutsets. The final
example from the last section is reproduced here using only base R types and the
as_zdd()
function.
lst <- list( c(1,2,3), c(4,5), 6, 1 ) as_zdd(lst)
There are two effects to the above. First, it enables a complete round trip between base R cutsets and ZDDs.
z <- as_zdd(lst) cutsets(z) cutsets( as_zdd(cutsets(z)) )
Second, it enables quick generation and then manipulation of ZDDs without having
to know too much about the internals of the zddr
implementation.
z * list(1, c(2,3), 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.