tests.utils#

tests.utils.test_optimization#

class tests.utils.test_optimization.TravelingSalesmanProblem(cities, **kwargs)[source]#

Bases: ElementwiseProblem

A two-dimensional Traveling Salesman Problem (TSP).

Parameters:

cities (ndarray) – the cities with 2d coordinates provided by a numpy array where each city is represented by a tuple.

tests.utils.test_optimization.tsp_problem()[source]#

Initialize the Traveling Salesman Problem with a list of cities.

Return type:

TravelingSalesmanProblem

Returns:

the Traveling Salesman Problem object

tests.utils.test_optimization.test_pso(tsp_problem)[source]#

Check if the Discrete Particle Swarm Optimization finds the best route.

Parameters:

tsp_problem (TravelingSalesmanProblem) – the Traveling Salesman Problem object fixture

Return type:

None

Returns:

None