moptipyapps.tests package

Unit tests that you can use to check your moptipyapps based experiments.

Submodules

moptipyapps.tests.on_binpacking2d module

Perform tests on the Two-Dimensional Bin Packing Problem.

moptipyapps.tests.on_binpacking2d.binpacking_instances_for_tests(random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Get a sequence of 2D Bin Packing instances to test on.

Parameters:

random (Generator, default: Generator(PCG64) at 0x7F2E7BAE4740) – the random number generator to use

Return type:

Iterable[str]

Returns:

an iterable of 2D Bin Packing instance names

moptipyapps.tests.on_binpacking2d.make_packing_invalid(random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Make a function that creates invalid packings.

Parameters:

random (Generator, default: Generator(PCG64) at 0x7F2E7BAE4740) – the random number generator to use

Return type:

Callable[[Packing], Packing]

Returns:

a function that can make packings invalid

moptipyapps.tests.on_binpacking2d.make_packing_valid(inst, random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Make a function that creates valid packings.

Parameters:
  • inst (Instance) – the two-dimensional bin packing instance

  • random (Generator, default: Generator(PCG64) at 0x7F2E7BAE4740) – the random number generator to use

Return type:

Callable[[Generator, Packing], Packing]

Returns:

a function that can make packings valid

moptipyapps.tests.on_binpacking2d.validate_algorithm_on_1_2dbinpacking(algorithm, instance=None, max_fes=100, random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Check the validity of a black-box algorithm on the 2d bin packing.

Parameters:
Return type:

None

moptipyapps.tests.on_binpacking2d.validate_algorithm_on_2dbinpacking(algorithm, max_fes=100, random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Validate an algorithm on a set of bin packing instances.

Parameters:
Return type:

None

moptipyapps.tests.on_binpacking2d.validate_objective_on_1_2dbinpacking(objective, instance=None, random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Validate an objective function on 1 2D bin packing instance.

Parameters:
Return type:

None

moptipyapps.tests.on_binpacking2d.validate_objective_on_2dbinpacking(objective, random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Validate an objective function on bin packing instances.

Parameters:
Return type:

None

moptipyapps.tests.on_binpacking2d.validate_signed_permutation_encoding_on_1_2dbinpacking(encoding, instance=None, random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Validate a signed permutation encoding on one 2D bin packing instance.

Parameters:
Return type:

None

moptipyapps.tests.on_binpacking2d.validate_signed_permutation_encoding_on_2dbinpacking(encoding, random=Generator(PCG64) at 0x7F2E7BAE4740)[source]

Validate a signed permutation encoding function on bin packing instances.

Parameters:
Return type:

None

moptipyapps.tests.on_tsp module

Perform tests on the Traveling Salesperson Problem.

moptipyapps.tests.on_tsp.make_tour_invalid(random, y)[source]

Create invalid tours.

Parameters:
  • random (Generator) – the random number generator to use

  • y (ndarray) – the input tour

Return type:

ndarray

Returns:

the invalid version of y

moptipyapps.tests.on_tsp.make_tour_valid(random, y)[source]

Create valid TSP tours.

Parameters:
  • random (Generator) – the random number generator to use

  • y (ndarray) – the input tour

Return type:

ndarray

Returns:

the valid version of y

moptipyapps.tests.on_tsp.tsp_instances_for_tests(random=Generator(PCG64) at 0x7F2E7BAE5C40, symmetric=True, asymmetric=True)[source]

Get a sequence of TSP instances to test on.

Parameters:
  • random (Generator, default: Generator(PCG64) at 0x7F2E7BAE5C40) – the random number generator to use

  • symmetric (bool, default: True) – include symmetric instances

  • asymmetric (bool, default: True) – include asymmetric instances

Return type:

Iterable[str]

Returns:

an iterable of TSP instance names

moptipyapps.tests.on_tsp.validate_algorithm_on_1_tsp(algorithm, instance=None, max_fes=256, random=Generator(PCG64) at 0x7F2E7BAE5C40)[source]

Check the validity of a black-box algorithm on one TSP instance.

Parameters:
Return type:

None

moptipyapps.tests.on_tsp.validate_algorithm_on_tsp(algorithm, symmetric=True, asymmetric=True, max_fes=256, random=Generator(PCG64) at 0x7F2E7BAE5C40)[source]

Validate an algorithm on a set of TSP instances.

Parameters:
  • algorithm (Callable[[Instance, Permutations], Algorithm]) – the algorithm factory

  • symmetric (bool, default: True) – include symmetric instances

  • asymmetric (bool, default: True) – include asymmetric instances

  • max_fes (int, default: 256) – the maximum FEs

  • random (Generator, default: Generator(PCG64) at 0x7F2E7BAE5C40) – the random number generator

Return type:

None

moptipyapps.tests.on_tsp.validate_objective_on_1_tsp(objective, instance=None, random=Generator(PCG64) at 0x7F2E7BAE5C40)[source]

Validate an objective function on 1 TSP instance.

Parameters:
Return type:

None

moptipyapps.tests.on_tsp.validate_objective_on_tsp(objective, symmetric=True, asymmetric=True, random=Generator(PCG64) at 0x7F2E7BAE5C40)[source]

Validate an objective function on TSP instances.

Parameters:
  • objective (Union[Objective, Callable[[Instance], Objective]]) – the objective function or a factory creating it

  • symmetric (bool, default: True) – include symmetric instances

  • asymmetric (bool, default: True) – include asymmetric instances

  • random (Generator, default: Generator(PCG64) at 0x7F2E7BAE5C40) – the random number generator

Return type:

None