Giter VIP home page Giter VIP logo

featjar-formula's People

Contributors

ekuiter avatar deltatimo avatar

Stargazers

Daniel Hohmann avatar

Watchers

James Cloos avatar  avatar Sebastian Krieter avatar

featjar-formula's Issues

FeatureIDE format: Alternative features not correctly supported

Current behaviour

In the class XMLFeatureModelFormat all alternatives are treated as atmost(1) cases. This may result an invalid number of solutions.

protected LiteralPredicate parseFeature(Literal parent, final Element e, final String nodeName, boolean and) {
//...
case ALT:
    if (parseFeatures.size() == 1) {
        constraints.add(implies(f, parseFeatures.get(0)));
    } else {
        constraints.add(new And(implies(f, parseFeatures), atMost(parseFeatures)));
    }
    break;
//...
}
protected Formula atMost(final List<Formula> parseFeatures) {
    return new AtMost(parseFeatures, 1);
}

Additionally, AtMost is not supported by JavaSMT

Exprected/proposed behaviour

protected LiteralPredicate parseFeature(Literal parent, final Element e, final String nodeName, boolean and) {
//...
case ALT:
    if (parseFeatures.size() == 1) {
        constraints.add(implies(f, parseFeatures.get(0)));
    } else {
        constraints.add(new And(implies(f, parseFeatures), alternative(f, parseFeatures)));
    }
    break;
//...
}

/**
* Creates an alternative selection using XOR.
*
* @param parent Parent feature
* @param parseFeatures All features available for selection
* @return parent implies (((f1 XOR f2) XOR ...) XOR fn)
*/
protected Formula alternative(LiteralPredicate parent, ArrayList<Formula> parseFeatures) {
List<Formula> options = new ArrayList<>();
    for (int i = 0; i < parseFeatures.size(); i++) {
	List<Formula> p = new ArrayList<>();
	for (int j = 0; j < parseFeatures.size(); j++) {
            if(i == j){
	        p.add(parseFeatures.get(j));
            } else {
	        p.add(new Not(parseFeatures.get(j)));
            }
        }
        options.add(new And(p));
    }
    return new Implies(parent, new Or(options));
}

For testing you could use the following structure:

<struct>
    <and mandatory="true" name="Webserver">
        <alt name="Datenbank">
            <feature name="MySQL"></feature>
            <feature name="PostgreSQL"></feature>
        </alt>
    </and>
</struct>

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.