Single-objective problems

Unconstrained

class jmetal.problem.singleobjective.unconstrained.OneMax(number_of_bits: int = 256)[source]

Bases: BinaryProblem

The implementation of the OneMax problems defines a single binary variable. This variable will contain the bit string representing the solutions.

create_solution() BinarySolution[source]

Creates a random_search solution to the problem.

Returns:

Solution.

evaluate(solution: BinarySolution) BinarySolution[source]

Evaluate a solution. For any new problem inheriting from Problem, this method should be replaced. Note that this framework ASSUMES minimization, thus solutions must be evaluated in consequence.

Returns:

Evaluated solution.

name() str[source]
number_of_constraints() int[source]
number_of_objectives() int[source]
number_of_variables() int[source]
class jmetal.problem.singleobjective.unconstrained.Rastrigin(number_of_variables: int = 10)[source]

Bases: FloatProblem

evaluate(solution: FloatSolution) FloatSolution[source]

Evaluate a solution. For any new problem inheriting from Problem, this method should be replaced. Note that this framework ASSUMES minimization, thus solutions must be evaluated in consequence.

Returns:

Evaluated solution.

name() str[source]
number_of_constraints() int[source]
number_of_objectives() int[source]
class jmetal.problem.singleobjective.unconstrained.Sphere(number_of_variables: int = 10)[source]

Bases: FloatProblem

evaluate(solution: FloatSolution) FloatSolution[source]

Evaluate a solution. For any new problem inheriting from Problem, this method should be replaced. Note that this framework ASSUMES minimization, thus solutions must be evaluated in consequence.

Returns:

Evaluated solution.

name() str[source]
number_of_constraints() int[source]
number_of_objectives() int[source]
class jmetal.problem.singleobjective.unconstrained.SubsetSum(C: int, W: list)[source]

Bases: BinaryProblem

create_solution() BinarySolution[source]

Creates a random_search solution to the problem.

Returns:

Solution.

evaluate(solution: BinarySolution) BinarySolution[source]

Evaluate a solution. For any new problem inheriting from Problem, this method should be replaced. Note that this framework ASSUMES minimization, thus solutions must be evaluated in consequence.

Returns:

Evaluated solution.

name() str[source]
number_of_constraints() int[source]
number_of_objectives() int[source]
number_of_variables() int[source]

Knapsack

class jmetal.problem.singleobjective.knapsack.Knapsack(number_of_items: int = 50, capacity: float = 1000, weights: list | None = None, profits: list | None = None, from_file: bool = False, filename: str | None = None)[source]

Bases: BinaryProblem

Class representing Knapsack Problem.

create_solution() BinarySolution[source]

Creates a random_search solution to the problem.

Returns:

Solution.

evaluate(solution: BinarySolution) BinarySolution[source]

Evaluate a solution. For any new problem inheriting from Problem, this method should be replaced. Note that this framework ASSUMES minimization, thus solutions must be evaluated in consequence.

Returns:

Evaluated solution.

name()[source]
number_of_constraints() int[source]
number_of_objectives() int[source]
number_of_variables() int[source]

TSP

class jmetal.problem.singleobjective.tsp.TSP(instance: str | None = None)[source]

Bases: PermutationProblem

Class representing TSP Problem.

create_solution() PermutationSolution[source]

Creates a random_search solution to the problem.

Returns:

Solution.

evaluate(solution: PermutationSolution) PermutationSolution[source]

Evaluate a solution. For any new problem inheriting from Problem, this method should be replaced. Note that this framework ASSUMES minimization, thus solutions must be evaluated in consequence.

Returns:

Evaluated solution.

name()[source]
number_of_constraints() int[source]
number_of_objectives() int[source]
number_of_variables() int[source]