java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_eval.paramtuning.GridSearch

public class GridSearch extends Object
GridSearch for ontology matching with an arbitrary amount of parameter and values to optimize. Important: when using parallel processing, ensure that the matcher does not write to the same results file.
Author:
Sven Hertling
  • Field Details

  • Constructor Details

    • GridSearch

      public GridSearch(Class<?> matcher, String matcherName)
      Constructor
      Parameters:
      matcher - The matcher for which the grid search shall be performed.
      matcherName - Name of the matcher.
    • GridSearch

      public GridSearch(Class<?> matcher)
      Constructor
      Parameters:
      matcher - The matcher for which the grid search shall be performed.
  • Method Details

    • addParameters

      public GridSearch addParameters(Map<String,List<Object>> paramsToValuesGrid)
      Adds a multiple parameter searches. The name (key of the map) can be a nested property. Example values for parameter "name" are:
      • "a" -- sets the value of property a of the specified bean
      • "a.b" -- gets the value of property a of the specified bean, then on that object sets the value of property b.
      • "a(key)" -- sets a value of mapped-property a on the specified bean. This effectively means bean.setA("key").
      • "a[3]" -- sets a value of indexed-property a on the specified bean. This effectively means bean.setA(3).
      (this is from org.apache.commons.beanutils.PropertyUtilsBean)
      Parameters:
      paramsToValuesGrid - a map where the key is a possibly nested name of the property to be modified and the values to which the property is to be set
      Returns:
      GridSearch object (for builder pattern)
    • addParameters

      public GridSearch addParameters(List<String> paramsNames, List<List<Object>> paramsValues)
      Adds a multiple parameter searches. The names can be a nested property. Example values for parameter "name" are:
      • "a" -- sets the value of property a of the specified bean
      • "a.b" -- gets the value of property a of the specified bean, then on that object sets the value of property b.
      • "a(key)" -- sets a value of mapped-property a on the specified bean. This effectively means bean.setA("key").
      • "a[3]" -- sets a value of indexed-property a on the specified bean. This effectively means bean.setA(3).
      (this is from org.apache.commons.beanutils.PropertyUtilsBean)
      Parameters:
      paramsNames - Possibly nested name of the property to be modified
      paramsValues - Values to which the property is to be set
      Returns:
      GridSearch object (for builder pattern)
    • addParameter

      public GridSearch addParameter(String name, Object... paramValues)
      Adds a parameter search. The name can be a nested property. Example values for parameter "name" are:
      • "a" -- sets the value of property a of the specified bean
      • "a.b" -- gets the value of property a of the specified bean, then on that object sets the value of property b.
      • "a(key)" -- sets a value of mapped-property a on the specified bean. This effectively means bean.setA("key").
      • "a[3]" -- sets a value of indexed-property a on the specified bean. This effectively means bean.setA(3).
      (this is from org.apache.commons.beanutils.PropertyUtilsBean)
      Parameters:
      name - Possibly nested name of the property to be modified.
      paramValues - Values to which the property is to be set.
      Returns:
      GridSearch object (for builder pattern).
    • addParameter

      public GridSearch addParameter(String name, List<Object> paramValues)
      Adds a parameter search. The name can be a nested property. Example values for parameter "name" are:
      • "a" -- sets the value of property a of the specified bean
      • "a.b" -- gets the value of property a of the specified bean, then on that object sets the value of property b.
      • "a(key)" -- sets a value of mapped-property a on the specified bean. This effectively means bean.setA("key").
      • "a[3]" -- sets a value of indexed-property a on the specified bean. This effectively means bean.setA(3).
      (this is from org.apache.commons.beanutils.PropertyUtilsBean)
      Parameters:
      name - Possibly nested name of the property to be modified
      paramValues - Values to which the property is to be set
      Returns:
      GridSearch object (for builder pattern)
    • addConstructorParameter

      public GridSearch addConstructorParameter(List<Object> paramValues)
      In case the matcher needs parameters in the constructor which should be changed in each run, use this method. If the constructor of the matcher has n parameters you should call this method n times with values which should be tried out. If the constructor looks like this:
      
       public MyMatcher(int number, String text){
       }
       
      then you should call it like that (order matters!)
      
       gridsearch.addConstructorParameter(1,2,3);
       gridsearch.addConstructorParameter("x", "y");
       
      to have the following calls of the constructor:
      
       new MyMatcher(1, "x")
       new MyMatcher(2, "x")
       new MyMatcher(3, "x")
       new MyMatcher(1, "y")
       new MyMatcher(2, "y")
       new MyMatcher(3, "y")
       
      In case you just want to provide constructor parameters which should not be changed, use addStaticConstructorParameter(java.lang.Object...)
      Parameters:
      paramValues - The parameters for the constructor in the correct order.
      Returns:
      Edited GridSearch instance.
    • addConstructorParameter

      public GridSearch addConstructorParameter(List<Object> paramValues, Class<?> clazz)
      In case the matcher needs parameters in the constructor which should be changed in each run, use this method. If the constructor of the matcher has n parameters you should call this method n times with values which should be tried out. If the constructor looks like this:
      
       public MyMatcher(int number, String text){
       }
       
      then you should call it like that (order matters!)
      
       gridsearch.addConstructorParameter(Arrays.asList(1,2,3), Integer.class);
       gridsearch.addConstructorParameter(Arrays.asList("x", "y"), String.class);
       
      to have the following calls of the constructor:
      
       new MyMatcher(1, "x")
       new MyMatcher(2, "x")
       new MyMatcher(3, "x")
       new MyMatcher(1, "y")
       new MyMatcher(2, "y")
       new MyMatcher(3, "y")
       
      In case you just want to provide constructor parameters which should not be changed, use addStaticConstructorParameter(java.lang.Object...)
      Parameters:
      paramValues - The parameters for the constructor in the correct order.
      clazz - The type of all the values.
      Returns:
      Edited GridSearch instance.
    • addStaticConstructorParameter

      public GridSearch addStaticConstructorParameter(Object... paramValues)
      In case you need parameters for the matcher constructor, but do not want the change them in each run, but keep them the same, then use this method. In case you supply multiple values, the constructor should also need the same amount of parameters (position matters!). This differ to addConstructorParameter(java.util.List) because it does not change the constructor paramters in each run. In case the constructor is not found (java.lang.NoSuchMethodException) then use addStaticConstructorParameter(java.util.List, java.util.List) and specify the types explicitly.
      Parameters:
      paramValues - The parameters for the constructor in the correct order.
      Returns:
      Edited GridSearch instance.
    • addStaticConstructorParameter

      public GridSearch addStaticConstructorParameter(List<Object> paramValues, List<Class<?>> paramTypes)
      In case you need parameters for the matcher constructor, but do not want the change them in each run, but keep them the same, then use this method. In case you supply multiple values, the constructor should also need the same amount of parameters (position matters!). This differ to addConstructorParameter(java.util.List) because it does not change the constructor paramters in each run.
      Parameters:
      paramValues - The parameters values for the constructor in the correct order.
      paramTypes - The parameter type of the constructor in the correct order.
      Returns:
      Edited GridSearch instance.
    • runGridParallel

      public ExecutionResultSet runGridParallel(TestCase testCase)
      Run in parallel on TestCase.
      Parameters:
      testCase - The test case to use.
      Returns:
      ExecutionResultSet instance.
    • runGridParallel

      public ExecutionResultSet runGridParallel(List<TestCase> testCases)
      Run in parallel on multiple TestCase.
      Parameters:
      testCases - The test cases to use.
      Returns:
      ExecutionResultSet instance.
    • runGridParallel

      public ExecutionResultSet runGridParallel(Track track)
    • runGridParallelTracks

      public ExecutionResultSet runGridParallelTracks(List<Track> tracks)
    • runGridParallel

      public ExecutionResultSet runGridParallel(TestCase testCase, int numberOfThreads)
    • runGridParallel

      public ExecutionResultSet runGridParallel(List<TestCase> testCases, int numberOfThreads)
    • runGridParallel

      public ExecutionResultSet runGridParallel(Track track, int numberOfThreads)
    • runGridParallelTrack

      public ExecutionResultSet runGridParallelTrack(List<Track> tracks, int numberOfThreads)
    • runGridSequential

      public ExecutionResultSet runGridSequential(TestCase testCase)
      Run sequentially on a TestCase.
      Parameters:
      testCase - The test case to use.
      Returns:
      ExecutionResultSet instance.
    • runGridSequential

      public ExecutionResultSet runGridSequential(List<TestCase> testCases)
      Run sequentially on multiple TestCase.
      Parameters:
      testCases - The test cases to use.
      Returns:
      ExecutionResultSet instance.
    • runGridSequential

      public ExecutionResultSet runGridSequential(Track track)
      Run sequentially a Track.
      Parameters:
      track - The track to use.
      Returns:
      ExecutionResultSet instance.
    • runGridSequentialTracks

      public ExecutionResultSet runGridSequentialTracks(List<Track> tracks)
      Run sequentially on multiple Track.
      Parameters:
      tracks - The tracks to use.
      Returns:
      ExecutionResultSet instance.
    • updateExecutionResultSet

      public ExecutionResultSet updateExecutionResultSet(ExecutionResultSet set)
      Updates the execution result set with configuration attributes in the extension of the alignment.
      Parameters:
      set - The execution result set to be updated.
      Returns:
      The updated execution result set.
    • getMatcherConfigurations

      public Map<String,Object> getMatcherConfigurations()
    • getMatcherNameWithSettings

      protected String getMatcherNameWithSettings(List<Object> paramValue)
    • getInstantiatedMatcher

      private Object getInstantiatedMatcher(List<Object> paramValue) throws ReflectiveOperationException
      Throws:
      ReflectiveOperationException
    • isConstructorParameter

      private static boolean isConstructorParameter(String parameterName)
    • cartesianProduct

      private static List<List<Object>> cartesianProduct(int index, List<List<Object>> paramValues)