Enum KnapsackSolver.SolverType

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<KnapsackSolver.SolverType>
    Enclosing class:
    KnapsackSolver

    public static enum KnapsackSolver.SolverType
    extends java.lang.Enum<KnapsackSolver.SolverType>
    Enum controlling which underlying algorithm is used.

    This enum is passed to the constructor of the KnapsackSolver object.
    It selects which solving method will be used.
    • Enum Constant Detail

      • KNAPSACK_BRUTE_FORCE_SOLVER

        public static final KnapsackSolver.SolverType KNAPSACK_BRUTE_FORCE_SOLVER
        Brute force method.

        Limited to 30 items and one dimension, this
        solver uses a brute force algorithm, ie. explores all possible states.
        Experiments show competitive performance for instances with less than
        15 items.
      • KNAPSACK_64ITEMS_SOLVER

        public static final KnapsackSolver.SolverType KNAPSACK_64ITEMS_SOLVER
        Optimized method for single dimension small problems

        Limited to 64 items and one dimension, this
        solver uses a branch & bound algorithm. This solver is about 4 times
        faster than KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER.
      • KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER

        public static final KnapsackSolver.SolverType KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER
        Dynamic Programming approach for single dimension problems

        Limited to one dimension, this solver is based on a dynamic programming
        algorithm. The time and space complexity is O(capacity *
        number_of_items).
      • KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER

        public static final KnapsackSolver.SolverType KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER
        CBC Based Solver

        This solver can deal with both large number of items and several
        dimensions. This solver is based on Integer Programming solver CBC.
      • KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER

        public static final KnapsackSolver.SolverType KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER
        Generic Solver.

        This solver can deal with both large number of items and several
        dimensions. This solver is based on branch and bound.
      • KNAPSACK_DIVIDE_AND_CONQUER_SOLVER

        public static final KnapsackSolver.SolverType KNAPSACK_DIVIDE_AND_CONQUER_SOLVER
        Divide and Conquer approach for single dimension problems

        Limited to one dimension, this solver is based on a divide and conquer
        technique and is suitable for larger problems than Dynamic Programming
        Solver. The time complexity is O(capacity * number_of_items) and the
        space complexity is O(capacity + number_of_items).
    • Method Detail

      • values

        public static KnapsackSolver.SolverType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (KnapsackSolver.SolverType c : KnapsackSolver.SolverType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static KnapsackSolver.SolverType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • swigValue

        public final int swigValue()