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
BuildsPlannerBenchmark
instances.Supports tweaking the configuration programmatically before a
PlannerBenchmark
instance is build.
-
-
Constructor Summary
Constructors Constructor Description PlannerBenchmarkFactory()
-
Method Summary
-
-
-
Method Detail
-
createFromSolverConfigXmlResource
public static PlannerBenchmarkFactory createFromSolverConfigXmlResource(String solverConfigResource)
Reads an XML solver configuration from the classpath and uses thatSolverConfig
to build aPlannerBenchmarkConfig
that in turn is used to build aPlannerBenchmarkFactory
. 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 byClassLoader.getResource(String)
-
createFromSolverConfigXmlResource
public static PlannerBenchmarkFactory createFromSolverConfigXmlResource(String solverConfigResource, ClassLoader classLoader)
As defined bycreateFromSolverConfigXmlResource(String)
.- Parameters:
solverConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
.classLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
-
createFromSolverConfigXmlResource
public static PlannerBenchmarkFactory createFromSolverConfigXmlResource(String solverConfigResource, File benchmarkDirectory)
As defined bycreateFromSolverConfigXmlResource(String)
.- Parameters:
solverConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
benchmarkDirectory
- never null
-
createFromSolverConfigXmlResource
public static PlannerBenchmarkFactory createFromSolverConfigXmlResource(String solverConfigResource, File benchmarkDirectory, ClassLoader classLoader)
As defined bycreateFromSolverConfigXmlResource(String)
.- Parameters:
solverConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
benchmarkDirectory
- never nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
-
createFromXmlResource
public static PlannerBenchmarkFactory createFromXmlResource(String benchmarkConfigResource)
Reads an XML benchmark configuration from the classpath and uses thatPlannerBenchmarkConfig
to build aPlannerBenchmarkFactory
. 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 byClassLoader.getResource(String)
- Returns:
- never null
-
createFromXmlResource
public static PlannerBenchmarkFactory createFromXmlResource(String benchmarkConfigResource, ClassLoader classLoader)
As defined bycreateFromXmlResource(String)
.- Parameters:
benchmarkConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
classLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromXmlFile
public static PlannerBenchmarkFactory createFromXmlFile(File benchmarkConfigFile)
Reads an XML benchmark configuration from the file system and uses thatPlannerBenchmarkConfig
to build aPlannerBenchmarkFactory
.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 bycreateFromXmlFile(File)
.- Parameters:
benchmarkConfigFile
- never nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- 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 thatPlannerBenchmarkConfig
to build aPlannerBenchmarkFactory
. The generated XML root element must be<plannerBenchmark>
.- Parameters:
templateResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
- Returns:
- never null
- See Also:
createFromFreemarkerXmlResource(String)
-
createFromFreemarkerXmlResource
public static PlannerBenchmarkFactory createFromFreemarkerXmlResource(String templateResource, ClassLoader classLoader)
As defined bycreateFromFreemarkerXmlResource(String)
.- Parameters:
templateResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
classLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromFreemarkerXmlResource
public static PlannerBenchmarkFactory createFromFreemarkerXmlResource(String templateResource, Object model)
As defined bycreateFromFreemarkerXmlResource(String)
.- Parameters:
templateResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
model
- sometimes null- Returns:
- never null
-
createFromFreemarkerXmlResource
public static PlannerBenchmarkFactory createFromFreemarkerXmlResource(String templateResource, Object model, ClassLoader classLoader)
As defined bycreateFromFreemarkerXmlResource(String)
.- Parameters:
templateResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
model
- sometimes nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- 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 thatPlannerBenchmarkConfig
to build aPlannerBenchmarkFactory
. 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 bycreateFromFreemarkerXmlFile(File)
.- Parameters:
templateFile
- never nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromFreemarkerXmlFile
public static PlannerBenchmarkFactory createFromFreemarkerXmlFile(File templateFile, Object model)
As defined bycreateFromFreemarkerXmlFile(File)
.- Parameters:
templateFile
- never nullmodel
- sometimes null- Returns:
- never null
-
createFromFreemarkerXmlFile
public static PlannerBenchmarkFactory createFromFreemarkerXmlFile(File templateFile, Object model, ClassLoader classLoader)
As defined bycreateFromFreemarkerXmlFile(File)
.- Parameters:
templateFile
- never nullmodel
- sometimes nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
create
public static PlannerBenchmarkFactory create(PlannerBenchmarkConfig benchmarkConfig)
Uses aPlannerBenchmarkConfig
to build aPlannerBenchmarkFactory
. If you don't need to manipulate thePlannerBenchmarkConfig
programmatically, usecreateFromXmlResource(String)
instead.- Parameters:
benchmarkConfig
- never null- Returns:
- never null
-
buildPlannerBenchmark
public abstract PlannerBenchmark buildPlannerBenchmark()
Creates a newPlannerBenchmark
instance.- Returns:
- never null
-
buildPlannerBenchmark
public <Solution_> PlannerBenchmark buildPlannerBenchmark(List<Solution_> problemList)
Creates a newPlannerBenchmark
instance for datasets that are already in memory.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation- Parameters:
problemList
- never null, can be empty- Returns:
- never null
-
buildPlannerBenchmark
public abstract <Solution_> PlannerBenchmark buildPlannerBenchmark(Solution_... problems)
Creates a newPlannerBenchmark
instance for datasets that are already in memory.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation- Parameters:
problems
- never null, can be none- Returns:
- never null
-
-