- java.lang.Object
-
- org.logicng.handlers.ComputationHandler
-
- org.logicng.handlers.NumberOfModelsHandler
-
- All Implemented Interfaces:
Handler,ModelEnumerationHandler
public class NumberOfModelsHandler extends ComputationHandler implements ModelEnumerationHandler
A model enumeration handler that terminates the solving process after a given number of models.- Since:
- 1.0
- Version:
- 2.1.0
-
-
Field Summary
-
Fields inherited from class org.logicng.handlers.ComputationHandler
aborted
-
-
Constructor Summary
Constructors Constructor Description NumberOfModelsHandler(int bound)Constructs a new model handler with an upper bound for the number of models (inclusive).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.ComputationHandler
aborted
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.logicng.handlers.ModelEnumerationHandler
aborted
-
-
-
-
Constructor Detail
-
NumberOfModelsHandler
public NumberOfModelsHandler(int bound)
Constructs a new model handler with an upper bound for the number of models (inclusive).- Parameters:
bound- the upper bound- Throws:
IllegalArgumentException- if the number of models to generate is <= 0
-
-
Method Detail
-
started
public void started()
Description copied from interface:HandlerThis method is called when the computation starts.- Specified by:
startedin interfaceHandler- Overrides:
startedin classComputationHandler
-
satHandler
public SATHandler satHandler()
Description copied from interface:ModelEnumerationHandlerReturns a SAT handler which can be used to cancel internal SAT calls of the model enumeration process.- Specified by:
satHandlerin interfaceModelEnumerationHandler- Returns:
- a SAT handler
-
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
-
-