Package org.optaplanner.benchmark.api

## Class PlannerBenchmarkFactory

- java.lang.Object
- - org.optaplanner.benchmark.api.PlannerBenchmarkFactory

- Direct Known Subclasses:
    `DefaultPlannerBenchmarkFactory`

      public abstract class PlannerBenchmarkFactory
      extends Object

  Builds `PlannerBenchmark` instances.

  Supports tweaking the configuration programmatically before a `PlannerBenchmark` instance is build.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PlannerBenchmarkFactory()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract PlannerBenchmark` | `buildPlannerBenchmark()` | Creates a new `PlannerBenchmark` instance.
    `<Solution_> PlannerBenchmark` | `buildPlannerBenchmark​(List<Solution_> problemList)` | Creates a new `PlannerBenchmark` instance for datasets that are already in memory.
    `abstract <Solution_> PlannerBenchmark` | `buildPlannerBenchmark​(Solution_... problems)` | Creates a new `PlannerBenchmark` instance for datasets that are already in memory.
    `static PlannerBenchmarkFactory` | `create​(PlannerBenchmarkConfig benchmarkConfig)` | Uses a `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlFile​(File templateFile)` | Reads an Freemarker template rom the file system that generates an XML benchmark configuration and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlFile​(File templateFile, ClassLoader classLoader)` | As defined by `createFromFreemarkerXmlFile(File)`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlFile​(File templateFile, Object model)` | As defined by `createFromFreemarkerXmlFile(File)`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlFile​(File templateFile, Object model, ClassLoader classLoader)` | As defined by `createFromFreemarkerXmlFile(File)`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlResource​(String templateResource)` | Reads an Freemarker template from the classpath that generates an XML benchmark configuration and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlResource​(String templateResource, ClassLoader classLoader)` | As defined by `createFromFreemarkerXmlResource(String)`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlResource​(String templateResource, Object model)` | As defined by `createFromFreemarkerXmlResource(String)`.
    `static PlannerBenchmarkFactory` | `createFromFreemarkerXmlResource​(String templateResource, Object model, ClassLoader classLoader)` | As defined by `createFromFreemarkerXmlResource(String)`.
    `static PlannerBenchmarkFactory` | `createFromSolverConfigXmlResource​(String solverConfigResource)` | Reads an XML solver configuration from the classpath and uses that `SolverConfig` to build a `PlannerBenchmarkConfig` that in turn is used to build a `PlannerBenchmarkFactory`.
    `static PlannerBenchmarkFactory` | `createFromSolverConfigXmlResource​(String solverConfigResource, File benchmarkDirectory)` | As defined by `createFromSolverConfigXmlResource(String)`.
    `static PlannerBenchmarkFactory` | `createFromSolverConfigXmlResource​(String solverConfigResource, File benchmarkDirectory, ClassLoader classLoader)` | As defined by `createFromSolverConfigXmlResource(String)`.
    `static PlannerBenchmarkFactory` | `createFromSolverConfigXmlResource​(String solverConfigResource, ClassLoader classLoader)` | As defined by `createFromSolverConfigXmlResource(String)`.
    `static PlannerBenchmarkFactory` | `createFromXmlFile​(File benchmarkConfigFile)` | Reads an XML benchmark configuration from the file system and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`.
    `static PlannerBenchmarkFactory` | `createFromXmlFile​(File benchmarkConfigFile, ClassLoader classLoader)` | As defined by `createFromXmlFile(File)`.
    `static PlannerBenchmarkFactory` | `createFromXmlResource​(String benchmarkConfigResource)` | Reads an XML benchmark configuration from the classpath and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`.
    `static PlannerBenchmarkFactory` | `createFromXmlResource​(String benchmarkConfigResource, ClassLoader classLoader)` | As defined by `createFromXmlResource(String)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PlannerBenchmarkFactory

          public PlannerBenchmarkFactory()

  - ### Method Detail

    - #### createFromSolverConfigXmlResource

          public static PlannerBenchmarkFactory createFromSolverConfigXmlResource​(String solverConfigResource)

      Reads an XML solver configuration from the classpath and uses that `SolverConfig` to build a `PlannerBenchmarkConfig` that in turn is used to build a `PlannerBenchmarkFactory`. The XML root element must be `<solver>`.

      To read an XML benchmark configuration instead, use `createFromXmlResource(String)`.

      Parameters:
        `solverConfigResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`

    - #### createFromSolverConfigXmlResource

          public static PlannerBenchmarkFactory createFromSolverConfigXmlResource​(String solverConfigResource,
                                                                                  ClassLoader classLoader)

      As defined by `createFromSolverConfigXmlResource(String)`.
      Parameters:
        `solverConfigResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`.
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`

    - #### createFromSolverConfigXmlResource

          public static PlannerBenchmarkFactory createFromSolverConfigXmlResource​(String solverConfigResource,
                                                                                  File benchmarkDirectory)

      As defined by `createFromSolverConfigXmlResource(String)`.
      Parameters:
        `solverConfigResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
        `benchmarkDirectory` - never null

    - #### createFromSolverConfigXmlResource

          public static PlannerBenchmarkFactory createFromSolverConfigXmlResource​(String solverConfigResource,
                                                                                  File benchmarkDirectory,
                                                                                  ClassLoader classLoader)

      As defined by `createFromSolverConfigXmlResource(String)`.
      Parameters:
        `solverConfigResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
        `benchmarkDirectory` - never null
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`

    - #### createFromXmlResource

          public static PlannerBenchmarkFactory createFromXmlResource​(String benchmarkConfigResource)

      Reads an XML benchmark configuration from the classpath and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`. The XML root element must be `<plannerBenchmark>`.

      To read an XML solver configuration instead, use `createFromSolverConfigXmlResource(String)`.

      Parameters:
        `benchmarkConfigResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
      Returns:
        never null

    - #### createFromXmlResource

          public static PlannerBenchmarkFactory createFromXmlResource​(String benchmarkConfigResource,
                                                                      ClassLoader classLoader)

      As defined by `createFromXmlResource(String)`.
      Parameters:
        `benchmarkConfigResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      Returns:
        never null

    - #### createFromXmlFile

          public static PlannerBenchmarkFactory createFromXmlFile​(File benchmarkConfigFile)

      Reads an XML benchmark configuration from the file system and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`.

      Warning: this leads to platform dependent code, it's recommend to use `createFromXmlResource(String)` instead.

      Parameters:
        `benchmarkConfigFile` - never null
      Returns:
        never null

    - #### createFromXmlFile

          public static PlannerBenchmarkFactory createFromXmlFile​(File benchmarkConfigFile,
                                                                  ClassLoader classLoader)

      As defined by `createFromXmlFile(File)`.
      Parameters:
        `benchmarkConfigFile` - never null
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      Returns:
        never null

    - #### createFromFreemarkerXmlResource

          public static PlannerBenchmarkFactory createFromFreemarkerXmlResource​(String templateResource)

      Reads an Freemarker template from the classpath that generates an XML benchmark configuration and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`. The generated XML root element must be `<plannerBenchmark>`.
      Parameters:
        `templateResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
      Returns:
        never null
      See Also:
        `createFromFreemarkerXmlResource(String)`

    - #### createFromFreemarkerXmlResource

          public static PlannerBenchmarkFactory createFromFreemarkerXmlResource​(String templateResource,
                                                                                ClassLoader classLoader)

      As defined by `createFromFreemarkerXmlResource(String)`.
      Parameters:
        `templateResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      Returns:
        never null

    - #### createFromFreemarkerXmlResource

          public static PlannerBenchmarkFactory createFromFreemarkerXmlResource​(String templateResource,
                                                                                Object model)

      As defined by `createFromFreemarkerXmlResource(String)`.
      Parameters:
        `templateResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
        `model` - sometimes null
      Returns:
        never null

    - #### createFromFreemarkerXmlResource

          public static PlannerBenchmarkFactory createFromFreemarkerXmlResource​(String templateResource,
                                                                                Object model,
                                                                                ClassLoader classLoader)

      As defined by `createFromFreemarkerXmlResource(String)`.
      Parameters:
        `templateResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
        `model` - sometimes null
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      Returns:
        never null

    - #### createFromFreemarkerXmlFile

          public static PlannerBenchmarkFactory createFromFreemarkerXmlFile​(File templateFile)

      Reads an Freemarker template rom the file system that generates an XML benchmark configuration and uses that `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`. The generated XML root element must be `<plannerBenchmark>`.

      Warning: this leads to platform dependent code, it's recommend to use `createFromFreemarkerXmlResource(String)` instead.

      Parameters:
        `templateFile` - never null
      Returns:
        never null

    - #### createFromFreemarkerXmlFile

          public static PlannerBenchmarkFactory createFromFreemarkerXmlFile​(File templateFile,
                                                                            ClassLoader classLoader)

      As defined by `createFromFreemarkerXmlFile(File)`.
      Parameters:
        `templateFile` - never null
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      Returns:
        never null

    - #### createFromFreemarkerXmlFile

          public static PlannerBenchmarkFactory createFromFreemarkerXmlFile​(File templateFile,
                                                                            Object model)

      As defined by `createFromFreemarkerXmlFile(File)`.
      Parameters:
        `templateFile` - never null
        `model` - sometimes null
      Returns:
        never null

    - #### createFromFreemarkerXmlFile

          public static PlannerBenchmarkFactory createFromFreemarkerXmlFile​(File templateFile,
                                                                            Object model,
                                                                            ClassLoader classLoader)

      As defined by `createFromFreemarkerXmlFile(File)`.
      Parameters:
        `templateFile` - never null
        `model` - sometimes null
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      Returns:
        never null

    - #### create

          public static PlannerBenchmarkFactory create​(PlannerBenchmarkConfig benchmarkConfig)

      Uses a `PlannerBenchmarkConfig` to build a `PlannerBenchmarkFactory`. If you don't need to manipulate the `PlannerBenchmarkConfig` programmatically, use `createFromXmlResource(String)` instead.
      Parameters:
        `benchmarkConfig` - never null
      Returns:
        never null

    - #### buildPlannerBenchmark

          public abstract PlannerBenchmark buildPlannerBenchmark()

      Creates a new `PlannerBenchmark` instance.
      Returns:
        never null

    - #### buildPlannerBenchmark

          public <Solution_> PlannerBenchmark buildPlannerBenchmark​(List<Solution_> problemList)

      Creates a new `PlannerBenchmark` instance for datasets that are already in memory.
      Type Parameters:
        `Solution_` - the solution type, the class with the `PlanningSolution` annotation
      Parameters:
        `problemList` - never null, can be empty
      Returns:
        never null

    - #### buildPlannerBenchmark

          public abstract <Solution_> PlannerBenchmark buildPlannerBenchmark​(Solution_... problems)

      Creates a new `PlannerBenchmark` instance for datasets that are already in memory.
      Type Parameters:
        `Solution_` - the solution type, the class with the `PlanningSolution` annotation
      Parameters:
        `problems` - never null, can be none
      Returns:
        never null