BeTTy

BeTTy is an extensible and highly configurable framework supporting BEnchmarking and TestTing on the analYses of feature models. It is written in Java and is distributed as a jar file facilitating its integration into external projects. BeTTy has been developed on top of some of the core components of theFaMa Tool Suite.

Registered Tool

Documentation

 Current version of BeTTy provides the following features:

  • Random generation of feature models.  BeTTy enables the random generation of highly-customized feature models. These may be used to evaluate the performance of analysis tools in average cases
  • Metamorphic generation of feature models and their products. The framework allows users to generate not only random feature model but also the set of products that these represents. The resultant models and set of products can be used to test the functionality of feature model analysis tools.  For more details about this have look to this paper.
  • Random generation of attributed feature models. BeTTy also supports the random generation of attributed feature models . These models are commonly used to add non functional attributes to the features. To the best of our knowledge, we are the first authors providing a random generator for this type of models.
  • Automated generation of test data for functional testing. BeTTy supports the generation of inputs and expected outputs for a number of analysis operations on
    feature models making the detection of faults straightforward.
  • Evolutionary feature model generator. BeTTy includes an evolutionary algorithm supporting the generation of feature models maximizing user-defined optimization criteria. This feature can be used to generate computationally–hard feature models that reveal the performance of tools in pessimistic cases.
  • Benchmarking. The BeTTy framework integrates several components to facilitate the performance comparison of feature model analysis tools.

For more details, have a look to our code samples or to our JavaDoc.

Tools related to Betty

The BeTTy Framework uses several popular open–source tools, namely:

Sat4j is a java solver for SATisfiability problems.

CHOCO is a java library for constraint satisfaction problems (CSP) and constraint programming (CP). It is built on a event-based propagation mechanism with back-trackable structures.

JaCoP is a Finite Domain constraint solver 

