Comments (3)
Right now, this functionality can be implemented using the "ternary apply" operator:
#[test]
fn test_if_then_else() {
let set = BddVariableSet::new_anonymous(3);
let vars = set.variables();
let v1 = set.mk_literal(vars[0], true);
let v2 = set.mk_literal(vars[1], true);
let v3 = set.mk_literal(vars[2], true);
// ITE(v1, v2, v3) = (v1 & v2) | (!v1 & v3)
let if_then_else = bdd![(v1 & v2) | ((!v1) & v3)];
fn ite_function(a: Option<bool>, b: Option<bool>, c: Option<bool>) -> Option<bool> {
match (a, b, c) {
// If "a" is known, we can just "implement" ITE and return "b"/"c".
(Some(true), _, _) => b,
(Some(false), _, _) => c,
// The next two cases are not strictly necessary, but
// can cause the operation to finish sooner if the result
// is already determined, even when "a" is still unknown.
(None, Some(false), Some(false)) => Some(false),
(None, Some(true), Some(true)) => Some(true),
// Otherwise, we return None until "a" becomes known.
(None, _, _) => None,
}
}
let ternary = Bdd::ternary_op(&v1, &v2, &v3, ite_function);
assert_eq!(ternary, if_then_else);
}
For now, you can use the code above as a workaround. This is still a single BDD operation, so it should be comparable in overhead to other "native" ITE implementations. However, I fully agree that this should be part of the library directly. I'll make sure to add it to the next release :)
from biodivine-lib-bdd.
thanks!
from biodivine-lib-bdd.
This is now supported in 0.5.0
.
from biodivine-lib-bdd.
Related Issues (20)
- Add a restrict algorithm HOT 5
- A greedy `pick` implementation
- Implementation of `infer_regulatory_graph` can use too much memory HOT 1
- Allow BDD operations to execute as interruptible async functions
- Isses with BDD serialisation on buffered reader/writer HOT 1
- Convert `BddValuation` back to `Bdd`. HOT 1
- Reconsider `Ord` trait on `BddValuation` HOT 5
- Add linear-time algorithm for BDD -> CNF conversion HOT 1
- Add algorithm to build BDD satisfied by valuations of size `k`. HOT 1
- Is it possiable to impl AndAbstract? HOT 5
- Ensure uniform sampling for randomized operations
- Implement `From BddValuation for BddPartialValuation` HOT 1
- Self-referential substitution
- Add the "optimized DNF" introduced in `balm` HOT 1
- Faster `restrict` algorithm HOT 1
- Provide generic `BddVariableSet` that does not necessarily rely on string names HOT 1
- Support `Conditional` ternary operator HOT 3
- Avoid recursion in the parser
- Coverage reporting is broken?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from biodivine-lib-bdd.