Single-objective problems

Unconstrained

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

Bases: BinaryProblem

The OneMax problem is a simple optimization problem that counts the number of ones in a binary string.

The objective is to maximize the number of ones in the binary string, which is equivalent to minimizing the negative count of ones.

Args:

number_of_bits: The length of the binary string (default: 256)

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, profits: list = None, from_file: bool = False, filename: str = 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)[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]