Package org.variantsync.boosting
Class TraceBoosting
java.lang.Object
org.variantsync.boosting.TraceBoosting
The
TraceBoosting
class encapsulates the algorithm for enhancing
retroactive comparison-based feature tracing with proactively collected feature traces.
It is designed to work with a set of product variants and their associated
feature traces to produce a more accurate and efficient tracing process.
The algorithm is inspired by the ECCO tracing algorithm
and is tailored to improve it by utilizing additional trace information.
Usage example:
// Initialize a list to hold ProductPassport objects that describe the
// artifact locations for each variant
List<ProductPassport> productPassports = new ArrayList<>();
// Iterate the collection of variants
for (Variant variant : variants) {
String variantName = variant.getName();
// Create a new ProductPassport for the variant and add it to the list
productPassports.add(new ProductPassport(variantName,
variantsDirectory.resolve(variantName), configFileMap.get(variantName)));
}
// Instantiate the TraceBoosting algorithm with the product passports,
// working directory, and the supported language for tracing.
// LINES creates a simple line-based AST that is language-agnostic.
TraceBoosting traceBoosting = new TraceBoosting(productPassports,
workingDirectory, ESupportedLanguages.LINES);
// Retrieve the list of products from the TraceBoosting instance
List<Product> products = traceBoosting.getProducts();
// Apply the proactively collected traces to the products
distributeMappings(products, variantGenerationResult.variantGroundTruthMap(),
percentage, config.getStrip());
// Compute the main tree which represents the AST resulting from merging all variants
// together with feature traces
MainTree mainTree = traceBoosting.computeMappings();
evaluate(mainTRee);
Note: The actual implementation of the methods distributeMappings
and
evaluate
are not shown in this example and need to be specified
elsewhere on demand.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic org.logicng.formulas.FormulaFactory
-
Constructor Summary
ConstructorsConstructorDescriptionTraceBoosting
(List<VariantPassport> sourceLocations, Path workingDir, ESupportedLanguages targetLanguage) -
Method Summary
Modifier and TypeMethodDescriptionComputes mappings for the given target language and returns a MainTree object containing the mappings.extractAssociationsComparisonBased
(MainTree mainTree) Extracts associations from a given main tree by merging each product AST into the main tree and collecting corresponding main tree nodes in the product for backtracking later on.static org.logicng.formulas.FormulaFactory
Returns the FormulaFactory instance that is currently in use.Gets the input file name.Gets the input folder path.String[]
getPaths()
Returns an array of strings containing the paths for the input folder, input file, results folder, and results file.Gets the results file name.Gets the results folder path.Initializes the products by creating them from variants and configuration files.static MainTree
loadMainTree
(String folderName) Loads the main tree from the specified folder.static void
saveMainTree
(MainTree mainTree, String folderName) Saves the main tree object to a file in the specified folder.void
setInputFile
(String inputFile) Sets the input file name.void
setInputFolder
(String inputFolder) Sets the input folder path.void
setNumThreads
(int numThreads) void
Sets the paths for input and results folders and files.void
setResultsFile
(String resultsFile) Sets the results file name.void
setResultsFolder
(String resultsFolder) Sets the results folder path.
-
Field Details
-
f
public static org.logicng.formulas.FormulaFactory f -
mapping_calculation
-
-
Constructor Details
-
TraceBoosting
public TraceBoosting(List<VariantPassport> sourceLocations, Path workingDir, ESupportedLanguages targetLanguage)
-
-
Method Details
-
getFormulaFactory
public static org.logicng.formulas.FormulaFactory getFormulaFactory()Returns the FormulaFactory instance that is currently in use.- Returns:
- the FormulaFactory instance that is currently in use
-
getAllFeatures
-
setNumThreads
public void setNumThreads(int numThreads) -
loadMainTree
Loads the main tree from the specified folder.- Parameters:
folderName
- the name of the folder containing the main tree file- Returns:
- the MainTree object loaded from the file
- Throws:
UncheckedIOException
- if an IOException occurs while reading the fileRuntimeException
- if the MainTree class is not found
-
saveMainTree
Saves the main tree object to a file in the specified folder.- Parameters:
mainTree
- The MainTree object to be savedfolderName
- The name of the folder where the file will be saved- Throws:
UncheckedIOException
- If an IOException occurs while creating directories or writing the object to the file
-
getVariants
-
initialize
Initializes the products by creating them from variants and configuration files. This method collects variant directories, starts the product creation process, and returns a list of ProductInitializationTask objects.- Returns:
- A list of ProductInitializationTask objects representing the initialized products.
-
computeMappings
Computes mappings for the given target language and returns a MainTree object containing the mappings.- Returns:
- MainTree object containing the mappings
- Throws:
IllegalStateException
- if an unexpected target language is provided
-
getPaths
Returns an array of strings containing the paths for the input folder, input file, results folder, and results file.- Returns:
- an array of strings containing the paths for the input folder, input file, results folder, and results file
-
getInputFolder
Gets the input folder path.- Returns:
- The input folder path as a String.
-
setInputFolder
Sets the input folder path.- Parameters:
inputFolder
- The input folder path to set.
-
getInputFile
Gets the input file name.- Returns:
- The input file name as a String.
-
setInputFile
Sets the input file name.- Parameters:
inputFile
- The input file name to set.
-
getResultsFolder
Gets the results folder path.- Returns:
- The results folder path as a String.
-
setResultsFolder
Sets the results folder path.- Parameters:
resultsFolder
- The results folder path to set.
-
getResultsFile
Gets the results file name.- Returns:
- The results file name as a String.
-
setResultsFile
Sets the results file name.- Parameters:
resultsFile
- The results file name to set.
-
setPaths
public void setPaths(String inputFolder, String inputFile, String resultsFolder, String resultsFile) Sets the paths for input and results folders and files.- Parameters:
inputFolder
- the name of the input folderinputFile
- the name of the input fileresultsFolder
- the name of the results folderresultsFile
- the name of the results file- Throws:
UncheckedIOException
- if an I/O error occurs while creating directories
-
extractAssociationsComparisonBased
Extracts associations from a given main tree by merging each product AST into the main tree and collecting corresponding main tree nodes in the product for backtracking later on.- Parameters:
mainTree
- The main tree to extract associations from- Returns:
- An EccoSet of Association objects representing the extracted associations
-