Interface SolutionListener<T extends Var>

    • Method Detail

      • executeAfterSolution

        boolean executeAfterSolution​(Search<T> search,
                                     SelectChoicePoint<T> select)
        It is executed by search after a solution is found.
        Parameters:
        search - the search which have found a solution.
        select - the select choice point heuristic
        Returns:
        false forces the search to keep looking for a solution, true then the search will accept a solution.
      • assignSolution

        boolean assignSolution​(Store store,
                               int no)
        It imposes the constraints, so the last found solution is enforced.
        Parameters:
        store - store in which the solution is enforced.
        no - the number of the solution to be enforced.
        Returns:
        true if the store is consistent after enforcing a solution, false otherwise.
      • toString

        java.lang.String toString()
        It returns the string representation of the last solution.
        Overrides:
        toString in class java.lang.Object
      • getVariables

        T[] getVariables()
        It returns the variables in the same order as the one used to encode solutions.
        Returns:
        list of variables
      • getSolutions

        Domain[][] getSolutions()
        It returns all solutions. Each solution is in a separate array.
        Returns:
        first dimension is indexed by solution, second dimension is indexed by a variable.
      • returnSolution

        PrimitiveConstraint[] returnSolution()
        It returns a collection of constraints which represent the last found solution.
        Returns:
        the set of constraints which imposed enforce the last found solution.
      • getSolution

        Domain[] getSolution​(int no)
        It returns the solution number no.
        Parameters:
        no - it obtains the solution with a given index.
        Returns:
        array containing assignments to search variables.
      • solutionsNo

        int solutionsNo()
        It returns number of solutions found while using this choice point selector.
        Returns:
        the number of solutions.
      • searchAll

        void searchAll​(boolean status)
        It will enforce the solution listener to instruct search to keep looking for a solution making the search explore the whole search space.
        Parameters:
        status - true if we are interested in search for all solutions, false otherwise.
      • recordSolutions

        void recordSolutions​(boolean status)
        It records each solution so it can be later retrieved and used. Search will always record the last solution.
        Parameters:
        status - true if we are interested in recording all solutions, false otherwise.
      • setParentSolutionListener

        void setParentSolutionListener​(SolutionListener<? extends Var> parent)
        It allows to inform sub-search of what is the current number of the solution in master search.
        Parameters:
        parent - solution listener used by a master search.
      • findSolutionMatchingParent

        int findSolutionMatchingParent​(int parentSolutionNo)
        For a given master solution finds any solution within that listener which matches the master solution.
        Parameters:
        parentSolutionNo - solution number of the parent for which we search matching solution.
        Returns:
        -1 if no solution was found, otherwise the index of the solution.
      • getParentSolution

        int getParentSolution​(int childSolutionNo)
      • setChildrenListeners

        void setChildrenListeners​(SolutionListener<T>[] children)
        It sets the children listeners for this solution listener.
        Parameters:
        children - an array containing children listeners.
      • setChildrenListeners

        void setChildrenListeners​(SolutionListener<T> child)
        It sets the child listener for this solution listener.
        Parameters:
        child - the child listener.
      • isRecordingSolutions

        boolean isRecordingSolutions()
        It specifies if the solution listener is recording solutions or not.
        Returns:
        true if all solutions are recorded, false if only the last one is recorded.
      • solutionLimitReached

        boolean solutionLimitReached()
        It checks if the sufficient number of solutions was found.
        Returns:
        true if the limit of found solutions has been reached.
      • setSolutionLimit

        void setSolutionLimit​(int limit)
        It sets the solution limit.
        Parameters:
        limit - the maximal number of solutions we are interested in.
      • printAllSolutions

        void printAllSolutions()
        It prints all the solutions.