JavaBDD is a Java library for manipulating BDDs (Binary Decision Diagrams).

 ANTLR, (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It’s widely used to build languages, tools, and frameworks.

Publications related to Betty

2012

S. Segura, J.A. Galindo, D. Benavides, J.A. Parejo, A. Ruiz-Cortés.  2012.  BeTTy: Benchmarking and Testing on the Automated Analysis of Feature Models. Sixth International Workshop on Variability Modelling of Software-intensive Systems (VaMoS’12). :63–71.

R.E. Lopez-Herrejon, J.A. Galindo, D. Benavides, S. Segura, Al. Egyed.  2012.  Reverse Engineering Feature Models with Evolutionary Algorithms: An Exploratory Study. 4th Symposium on Search Based Software Engineering.

2011

S. Segura, R.M Hierons, D. Benavides, A. Ruiz-Cortés.  2011.  Automated Metamorphic Testing on the Analyses of Feature Models. Information and Software Technology.

Related Tools

Code Samples

Random generation of feature models

Listing §A.1 This example shows how to generate a basic feature model and save it in xml format. The number of features and percentage of cross-tree constraints are given as input parameters.

 
 
	public static void main(String[] args) throws Exception, BettyException {
 
		// STEP 1: Specify the user's preferences for the generation (so-called characteristics)
		GeneratorCharacteristics characteristics = new GeneratorCharacteristics();
		characteristics.setNumberOfFeatures(5);		// Number of features
		characteristics.setPercentageCTC(100);			// Percentage of cross-tree constraints.
 
		// STEP 2: Generate the model with the specific characteristics (FaMa FM metamodel is used)
		AbstractFMGenerator generator = new FMGenerator();
		FAMAFeatureModel fm = (FAMAFeatureModel) generator.generateFM(characteristics);
 
		// OPTIONAL: Show detailed statistics of the feature model generated
		FMStatistics statistics = new FMStatistics(fm);
		System.out.println(statistics);
 
		// STEP 3: Save the model
		FMWriter writer = new FMWriter();
		writer.saveFM(fm, "./model.xml"); 
 
	}

Listing A.1: Random feature model generation


Random generation of attributed feature models

Listing §A.2 This example shows how to generate a basic feature model and save it in xml format. The number of features, number of attributes and percentage of cross-tree constraints are given as input parameters. Attributes are placed in leaf features.

 
      public static void main(String[] args) throws Exception, BettyException {
 
		// STEP 1: Specify the user's preferences for the generation (so-called
		// characteristics)
		// Our characteristics are AttributedCharacteristics
		AttributedCharacteristic characteristics = new AttributedCharacteristic();
		characteristics.setNumberOfFeatures(20); // Number of features
		characteristics.setPercentageCTC(30); // Percentage of cross-tree
							 // constraints.
		characteristics.setNumberOfExtendedCTC(5);
		characteristics.setAttributeType(AttributedCharacteristic.INTEGER_TYPE);
		characteristics
			.setDefaultValueDistributionFunction((AttributedCharacteristic.UNIFORM_DISTRIBUTION));
		characteristics.addRange(new Range(3, 100));
		characteristics.setNumberOfAttibutesPerFeature(5);
		String argumentsDistributionFunction[] = { "3", "100" };
		characteristics
				.setDistributionFunctionArguments(argumentsDistributionFunction);
		characteristics.setHeadAttributeName("Atribute");
 
		// STEP 2: Generate the model with the specific characteristics (FaMa
		// Attributed FM metamodel is used)
		for (int i = 0; i < 1000; i++) {
		characteristics.setSeed(characteristics.getSeed()+i);
		AbstractFMGenerator gen = new FMGenerator();
		AttributedFMGenerator generator = new AttributedFMGenerator(gen);
		FAMAAttributedFeatureModel afm = (FAMAAttributedFeatureModel) generator
				.generateFM(characteristics);
 
 
 
 
		// STEP 3: Save the model
		FMWriter writer = new FMWriter();
		writer.saveFM(afm, "./attributedModel.afm");
		AttributedReader reader = new AttributedReader();
		VariabilityModel fm = reader.parseFile("./attributedModel.afm");
 
 
		 }

Listing A.2: Random attributed feature model generation

Random generation of feature models and their products

Generation of optimized feature models

Listing §A.4 This example compares the effectiveness of evolutionary and random search in searching for a feature model maximizing its CTC ratio. (average of 10 executions is shown).

 
public static void main(String[] args) throws BettyException, Exception {
		int hits = 0;
		List<Double> randomFitnesses = new ArrayList<Double>();
		List<Double> EAFitnesses = new ArrayList<Double>();
		int iterations = 10;
		for (int u = 0; u < iterations; u++) {
 
			// STEP 1: Specify the user's preferences for the generation (characteristics)
			GeneratorCharacteristics ch = new GeneratorCharacteristics();
			ch.setMaxBranchingFactor(20);
			ch.setNumberOfFeatures(100);
			ch.setProbabilityAlternative(20);
			ch.setPercentageCTC(30);
			ch.setProbabilityMandatory(40);
			ch.setProbabilityOptional(20);
			ch.setProbabilityOr(20);
 
			// STEP 2: Generate 5000 random models, evaluate them and save the best fitness obtained
			FMGenerator randomGen = new FMGenerator();
			CTCRFitness bf = new CTCRFitness();
			double bestRandomFitness = 0;
			for (int i = 0; i < 5000; i++) {
				VariabilityModel generateFM = randomGen.generateFM(ch);
				double randomFitness = bf.fitness((FAMAFeatureModel) generateFM);
				if (randomFitness > bestRandomFitness)
					bestRandomFitness = randomFitness;
 
			}
 
			randomFitnesses.add(bestRandomFitness);
 
			// STEP 3.1: Create an evolutionary generator object 
			//(by default 5000 models are generated (25 generation x 200 individuals on each generation)
			EvolutionaryFMGenerator generator = new EvolutionaryFMGenerator();
 
			// STEP 3.2: Set the fitness function for the evolutionary algorithm
			generator.setFitnessFunction(new CTCRFitness());
			generator.generateFM(ch);
			double bestEAFitness = generator.getBestFitness();
			EAFitnesses.add(bestEAFitness);
 
			if(bestEAFitness > bestRandomFitness){
				hits++;
			}
		}

Listing A.4: Generation of a feature model maximizing its cross-tree constraint ratio

 
 
public class CTCRFitness implements FitnessFunction {
 
	@Override
	public double fitness(FAMAFeatureModel fm) {
		FMStatistics statistics= new FMStatistics(fm);
		return statistics.getCTCR();
	}
 
}

Listing A.4: Fitness function obtaining the CTC ratio of an input feature model.

Version Control

BeTTy 1.1.1 (November 2011)

  • Minor bug fixed in the FaMa Textual Format writer

BeTTy 1.1 (October 2011)

  • Support for the random generation of attributed feature models.
  • Minor bug in the random FM generator fixed. The bug produced an infinite loop when generating overconstrained models

BeTTy 1.0 (February 2011)

  • Class refactoring to facilitate extensibility.
  • Minor bug in the evolutionary feature model generator fixed.
  • FaMa components updated.

BeTTy 1.0 beta (October 2010)

BeTTy is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License. Although the GPLv3 has many terms, the most important is that you must provide the source code of your application to your users so they can be free to modify your application for their own needs.