featureide / featjar-formula Goto Github PK
View Code? Open in Web Editor NEWPropositional and first-order formulas
License: GNU Lesser General Public License v3.0
Propositional and first-order formulas
License: GNU Lesser General Public License v3.0
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
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>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.