Coverage for moptipyapps / __init__.py: 71%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-11 04:40 +0000

1""" 

2Applications of Metaheuristic Optimization in Python. 

3 

4Currently, the following applications are implemented: 

5 

6- :mod:`~moptipyapps.binpacking2d` provides methods to solve two-dimensional 

7 bin packing instances, 

8- mod:`~moptipyapps.qap` offers instances of the well-known Quadratic 

9 Assignment Problem (QAP) and some very basic algorithms to tackle it, 

10- mod:`~moptipyapps.tsp` offers instances of the well-known Traveling 

11 Salesperson Problem (TSP) and some very basic algorithms to tackle it, 

12- mod:`~moptipyapps.ttp` offers instances of the Traveling Tournament Problem 

13 (TTP),. 

14 

15The following additional tools are implemented: 

16 

17- :mod:`~moptipyapps.tests` offers unit tests to try out optimization 

18 algorithms and other instances of :mod:`~moptipy.api.component` on the 

19 different problems that are provided above. 

20- :mod:`~moptipyapps.utils.shared` offers shared constants and tools. 

21""" 

22 

23# During some local pip installs, the other already installed packages may not 

24# be accessible. This may cause 

25# `from moptipy.utils.sys_info import add_dependency` to fail during 

26# `pip3 --no-input --timeout 360 --retries 100 -v install .`. 

27# The reason is not clear to me. 

28# To prevent this issue, we now try to load the `moptipy` module and catch the 

29# corresponding `ModuleNotFoundError` exception. Only if the module is loaded 

30# correctly, we add `moptipyapps` to the dependencies. 

31# Of course, this ignores the situation where there would really be an error. 

32# But that is OK, because in that case we will crash later anyway. 

33 

34can_do: bool = True 

35try: 

36 from moptipy.utils.sys_info import add_dependency 

37except ModuleNotFoundError: 

38 can_do = False 

39 

40if can_do: 

41 add_dependency("moptipyapps", ignore_if_make_build=True)