- java.lang.Object
-
- org.logicng.handlers.ComputationHandler
-
- org.logicng.handlers.TimeoutHandler
-
- org.logicng.handlers.TimeoutMaxSATHandler
-
- All Implemented Interfaces:
Handler,MaxSATHandler
public class TimeoutMaxSATHandler extends TimeoutHandler implements MaxSATHandler
A MaxSAT handler which cancels the solving 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 TimeoutMaxSATHandler(long timeout)Constructs a new timeout handler with a given timeout and uses the timeout typeTimeoutHandler.TimerType.SINGLE_TIMEOUT.TimeoutMaxSATHandler(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.voidfinishedSolving()This method is called when the MaxSAT solver finished solving.booleanfoundLowerBound(int lowerBound, Assignment model)This method is called when the MaxSAT solver found a new lower bound for a solution.booleanfoundUpperBound(int upperBound, Assignment model)This method is called when the MaxSAT solver found a new upper bound for a solution.intlowerBoundApproximation()Returns the last approximation of the result or -1 if there is no approximation for the lower bound.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.intupperBoundApproximation()Returns the last approximation of the result or -1 if there is no approximation for the lower bound.-
Methods inherited from class org.logicng.handlers.TimeoutHandler
timeLimitExceeded
-
-
-
-
Constructor Detail
-
TimeoutMaxSATHandler
public TimeoutMaxSATHandler(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.
foundApproximation()orSATHandler.detectedConflict().- Parameters:
timeout- the timeout in milliseconds, its meaning is defined by the timeout typetype- the type of the timer, must not benull
-
TimeoutMaxSATHandler
public TimeoutMaxSATHandler(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
-
started
public void started()
Description copied from interface:HandlerThis method is called when the computation starts.- Specified by:
startedin interfaceHandler- Overrides:
startedin classTimeoutHandler
-
aborted
public boolean aborted()
Description copied from interface:HandlerReturns whether the computation was aborted by the handler.- Specified by:
abortedin interfaceHandler- Specified by:
abortedin interfaceMaxSATHandler- Overrides:
abortedin classComputationHandler- Returns:
trueif the computation was aborted by the handler, otherwisefalse
-
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 interfaceMaxSATHandler- Returns:
- the SAT handler
-
foundLowerBound
public boolean foundLowerBound(int lowerBound, Assignment model)Description copied from interface:MaxSATHandlerThis method is called when the MaxSAT solver found a new lower bound for a solution.- Specified by:
foundLowerBoundin interfaceMaxSATHandler- Parameters:
lowerBound- the cost of the lower boundmodel- the model of the lower bound, may be null if not applicable- Returns:
trueif the solving process should be continued, otherwisefalse
-
foundUpperBound
public boolean foundUpperBound(int upperBound, Assignment model)Description copied from interface:MaxSATHandlerThis method is called when the MaxSAT solver found a new upper bound for a solution.- Specified by:
foundUpperBoundin interfaceMaxSATHandler- Parameters:
upperBound- the cost of the upper boundmodel- the model of the upper bound, may be null if not applicable- Returns:
trueif the solving process should be continued, otherwisefalse
-
finishedSolving
public void finishedSolving()
Description copied from interface:MaxSATHandlerThis method is called when the MaxSAT solver finished solving.- Specified by:
finishedSolvingin interfaceMaxSATHandler
-
lowerBoundApproximation
public int lowerBoundApproximation()
Description copied from interface:MaxSATHandlerReturns the last approximation of the result or -1 if there is no approximation for the lower bound. If the handler does not cancel the solving process, it is not guaranteed that this method will return the optimal result. Use the respective method of the MaxSAT solver instead.- Specified by:
lowerBoundApproximationin interfaceMaxSATHandler- Returns:
- the last approximation of the result or -1 if no approximation is known
-
upperBoundApproximation
public int upperBoundApproximation()
Description copied from interface:MaxSATHandlerReturns the last approximation of the result or -1 if there is no approximation for the lower bound. If the handler does not cancel the solving process, it is not guaranteed that this method will return the optimal result. Use the respective method of the MaxSAT solver instead.- Specified by:
upperBoundApproximationin interfaceMaxSATHandler- Returns:
- the last approximation of the result or -1 if no approximation is known
-
-