Package org.optaplanner.benchmark.config
Class PlannerBenchmarkConfig
- java.lang.Object
-
- org.optaplanner.benchmark.config.PlannerBenchmarkConfig
-
public class PlannerBenchmarkConfig extends Object
To read it from XML, usecreateFromXmlResource(String)
. To build aPlannerBenchmarkFactory
with it, usePlannerBenchmarkFactory.create(PlannerBenchmarkConfig)
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PARALLEL_BENCHMARK_COUNT_AUTO
static Pattern
VALID_NAME_PATTERN
-
Constructor Summary
Constructors Constructor Description PlannerBenchmarkConfig()
Create an empty benchmark config.PlannerBenchmarkConfig(ClassLoader classLoader)
-
Method Summary
-
-
-
Field Detail
-
PARALLEL_BENCHMARK_COUNT_AUTO
public static final String PARALLEL_BENCHMARK_COUNT_AUTO
- See Also:
- Constant Field Values
-
VALID_NAME_PATTERN
public static final Pattern VALID_NAME_PATTERN
-
-
Constructor Detail
-
PlannerBenchmarkConfig
public PlannerBenchmarkConfig()
Create an empty benchmark config.
-
PlannerBenchmarkConfig
public PlannerBenchmarkConfig(ClassLoader classLoader)
- Parameters:
classLoader
- sometimes null
-
-
Method Detail
-
createFromSolverConfig
public static PlannerBenchmarkConfig createFromSolverConfig(SolverConfig solverConfig)
- Parameters:
solverConfig
- never null
-
createFromSolverConfig
public static PlannerBenchmarkConfig createFromSolverConfig(SolverConfig solverConfig, File benchmarkDirectory)
- Parameters:
solverConfig
- never nullbenchmarkDirectory
- never null
-
createFromXmlResource
public static PlannerBenchmarkConfig createFromXmlResource(String benchmarkConfigResource)
Reads an XML benchmark configuration from the classpath.- Parameters:
benchmarkConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
- Returns:
- never null
-
createFromXmlResource
public static PlannerBenchmarkConfig 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 PlannerBenchmarkConfig createFromXmlFile(File benchmarkConfigFile)
Reads an XML benchmark configuration from the file system.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 PlannerBenchmarkConfig 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
-
createFromXmlInputStream
public static PlannerBenchmarkConfig createFromXmlInputStream(InputStream in)
- Parameters:
in
- never null, gets closed- Returns:
- never null
-
createFromXmlInputStream
public static PlannerBenchmarkConfig createFromXmlInputStream(InputStream in, ClassLoader classLoader)
- Parameters:
in
- never null, gets closedclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromXmlReader
public static PlannerBenchmarkConfig createFromXmlReader(Reader reader)
- Parameters:
reader
- never null, gets closed- Returns:
- never null
-
createFromXmlReader
public static PlannerBenchmarkConfig createFromXmlReader(Reader reader, ClassLoader classLoader)
- Parameters:
reader
- never null, gets closedclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromFreemarkerXmlResource
public static PlannerBenchmarkConfig createFromFreemarkerXmlResource(String templateResource)
Reads a Freemarker XML benchmark configuration from the classpath.- Parameters:
templateResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
- Returns:
- never null
-
createFromFreemarkerXmlResource
public static PlannerBenchmarkConfig 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 PlannerBenchmarkConfig 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 PlannerBenchmarkConfig 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 PlannerBenchmarkConfig createFromFreemarkerXmlFile(File templateFile)
Reads a Freemarker XML benchmark configuration from the file system.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 PlannerBenchmarkConfig 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 PlannerBenchmarkConfig createFromFreemarkerXmlFile(File templateFile, Object model)
As defined bycreateFromFreemarkerXmlFile(File)
.- Parameters:
templateFile
- never nullmodel
- sometimes null- Returns:
- never null
-
createFromFreemarkerXmlFile
public static PlannerBenchmarkConfig 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
-
createFromFreemarkerXmlInputStream
public static PlannerBenchmarkConfig createFromFreemarkerXmlInputStream(InputStream templateIn)
- Parameters:
templateIn
- never null, gets closed- Returns:
- never null
-
createFromFreemarkerXmlInputStream
public static PlannerBenchmarkConfig createFromFreemarkerXmlInputStream(InputStream templateIn, ClassLoader classLoader)
As defined bycreateFromFreemarkerXmlInputStream(InputStream)
.- Parameters:
templateIn
- never null, gets closedclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromFreemarkerXmlInputStream
public static PlannerBenchmarkConfig createFromFreemarkerXmlInputStream(InputStream templateIn, Object model)
As defined bycreateFromFreemarkerXmlInputStream(InputStream)
.- Parameters:
templateIn
- never null, gets closedmodel
- sometimes null- Returns:
- never null
-
createFromFreemarkerXmlInputStream
public static PlannerBenchmarkConfig createFromFreemarkerXmlInputStream(InputStream templateIn, Object model, ClassLoader classLoader)
As defined bycreateFromFreemarkerXmlInputStream(InputStream)
.- Parameters:
templateIn
- never null, gets closedmodel
- sometimes nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromFreemarkerXmlReader
public static PlannerBenchmarkConfig createFromFreemarkerXmlReader(Reader templateReader)
- Parameters:
templateReader
- never null, gets closed- Returns:
- never null
-
createFromFreemarkerXmlReader
public static PlannerBenchmarkConfig createFromFreemarkerXmlReader(Reader templateReader, ClassLoader classLoader)
As defined bycreateFromFreemarkerXmlReader(Reader)
.- Parameters:
templateReader
- never null, gets closedclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromFreemarkerXmlReader
public static PlannerBenchmarkConfig createFromFreemarkerXmlReader(Reader templateReader, Object model)
As defined bycreateFromFreemarkerXmlReader(Reader)
.- Parameters:
templateReader
- never null, gets closedmodel
- sometimes null- Returns:
- never null
-
createFromFreemarkerXmlReader
public static PlannerBenchmarkConfig createFromFreemarkerXmlReader(Reader templateReader, Object model, ClassLoader classLoader)
As defined bycreateFromFreemarkerXmlReader(Reader)
.- Parameters:
templateReader
- never null, gets closedmodel
- sometimes nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
getClassLoader
public ClassLoader getClassLoader()
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
-
getName
public String getName()
-
setName
public void setName(String name)
-
getBenchmarkDirectory
public File getBenchmarkDirectory()
-
setBenchmarkDirectory
public void setBenchmarkDirectory(File benchmarkDirectory)
-
getThreadFactoryClass
public Class<? extends ThreadFactory> getThreadFactoryClass()
-
setThreadFactoryClass
public void setThreadFactoryClass(Class<? extends ThreadFactory> threadFactoryClass)
-
getParallelBenchmarkCount
public String getParallelBenchmarkCount()
Using multiple parallel benchmarks can decrease the reliability of the results.If there aren't enough processors available, it will be decreased.
- Returns:
- null, a number, "AUTO" or a JavaScript calculation using "availableProcessorCount".
-
setParallelBenchmarkCount
public void setParallelBenchmarkCount(String parallelBenchmarkCount)
-
getWarmUpMillisecondsSpentLimit
public Long getWarmUpMillisecondsSpentLimit()
-
setWarmUpMillisecondsSpentLimit
public void setWarmUpMillisecondsSpentLimit(Long warmUpMillisecondsSpentLimit)
-
getWarmUpSecondsSpentLimit
public Long getWarmUpSecondsSpentLimit()
-
setWarmUpSecondsSpentLimit
public void setWarmUpSecondsSpentLimit(Long warmUpSecondsSpentLimit)
-
getWarmUpMinutesSpentLimit
public Long getWarmUpMinutesSpentLimit()
-
setWarmUpMinutesSpentLimit
public void setWarmUpMinutesSpentLimit(Long warmUpMinutesSpentLimit)
-
getWarmUpHoursSpentLimit
public Long getWarmUpHoursSpentLimit()
-
setWarmUpHoursSpentLimit
public void setWarmUpHoursSpentLimit(Long warmUpHoursSpentLimit)
-
getWarmUpDaysSpentLimit
public Long getWarmUpDaysSpentLimit()
-
setWarmUpDaysSpentLimit
public void setWarmUpDaysSpentLimit(Long warmUpDaysSpentLimit)
-
getBenchmarkReportConfig
public BenchmarkReportConfig getBenchmarkReportConfig()
-
setBenchmarkReportConfig
public void setBenchmarkReportConfig(BenchmarkReportConfig benchmarkReportConfig)
-
getInheritedSolverBenchmarkConfig
public SolverBenchmarkConfig getInheritedSolverBenchmarkConfig()
-
setInheritedSolverBenchmarkConfig
public void setInheritedSolverBenchmarkConfig(SolverBenchmarkConfig inheritedSolverBenchmarkConfig)
-
getSolverBenchmarkBluePrintConfigList
public List<SolverBenchmarkBluePrintConfig> getSolverBenchmarkBluePrintConfigList()
-
setSolverBenchmarkBluePrintConfigList
public void setSolverBenchmarkBluePrintConfigList(List<SolverBenchmarkBluePrintConfig> solverBenchmarkBluePrintConfigList)
-
getSolverBenchmarkConfigList
public List<SolverBenchmarkConfig> getSolverBenchmarkConfigList()
-
setSolverBenchmarkConfigList
public void setSolverBenchmarkConfigList(List<SolverBenchmarkConfig> solverBenchmarkConfigList)
-
buildPlannerBenchmark
public PlannerBenchmark buildPlannerBenchmark(SolverConfigContext solverConfigContext)
Do not use this method, it is an internal method. UsePlannerBenchmarkFactory.buildPlannerBenchmark()
instead.Will be removed in 8.0.
- Parameters:
solverConfigContext
- never null- Returns:
- never null
-
buildPlannerBenchmark
public <Solution_> PlannerBenchmark buildPlannerBenchmark(SolverConfigContext solverConfigContext, Solution_[] extraProblems)
Do not use this method, it is an internal method. UsePlannerBenchmarkFactory.buildPlannerBenchmark(Object[])
instead.Will be removed in 8.0.
- Parameters:
solverConfigContext
- never nullextraProblems
- never null- Returns:
- never null
-
validate
protected void validate()
-
generateSolverBenchmarkConfigNames
protected void generateSolverBenchmarkConfigNames()
-
buildEffectiveSolverBenchmarkConfigList
protected List<SolverBenchmarkConfig> buildEffectiveSolverBenchmarkConfigList()
-
resolveParallelBenchmarkCount
protected int resolveParallelBenchmarkCount()
-
resolveParallelBenchmarkCountAutomatically
protected int resolveParallelBenchmarkCountAutomatically(int availableProcessorCount)
-
calculateWarmUpTimeMillisSpentLimit
protected Long calculateWarmUpTimeMillisSpentLimit()
-
-