Class AlgorithmProfileHelper

java.lang.Object
eu.qualimaster.easy.extension.internal.AlgorithmProfileHelper

public class AlgorithmProfileHelper extends Object
Support for creating on-demand pipelines for algorithm profiling.
Author:
Holger Eichelberger
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Information describing a new profile pipeline.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
     
    private static final String
     
    static final String
     
    static final String
     
    private static final String[]
     
    static final String
     
    static final String
     
    static final String
     
    private static final String
     
    private static final String[]
     
    private static final String[]
     
    static final String
     
    private static final String[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static void
    addImports(net.ssehub.easy.varModel.model.Project source, String[] imports, net.ssehub.easy.varModel.model.Project target, net.ssehub.easy.varModel.model.Project... furtherImports)
    Adds the given imports to target.
    private static List<net.ssehub.easy.varModel.model.IFreezable>
    addTopLevelValues(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project source, net.ssehub.easy.varModel.model.Project target, String... exclude)
    Adds top level values configured for source to target.
    private static Object[]
    createDataSourceParameters(net.ssehub.easy.varModel.model.Project cfgProject)
    Creates the default adaptable parameters for a data source.
    private static net.ssehub.easy.varModel.model.DecisionVariableDeclaration
    createDecisionVariable(String name, net.ssehub.easy.varModel.model.datatypes.IDatatype type, net.ssehub.easy.varModel.model.Project target, Object... values)
    Creates a decision variable declaration.
    static net.ssehub.easy.varModel.model.FreezeBlock
    createFreezeBlock(List<net.ssehub.easy.varModel.model.IFreezable> freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType)
    Creates a freeze block for project and adds it to project.
    private static net.ssehub.easy.varModel.model.FreezeBlock
    createFreezeBlock(net.ssehub.easy.varModel.model.IFreezable[] freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType)
    Creates a freeze block for project and adds it to project.
    private static net.ssehub.easy.varModel.model.Project
    createInfrastructureCfg(net.ssehub.easy.varModel.confModel.Configuration config, net.ssehub.easy.varModel.model.Project pipelines, net.ssehub.easy.varModel.model.Project cfgInfra, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar)
    Creates the InfrastructureCfg IVML project.
    private static net.ssehub.easy.varModel.model.Project
    createNewRoot(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName)
    Creates a new QM model root leaving the real one as it is.
    private static net.ssehub.easy.varModel.model.Project
    createPipelinesCfg(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project pip, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar)
    Creates the PipelinesCfg IVML project.
    createProfilePipeline(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName, net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor source)
    Profiles the given algorithm.
    private static net.ssehub.easy.varModel.model.Project
    createQm(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project infra)
    Creates the top-level QM project.
    private static net.ssehub.easy.varModel.model.Project
    createQmProject(String name, net.ssehub.easy.varModel.model.Project typeFallback)
    Creates a project with basic settings for QM.
    private static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree
    createRefToTuple(net.ssehub.easy.varModel.model.DecisionVariableDeclaration var, String slotName, int index)
    Creates an expression accessing the index element of slotName in var.
    private static void
    Extracts the data artifact to base.
    static void
    extractProfilingArtifact(String artifactSpec, String name, File base)
    Extracts the profiling artifact.
    static File
    Just returns a file instance pointing to the control file.
    static File
    Just returns a file instance pointing to the data file.
    private static net.ssehub.easy.varModel.model.values.Value
    getValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String slot)
    Returns (a copy) of the value of the slot in var.
    private static net.ssehub.easy.varModel.model.DecisionVariableDeclaration
    setPipelines(net.ssehub.easy.varModel.model.Project prj, String varName, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipeline)
    Sets the given pipeline as value in the varName of prj.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AlgorithmProfileHelper

      public AlgorithmProfileHelper()
  • Method Details

    • createProfilePipeline

      public static AlgorithmProfileHelper.ProfileData createProfilePipeline(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName, net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor source) throws net.ssehub.easy.instantiation.core.model.common.VilException
      Profiles the given algorithm. Create a specific pipeline with data source, specific family holding only the test algorithm. Stores data and control file into source.
      Parameters:
      config - the configuration to be used as basis for creating a profiling pipeline
      pipelineName - the name of the pipeline to be created (must be a valid Java identifier)
      familyName - the name of the family to test
      algorithmName - the name of the algorithm within family to test
      source - the source project descriptor, also to be used as target folder for instantiation (the folder may be empty)
      Returns:
      pipeline information
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException - in case of model query problems, model management problems, CST errors, unmatching IVML values or VIL execution errors
    • getDataFile

      public static File getDataFile(File base)
      Just returns a file instance pointing to the data file.
      Parameters:
      base - the base folder
      Returns:
      the file instance (regardless whether it exists)
    • getControlFile

      public static File getControlFile(File base)
      Just returns a file instance pointing to the control file.
      Parameters:
      base - the base folder
      Returns:
      the file instance (regardless whether it exists)
    • extractProfilingArtifact

      public static void extractProfilingArtifact(String artifactSpec, String name, File base) throws net.ssehub.easy.instantiation.core.model.common.VilException
      Extracts the profiling artifact.
      Parameters:
      artifactSpec - the artifact specification
      name - the logical name of the artifact
      base - the base folder where to extract to
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException - in case that obtaining the artifact fails
    • extractDataArtifact

      private static void extractDataArtifact(File file, File base)
      Extracts the data artifact to base.
      Parameters:
      file - the file to extract
      base - the base folder to extract to
    • createNewRoot

      private static net.ssehub.easy.varModel.model.Project createNewRoot(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException
      Creates a new QM model root leaving the real one as it is.
      Parameters:
      config - the configuration to be used as basis for creation
      pipelineName - the pipeline name (here a valid Java identifier)
      familyName - the name of the family to test
      algorithmName - the name of the algorithm within family to test
      Returns:
      the new model root project
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - in case of model query problems
      net.ssehub.easy.basics.modelManagement.ModelManagementException - in case of model management problems
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case of unmatching values
    • createPipelinesCfg

      private static net.ssehub.easy.varModel.model.Project createPipelinesCfg(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project pip, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException
      Creates the PipelinesCfg IVML project.
      Parameters:
      cfgProject - the top-level configuration project
      pip - the pipeline project
      pipVar - the pipeline decision variable
      Returns:
      the IVML project
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - in case of model query problems
      net.ssehub.easy.basics.modelManagement.ModelManagementException - in case of model management problems
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case of unmatching values
    • createInfrastructureCfg

      private static net.ssehub.easy.varModel.model.Project createInfrastructureCfg(net.ssehub.easy.varModel.confModel.Configuration config, net.ssehub.easy.varModel.model.Project pipelines, net.ssehub.easy.varModel.model.Project cfgInfra, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException
      Creates the InfrastructureCfg IVML project.
      Parameters:
      config - the top-level configuration
      pipelines - the pipelines project (see createPipelinesCfg(Project, Project, DecisionVariableDeclaration)
      cfgInfra - the orignal infrastructure configuration project
      pipVar - the pipeline decision variable
      Returns:
      the IVML project
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - in case of model query problems
      net.ssehub.easy.basics.modelManagement.ModelManagementException - in case of model management problems
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case of unmatching values
    • createQm

      private static net.ssehub.easy.varModel.model.Project createQm(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project infra) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException
      Creates the top-level QM project.
      Parameters:
      cfgProject - the top-level configuration project
      infra - the infrastructure cfg project (see createInfrastructureCfg(Configuration, Project, Project, DecisionVariableDeclaration))
      Returns:
      the IVML project
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - in case of model query problems
      net.ssehub.easy.basics.modelManagement.ModelManagementException - in case of model management problems
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case of unmatching values
    • createRefToTuple

      private static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createRefToTuple(net.ssehub.easy.varModel.model.DecisionVariableDeclaration var, String slotName, int index) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException
      Creates an expression accessing the index element of slotName in var.
      Parameters:
      var - the variable to access
      slotName - the slot to access
      index - the index within the slot to access
      Returns:
      the accessing expression
      Throws:
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case that the constraint expression cannot be created
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case that the index value does not match
    • createDataSourceParameters

      private static Object[] createDataSourceParameters(net.ssehub.easy.varModel.model.Project cfgProject) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException
      Creates the default adaptable parameters for a data source.
      Parameters:
      cfgProject - the project used to query for types
      Returns:
      the parameters
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - in case that types cannot be resolved
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case that the value cannot be created due to type mismatches
    • createFreezeBlock

      private static net.ssehub.easy.varModel.model.FreezeBlock createFreezeBlock(net.ssehub.easy.varModel.model.IFreezable[] freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.model.ModelQueryException
      Creates a freeze block for project and adds it to project.
      Parameters:
      freezables - the freezables
      project - the IVML project to add to (may be null if failed)
      fallbackForType - in case that project is being written the first time, may be null
      Returns:
      the created freeze block
      Throws:
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case of unmatching values
      net.ssehub.easy.varModel.model.ModelQueryException - in case of model access problems
    • createFreezeBlock

      public static net.ssehub.easy.varModel.model.FreezeBlock createFreezeBlock(List<net.ssehub.easy.varModel.model.IFreezable> freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.model.ModelQueryException
      Creates a freeze block for project and adds it to project.
      Parameters:
      freezables - the freezables
      project - the IVML project to add to (may be null if failed)
      fallbackForType - in case that project is being written the first time, may be null
      Returns:
      the created freeze block
      Throws:
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case of unmatching values
      net.ssehub.easy.varModel.model.ModelQueryException - in case of model access problems
    • createQmProject

      private static net.ssehub.easy.varModel.model.Project createQmProject(String name, net.ssehub.easy.varModel.model.Project typeFallback) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.model.ModelQueryException
      Creates a project with basic settings for QM.
      Parameters:
      name - the name of the project
      typeFallback - a project acting as type fallback (may be null)
      Returns:
      the created project
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - in case of model query problems
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - in case of unmatching values
    • getValue

      private static net.ssehub.easy.varModel.model.values.Value getValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String slot) throws net.ssehub.easy.varModel.model.ModelQueryException
      Returns (a copy) of the value of the slot in var.
      Parameters:
      var - the variable to look into
      slot - the slot name
      Returns:
      the (copied) value
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - if the given slot does not exist
    • addTopLevelValues

      private static List<net.ssehub.easy.varModel.model.IFreezable> addTopLevelValues(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project source, net.ssehub.easy.varModel.model.Project target, String... exclude) throws net.ssehub.easy.varModel.cst.CSTSemanticException
      Adds top level values configured for source to target.
      Parameters:
      cfg - the actual configuration holding the values
      source - the source project
      target - the target project
      exclude - the variable names to exclude
      Returns:
      the changed top-level variables ready for freezing
      Throws:
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
    • addImports

      private static void addImports(net.ssehub.easy.varModel.model.Project source, String[] imports, net.ssehub.easy.varModel.model.Project target, net.ssehub.easy.varModel.model.Project... furtherImports) throws net.ssehub.easy.basics.modelManagement.ModelManagementException
      Adds the given imports to target.
      Parameters:
      source - the project to look for the imports
      imports - the import names to add
      target - the target project to modify as a side effect
      furtherImports - further imports created in this class
      Throws:
      net.ssehub.easy.basics.modelManagement.ModelManagementException - in case of model management problems
    • createDecisionVariable

      private static net.ssehub.easy.varModel.model.DecisionVariableDeclaration createDecisionVariable(String name, net.ssehub.easy.varModel.model.datatypes.IDatatype type, net.ssehub.easy.varModel.model.Project target, Object... values) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException
      Creates a decision variable declaration.
      Parameters:
      name - the name of the variable
      type - the type
      target - the project to add the variable to
      values - the values as default value
      Returns:
      the created variable
      Throws:
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - if the given values do not match
    • setPipelines

      private static net.ssehub.easy.varModel.model.DecisionVariableDeclaration setPipelines(net.ssehub.easy.varModel.model.Project prj, String varName, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipeline) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException
      Sets the given pipeline as value in the varName of prj.
      Parameters:
      prj - the project to modify
      varName - the variable to modify
      pipeline - the pipeline to set as (reference) value
      Returns:
      the affected variable
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - if access to the variable failed
      net.ssehub.easy.varModel.cst.CSTSemanticException - in case of CST errors
      net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - if pipeline does not match as a value