Coder Social home page Coder Social logo

Comments (5)

daemontus avatar daemontus commented on June 27, 2024 1

Maybe I am missing something, but from your description, it sounds like var_select followed by var_project would do what you are after, right?

I have implemented a quick prototype here - if this corresponds to what you are describing, I can put it into the next release :) (Granted, there is probably a slightly faster algorithm to do this in one "go" - I don't have the time to implement it at the moment though, maybe later this year if everything goes well)

from biodivine-lib-bdd.

ellmau avatar ellmau commented on June 27, 2024 1

Thanks for the reply, i will have a look into the var_select + var_project approach and test whether it works out as intended and performs good enough for my application.

In the next release it will be pretty easy to adapt to the "restrict" function then.

I'll let you know when I've done the related testing in the following days.

from biodivine-lib-bdd.

daemontus avatar daemontus commented on June 27, 2024 1

Cool! I'll keep this issue open until it is implemented properly, and I've added this into the 0.4.0 milestone. Thank you for reporting!

from biodivine-lib-bdd.

ellmau avatar ellmau commented on June 27, 2024

Thanks again for the advice. The solution where both operations are chained is working reasonable well on the first tests. (honestly I did not expect that chaining both operations is that well-performing).

Till the feature is implemented in the project, i have implemented a trait for easier use.

/// Implementations of the restrict-operations on BDDs
pub trait BddRestrict {
    /// Provides an implementation of the restrict-operation on BDDs for one variable
    fn var_restrict(&self, variable: biodivine_lib_bdd::BddVariable, value: bool) -> Self;
    /// Provides an implementation of the restrict-operation on a set of variables
    fn restrict(&self, variables: &[(biodivine_lib_bdd::BddVariable, bool)]) -> Self;
}

impl BddRestrict for biodivine_lib_bdd::Bdd {
    fn var_restrict(&self, variable: biodivine_lib_bdd::BddVariable, value: bool) -> Self {
        self.var_select(variable, value).var_project(variable)
    }

    fn restrict(&self, variables: &[(biodivine_lib_bdd::BddVariable, bool)]) -> Self {
        let mut variablelist: Vec<biodivine_lib_bdd::BddVariable> = Vec::new();
        variables
            .iter()
            .for_each(|(var, _val)| variablelist.push(*var));
        self.select(variables).project(&variablelist)
    }
}

PS: I'm not happy about the construction of the helping vector in here, but it is just a quick workaround for now.

from biodivine-lib-bdd.

daemontus avatar daemontus commented on June 27, 2024

For now, I have merged the "naive" algorithm that combines select and project. This is now released as part of version 0.4.0. Further performance improvements to the method will be tracked as part of #28.

from biodivine-lib-bdd.

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.