D. Stop Conditions

List of all stop conditions in JCOP

In table 1 is a list of all stop conditions bundled with JCOP, along with summary when they are met and which messages they accept. Note that all of them extends BaseCondition.

Name Met Accepted messages
AndCondition all of its conditions are met none
FoundSolutionCondition MessageSolutionFound is received MessageSolverStart
MessageSolutionFound
IterationCondition MessageOptimize is received enough times MessageSolverStart
MessageOptimize
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

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

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

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

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

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.