- java.lang.Object
-
- org.logicng.handlers.ComputationHandler
-
- org.logicng.handlers.TimeoutHandler
-
- org.logicng.handlers.TimeoutModelEnumerationHandler
-
- All Implemented Interfaces:
Handler,ModelEnumerationHandler
public class TimeoutModelEnumerationHandler extends TimeoutHandler implements ModelEnumerationHandler
A model enumeration handler which cancels the computation process after a given timeout.- Since:
- 1.0
- Version:
- 2.1.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.logicng.handlers.TimeoutHandler
TimeoutHandler.TimerType
-
-
Field Summary
-
Fields inherited from class org.logicng.handlers.TimeoutHandler
designatedEnd, timeout, type
-
Fields inherited from class org.logicng.handlers.ComputationHandler
aborted
-
-
Constructor Summary
Constructors Constructor Description TimeoutModelEnumerationHandler(long timeout)Constructs a new timeout handler with a given timeout and uses the timeout typeTimeoutHandler.TimerType.SINGLE_TIMEOUT.TimeoutModelEnumerationHandler(long timeout, TimeoutHandler.TimerType type)Constructs a new timeout handler with a given timeout and a timeout type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaborted()Returns whether the computation was aborted by the handler.booleanfoundModel(Assignment assignment)This method is called every time a model is found.SATHandlersatHandler()Returns a SAT handler which can be used to cancel internal SAT calls of the model enumeration process.voidstarted()This method is called when the computation starts.-
Methods inherited from class org.logicng.handlers.TimeoutHandler
timeLimitExceeded
-
-
-
-
Constructor Detail
-
TimeoutModelEnumerationHandler
public TimeoutModelEnumerationHandler(long timeout, TimeoutHandler.TimerType type)Constructs a new timeout handler with a given timeout and a timeout type. The interpretation of the timeout depends on the timeout type:TimeoutHandler.TimerType.SINGLE_TIMEOUT: The timeout is started whenHandler.started()is called. Further calls toHandler.started()have no effect on the timeout. Thus, the timeout can only be started once.TimeoutHandler.TimerType.RESTARTING_TIMEOUT: The timeout is restarted whenHandler.started()is called.TimeoutHandler.TimerType.FIXED_END: Timeout which is interpreted as fixed point in time (in milliseconds) at which the computation should be aborted. The methodHandler.started()must still be called, but does not have an effect on the timeout.
- Parameters:
timeout- the timeout in milliseconds, its meaning is defined by the timeout typetype- the type of the timer, must not benull
-
TimeoutModelEnumerationHandler
public TimeoutModelEnumerationHandler(long timeout)
Constructs a new timeout handler with a given timeout and uses the timeout typeTimeoutHandler.TimerType.SINGLE_TIMEOUT. Thus, the timeout is started whenHandler.started()is called and further calls toHandler.started()have no effect on the timeout.- Parameters:
timeout- the timeout in milliseconds
-
-
Method Detail
-
satHandler
public SATHandler satHandler()
Returns a SAT handler which can be used to cancel internal SAT calls of the model enumeration process. Note that this handler will only be available after the first call tostarted().- Specified by:
satHandlerin interfaceModelEnumerationHandler- Returns:
- the SAT handler
-
aborted
public boolean aborted()
Description copied from interface:HandlerReturns whether the computation was aborted by the handler.- Specified by:
abortedin interfaceHandler- Specified by:
abortedin interfaceModelEnumerationHandler- Overrides:
abortedin classComputationHandler- Returns:
trueif the computation was aborted by the handler, otherwisefalse
-
started
public void started()
Description copied from interface:HandlerThis method is called when the computation starts.- Specified by:
startedin interfaceHandler- Overrides:
startedin classTimeoutHandler
-
foundModel
public boolean foundModel(Assignment assignment)
Description copied from interface:ModelEnumerationHandlerThis method is called every time a model is found.- Specified by:
foundModelin interfaceModelEnumerationHandler- Parameters:
assignment- the respective model- Returns:
trueif more models should be searched, otherwisefalse
-
-