Module logicng

Class TimeoutOptimizationHandler

    • Constructor Detail

      • TimeoutOptimizationHandler

        public TimeoutOptimizationHandler​(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: Note that it might take a few milliseconds more until the computation is actually canceled, since the handler depends on the next found model.
        Parameters:
        timeout - the timeout in milliseconds, its meaning is defined by the timeout type
        type - the type of the timer, must not be null
      • TimeoutOptimizationHandler

        public TimeoutOptimizationHandler​(long timeout)
        Constructs a new timeout handler with a given timeout and uses the timeout type TimeoutHandler.TimerType.SINGLE_TIMEOUT. Thus, the timeout is started when Handler.started() is called and further calls to Handler.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 to started().
        Specified by:
        satHandler in interface OptimizationHandler
        Returns:
        the SAT handler
      • aborted

        public boolean aborted()
        Description copied from interface: Handler
        Returns whether the computation was aborted by the handler.
        Specified by:
        aborted in interface Handler
        Specified by:
        aborted in interface OptimizationHandler
        Overrides:
        aborted in class ComputationHandler
        Returns:
        true if the computation was aborted by the handler, otherwise false
      • started

        public void started()
        Description copied from interface: Handler
        This method is called when the computation starts.
        Specified by:
        started in interface Handler
        Overrides:
        started in class TimeoutHandler
      • foundBetterBound

        public boolean foundBetterBound​(Supplier<Assignment> lastModelProvider)
        Description copied from interface: OptimizationHandler
        This method is called when the solver found a better bound for the optimization.
        Specified by:
        foundBetterBound in interface OptimizationHandler
        Parameters:
        lastModelProvider - a provider for the current result, can be used to examine the current result or to use this result if the optimization should be aborted
        Returns:
        true if the optimization process should be continued, otherwise false
      • getIntermediateResult

        public Assignment getIntermediateResult()
        Returns the latest intermediate result of the optimization or null if no such result was yet computed.
        Returns:
        the latest intermediate result