D. Stop Conditions
List of all stop conditions in JCOP
|AndCondition||all of its conditions are met||none|
|FoundSolutionCondition||MessageSolutionFound is received||MessageSolverStart
|IterationCondition||MessageOptimize is received enough times||MessageSolverStart
|OrCondition||any of its conditions is met||none|
|TimeoutCondition||CPU time of solver is high enough||MessageSolverStart|
Table 1: List of stop conditions in JCOP.
AndCondition is used to create complex conditions. It can hold any number of stop conditions (added in constructor or by calling AndCondition#addStopCondition(StopCondition)). Whenever it is evaluated, returns true iff no stop condition in it returned false. It accepts no messages.
FoundSolutionCondition returns true at least one solution was found (solution is such configuration for which Problem#isSolution(Configuration) returns true). It accepts MessageSolverStart to reset it internal status and MessageSolutionFound to notify that solution was found.
IterationCondition counts number of optimizations in solver iteration. When a threshold specified in constructor is achieved, it returns true. Accepts MessageOptimize to increase internal optimization counter and MessageSolverStart to reset it to zero.
OrCondition is used to create complex conditions. It can hold any number of stop conditions (added in constructor or by calling OrCondition#addStopCondition(StopCondition)). Whenever it is evaluated, returns true iff at least one stop condition in it returned true. It accepts no messages.
TimeoutCondition limits how long can one solver iteration run. Limit time in miliseconds is given in constructor. Uses PreciseTime#getCpuTimeMili() to get CPU time. Returns true after specified time has elapsed. Accepts MessageSolverStart to reset timer.