Coder Social home page Coder Social logo

Vector Compose Algorithm? about dd HOT 1 CLOSED

tulip-control avatar tulip-control commented on September 16, 2024
Vector Compose Algorithm?

from dd.

Comments (1)

johnyf avatar johnyf commented on September 16, 2024

Vectorized composition is simultaneous substitution of multiple variables with arbitrary expressions, the latter as BDD nodes (so LET x = y, y = x IN x /\ ~ y should yield y /\ ~ x). Currently, it is available only in dd.cudd, where Cudd_bddVectorCompose is called from here.

dd.bdd includes compose, but for one variable at a time. There is a todo item to offer vectorized composition there. It is already implemented, in the sense that it is essentially the same algorithm with rename, cofactor, and evaluate, where one can pass multiple variables or constants and they are replaced in one pass, down as the BDD graph is being "rezipped".

A naive first dev implementation wasn't simultaneous composition, so it was omitted (more details in #12 #11 (comment)). Because of compose being essentially the same algorithm with rename etc., I would like to consolidate these methods into one, as described in #12. The only real difference between them is user input, and that can still be available as methods with different signatures that call the same method implementing the algorithm.

There is a good chance that a method called BDD.replace will be preferred, for the reasons described here. The name replace has been used in the first-order interface (i.e., integers and arithmetic) to BDDs in omega.symbolic.fol (which I also recommend using -- just beware it may be a little unstable in the near future, because it has been freshly minted).

The best reference is Bryant's original paper, which is readable and to the point. I highly recommend reading it (in particular the original PDF). Single variable composition is covered in Sec.IV-E, p.685, where the complexity is shown to be O( NumberOfNodes(G1)^2 NumberOfNodes(G2)). The updated version comments in footnote 8, p.16 that this bound is tight.

For use cases where some variable is replaced by some given BDD, improvements rely on what that BDD is. This is what rename exploits, for variables with neighboring levels, to reduce the complexity. The complexity of rename and cofactor (which are special cases of compose) is discussed in Baier and Katoen, pp.416--421. It is a good overview, though I do not recommend it for learning those particular algorithms, because they are written in a complicated and messy way. Quoting p.416: "... there is no linear-time algorithm that realizes the rename operator for arbitrary variable orderings".

The way that these functions are implemented in Python, the space complexity relates to the number of intermediate results, because they are simply memoized in a dict. This is intentional, i.e., I have written a simple and (hopefully) readable implementation. Premature optimization is the root of all evil, i.e., dd.bdd has value for development, prototyping, debugging, easy deployment, and education. Not for industrial use---that is served by dd.cudd.

It so happens that dd.bdd actually works well in practice, but I would be reluctant to sacrifice readability and simplicity for performance. Instead, I would prefer to write, say, another, optimized, BDD implementation in a separate Python module, and have it be used if needed (for example, see debug and optimized versions of functions in ply). The dual implementation approach serves also for cross-testing code (the simple implementation can be used as a reference, because it is less likely to contain errors).

from dd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.