Class TraceBoosting

java.lang.Object
org.variantsync.boosting.TraceBoosting

public class TraceBoosting extends Object
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 Details

    • f

      public static org.logicng.formulas.FormulaFactory f
    • mapping_calculation

      public String mapping_calculation
  • Constructor Details

  • 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

      public CustomHashSet<Feature> getAllFeatures()
    • setNumThreads

      public void setNumThreads(int numThreads)
    • loadMainTree

      public static MainTree loadMainTree(String folderName)
      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 file
      RuntimeException - if the MainTree class is not found
    • saveMainTree

      public static void saveMainTree(MainTree mainTree, String folderName)
      Saves the main tree object to a file in the specified folder.
      Parameters:
      mainTree - The MainTree object to be saved
      folderName - 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

      public List<Variant> getVariants()
    • initialize

      public List<VariantInitTask> 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

      public MainTree 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

      public String[] 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

      public String getInputFolder()
      Gets the input folder path.
      Returns:
      The input folder path as a String.
    • setInputFolder

      public void setInputFolder(String inputFolder)
      Sets the input folder path.
      Parameters:
      inputFolder - The input folder path to set.
    • getInputFile

      public String getInputFile()
      Gets the input file name.
      Returns:
      The input file name as a String.
    • setInputFile

      public void setInputFile(String inputFile)
      Sets the input file name.
      Parameters:
      inputFile - The input file name to set.
    • getResultsFolder

      public String getResultsFolder()
      Gets the results folder path.
      Returns:
      The results folder path as a String.
    • setResultsFolder

      public void setResultsFolder(String resultsFolder)
      Sets the results folder path.
      Parameters:
      resultsFolder - The results folder path to set.
    • getResultsFile

      public String getResultsFile()
      Gets the results file name.
      Returns:
      The results file name as a String.
    • setResultsFile

      public void setResultsFile(String resultsFile)
      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 folder
      inputFile - the name of the input file
      resultsFolder - the name of the results folder
      resultsFile - the name of the results file
      Throws:
      UncheckedIOException - if an I/O error occurs while creating directories
    • extractAssociationsComparisonBased

      public CustomHashSet<Association> 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.
      Parameters:
      mainTree - The main tree to extract associations from
      Returns:
      An EccoSet of Association objects representing the extracted associations