Class CombinatoricsProblem

    • Constructor Detail

      • CombinatoricsProblem

        public CombinatoricsProblem​(java.util.List<ElementOfCombinatoricsProb> elements,
                                    int[][] graphRepresantation)
    • Method Detail

      • sumOfWeights

        public abstract double sumOfWeights​(java.util.ArrayList<ElementOfCombinatoricsProb> sol)
        Parameters:
        sol - is the solution to be viewd
        Returns:
        if the solution sol is valid under the constraints of the problem
      • getGraphrepresentation

        public int[][] getGraphrepresentation()
      • createRandomNewSolution

        public abstract java.util.ArrayList<ElementOfCombinatoricsProb> createRandomNewSolution​(java.util.ArrayList<ElementOfCombinatoricsProb> currSol)
        create a solution that changes the solution currSol a little bit (i.e.: for TSP: swap 2 cities; for KnapSack: add a random element) for currSol == null: create a random solution
        Parameters:
        currSol - the current solution
        Returns:
        the solution
      • evaluate

        public abstract double evaluate​(java.util.ArrayList<ElementOfCombinatoricsProb> sol)
        evaluates the solution
        Parameters:
        sol - some solution
        Returns:
        the target function for sol
      • isValid

        public abstract boolean isValid​(java.util.ArrayList<ElementOfCombinatoricsProb> sol)
        checks if a given solution is valid under all constraints
        Parameters:
        sol - some solution
        Returns:
        true iff the solution is valid
      • getHeuristicValue

        public abstract java.lang.Double getHeuristicValue​(ElementOfCombinatoricsProb solutionComponent,
                                                           java.lang.Integer getCurrentIndex,
                                                           ElementOfCombinatoricsProb initialReference,
                                                           ElementOfCombinatoricsProb[] sol)
        for Ant optimization: give a chance between 0 and 1 for accepting solutionComponent to the solution sol
        Parameters:
        solutionComponent - : Element to be checked *
        getCurrentIndex - : the length of the solution
        initialReference - : default starting point for the solution (the first Element in the solution)
        sol - : array representation of a solution (needed for Ant optimization)
        Returns:
        the heuristic value
      • getRepresentation

        public abstract double[][] getRepresentation()
        for Ant optimization: represent the problem as an adjacence matrix