Class SimpleSolutionListener<T extends Var>

    • Field Detail

      • debug

        private static final boolean debug
        It specifies if the debugging information should be printed.
        See Also:
        Constant Field Values
      • vars

        public T extends Var[] vars
        It is executed right after consistency of the current search node. The return code specifies if the search should continue or exit.
      • alwaysUpdateToMostRecentSolution

        boolean alwaysUpdateToMostRecentSolution
      • solutionLimit

        public int solutionLimit
        It specifies the number of solutions we want to find.
      • noSolutions

        protected int noSolutions
      • recordSolutions

        boolean recordSolutions
      • solutions

        public Domain[][] solutions
      • parentSolutionListener

        public SolutionListener<? extends Var> parentSolutionListener
        If this search is a slave search than each solution within this search must be connected to a solution of the master search. The parentSolutionListener is a solution listener of the master search.
      • parentSolutionNo

        public int[] parentSolutionNo
        If this search is a slave search than each solution within this search must be connected to a solution of the master search. This array stores for each solution recorded by this solution listener the solution number of the master slave.
      • childrenSolutionListeners

        public SolutionListener<T extends Var>[] childrenSolutionListeners
        It contains children of the solution listener.
    • Constructor Detail

      • SimpleSolutionListener

        public SimpleSolutionListener()
    • Method Detail

      • getVariables

        public T[] getVariables()
        It returns null if no solution was recorded, or the variables for which the solution(s) was recorded.
        Specified by:
        getVariables in interface SolutionListener<T extends Var>
        Returns:
        list of variables
      • solutionLimitReached

        public boolean solutionLimitReached()
        Description copied from interface: SolutionListener
        It checks if the sufficient number of solutions was found.
        Specified by:
        solutionLimitReached in interface SolutionListener<T extends Var>
        Returns:
        true if the limit of found solutions has been reached.
      • setSolutionLimit

        public void setSolutionLimit​(int limit)
        Description copied from interface: SolutionListener
        It sets the solution limit.
        Specified by:
        setSolutionLimit in interface SolutionListener<T extends Var>
        Parameters:
        limit - the maximal number of solutions we are interested in.
      • setParentSolutionListener

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

        public Domain[][] getSolutions()
        Description copied from interface: SolutionListener
        It returns all solutions. Each solution is in a separate array.
        Specified by:
        getSolutions in interface SolutionListener<T extends Var>
        Returns:
        first dimension is indexed by solution, second dimension is indexed by a variable.
      • getSolution

        public Domain[] getSolution​(int no)
        It returns the solution number no. The first solution has an index 1.
        Specified by:
        getSolution in interface SolutionListener<T extends Var>
        Parameters:
        no - it obtains the solution with a given index.
        Returns:
        array containing assignments to search variables.
      • solutionsNo

        public int solutionsNo()
        It returns number of solutions found while using this choice point selector.
        Specified by:
        solutionsNo in interface SolutionListener<T extends Var>
        Returns:
        the number of solutions.
      • setSolutionsNo

        public void setSolutionsNo​(int no)
      • recordSolutions

        public void recordSolutions​(boolean status)
        It records all solutions so they can be later retrieved and used.
        Specified by:
        recordSolutions in interface SolutionListener<T extends Var>
        Parameters:
        status - true if we are interested in recording all solutions, false otherwise.
      • searchAll

        public void searchAll​(boolean status)
        It searches for all solutions, but they do not have to be recorded as this is decided by another parameter.
        Specified by:
        searchAll in interface SolutionListener<T extends Var>
        Parameters:
        status - true if we are interested in search for all solutions, false otherwise.
      • recordSolution

        public void recordSolution()
        It records a solution. It uses the current value of the search variables (they must be all grounded) as well as the current number of the solution in master search (if there is one).
      • executeAfterSolution

        public boolean executeAfterSolution​(Search<T> search,
                                            SelectChoicePoint<T> select)
        Description copied from interface: SolutionListener
        It is executed by search after a solution is found.
        Specified by:
        executeAfterSolution in interface SolutionListener<T extends Var>
        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

        public boolean assignSolution​(Store store)
        It assigns the last found solution to the store. If the function returns false that means that for some reason the solution which was supposed to be a solution is not. It can be caused by a number of issues, starting with wrongly implemented plugins, wrongly implemented consistency or satisfied function of the constraint.
        Parameters:
        store - the store in the context of which the search took place.
        Returns:
        true if the store is consistent after assigning a solution, false otherwise.
      • assignSolution

        public boolean assignSolution​(Store store,
                                      int number)
        Description copied from interface: SolutionListener
        It imposes the constraints, so the last found solution is enforced.
        Specified by:
        assignSolution in interface SolutionListener<T extends Var>
        Parameters:
        store - store in which the solution is enforced.
        number - the number of the solution to be enforced.
        Returns:
        true if the store is consistent after enforcing a solution, false otherwise.
      • setVariables

        public void setVariables​(T[] vs)
      • toString

        public java.lang.String toString()
        Description copied from interface: SolutionListener
        It returns the string representation of the last solution.
        Specified by:
        toString in interface SolutionListener<T extends Var>
        Overrides:
        toString in class java.lang.Object
      • returnSolution

        public PrimitiveConstraint[] returnSolution()
        Description copied from interface: SolutionListener
        It returns a collection of constraints which represent the last found solution.
        Specified by:
        returnSolution in interface SolutionListener<T extends Var>
        Returns:
        the set of constraints which imposed enforce the last found solution.
      • returnSolution

        public PrimitiveConstraint[] returnSolution​(int number)
        It returns the solution with the given number (value 0 denotes the first solution) as a set of primitive constraints.
        Parameters:
        number - the solution number (0 denotes the first solution).
        Returns:
        set of primitive constraint which if imposed will enforce given solution.
      • findSolutionMatchingParent

        public int findSolutionMatchingParent​(int parentNo)
        Description copied from interface: SolutionListener
        For a given master solution finds any solution within that listener which matches the master solution.
        Specified by:
        findSolutionMatchingParent in interface SolutionListener<T extends Var>
        Parameters:
        parentNo - solution number of the parent for which we search matching solution.
        Returns:
        -1 if no solution was found, otherwise the index of the solution.
      • isRecordingSolutions

        public boolean isRecordingSolutions()
        Description copied from interface: SolutionListener
        It specifies if the solution listener is recording solutions or not.
        Specified by:
        isRecordingSolutions in interface SolutionListener<T extends Var>
        Returns:
        true if all solutions are recorded, false if only the last one is recorded.