Enum EnvironmentMode
- java.lang.Object
-
- java.lang.Enum<EnvironmentMode>
-
- org.optaplanner.core.config.solver.EnvironmentMode
-
- All Implemented Interfaces:
Serializable
,Comparable<EnvironmentMode>
public enum EnvironmentMode extends Enum<EnvironmentMode>
The environment mode also allows you to detect common bugs in your implementation.Also, a
Solver
has a singleRandom
instance. Some optimization algorithms use theRandom
instance a lot more than others. For example simulated annealing depends highly on random numbers, while tabu search only depends on it to deal with score ties. This environment mode influences the seed of thatRandom
instance.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description FAST_ASSERT
This mode turns on several assertions (but not all of them) to fail-fast on a bug in aMove
implementation, a constraint rule, the engine itself or something else at a reasonable performance cost (in development at least).FULL_ASSERT
This mode turns on all assertions to fail-fast on a bug in aMove
implementation, a constraint, the engine itself or something else at a horrible performance cost.NON_INTRUSIVE_FULL_ASSERT
This mode turns on several assertions (but not all of them) to fail-fast on a bug in aMove
implementation, a constraint, the engine itself or something else at an overwhelming performance cost.NON_REPRODUCIBLE
The non reproducible mode is equally fast or slightly faster thanREPRODUCIBLE
.REPRODUCIBLE
The reproducible mode is the default mode because it is recommended during development.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isAsserted()
boolean
isIntrusiveFastAsserted()
boolean
isNonIntrusiveFullAsserted()
boolean
isReproducible()
static EnvironmentMode
valueOf(String name)
Returns the enum constant of this type with the specified name.static EnvironmentMode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FULL_ASSERT
public static final EnvironmentMode FULL_ASSERT
This mode turns on all assertions to fail-fast on a bug in aMove
implementation, a constraint, the engine itself or something else at a horrible performance cost.This mode is reproducible (see
REPRODUCIBLE
mode).This mode is intrusive because it calls the
InnerScoreDirector.calculateScore()
more frequently than a non assert mode.This mode is horribly slow.
-
NON_INTRUSIVE_FULL_ASSERT
public static final EnvironmentMode NON_INTRUSIVE_FULL_ASSERT
This mode turns on several assertions (but not all of them) to fail-fast on a bug in aMove
implementation, a constraint, the engine itself or something else at an overwhelming performance cost.This mode is reproducible (see
REPRODUCIBLE
mode).This mode is non-intrusive, unlike
FULL_ASSERT
andFAST_ASSERT
.This mode is horribly slow.
-
FAST_ASSERT
public static final EnvironmentMode FAST_ASSERT
This mode turns on several assertions (but not all of them) to fail-fast on a bug in aMove
implementation, a constraint rule, the engine itself or something else at a reasonable performance cost (in development at least).This mode is reproducible (see
REPRODUCIBLE
mode).This mode is intrusive because it calls the
InnerScoreDirector.calculateScore()
more frequently than a non assert mode.This mode is slow.
-
REPRODUCIBLE
public static final EnvironmentMode REPRODUCIBLE
The reproducible mode is the default mode because it is recommended during development. In this mode, 2 runs on the same computer will execute the same code in the same order. They will also yield the same result, except if they use a time based termination and they have a sufficiently large difference in allocated CPU time. This allows you to benchmark new optimizations (such as a newMove
implementation) fairly and reproduce bugs in your code reliably.Warning: some code can disrupt reproducibility regardless of this mode. See the reference manual for more info.
In practice, this mode uses the default random seed, and it also disables certain concurrency optimizations (such as work stealing).
-
NON_REPRODUCIBLE
public static final EnvironmentMode NON_REPRODUCIBLE
The non reproducible mode is equally fast or slightly faster thanREPRODUCIBLE
.The random seed is different on every run, which makes it more robust against an unlucky random seed. An unlucky random seed gives a bad result on a certain data set with a certain solver configuration. Note that in most use cases the impact of the random seed is relatively low on the result. An occasional bad result is far more likely to be caused by another issue (such as a score trap).
In multithreaded scenarios, this mode allows the use of work stealing and other non deterministic speed tricks.
-
-
Method Detail
-
values
public static EnvironmentMode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (EnvironmentMode c : EnvironmentMode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EnvironmentMode valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isAsserted
public boolean isAsserted()
-
isNonIntrusiveFullAsserted
public boolean isNonIntrusiveFullAsserted()
-
isIntrusiveFastAsserted
public boolean isIntrusiveFastAsserted()
-
isReproducible
public boolean isReproducible()
-
-