diff --git a/code/python/assets/commands.yaml b/code/python/assets/commands.yaml index 4219a18..d5c3bf9 100644 --- a/code/python/assets/commands.yaml +++ b/code/python/assets/commands.yaml @@ -7,11 +7,11 @@ [2, 7, 4, 0], ] optimise: MIN -# Beispiele für Seminarwoche 10 (Blatt 9) +## Beispiele für Seminarwoche 10 (Blatt 9) - name: HIRSCHBERG word1: 'happily ever after' word2: 'apples' - once: false + once: true - name: HIRSCHBERG word1: 'happily' word2: 'applses' diff --git a/code/python/assets/config.yaml b/code/python/assets/config.yaml index d0d18b9..4c89437 100644 --- a/code/python/assets/config.yaml +++ b/code/python/assets/config.yaml @@ -14,6 +14,6 @@ options: verbose: - COSTS - MOVES - # show: - # # - ATOMS - # - TREE + show: + # - ATOMS + - TREE diff --git a/code/python/main.py b/code/python/main.py index 4d85160..27e43dd 100644 --- a/code/python/main.py +++ b/code/python/main.py @@ -7,7 +7,6 @@ import os; import sys -from token import MINUS; os.chdir(os.path.join(os.path.dirname(__file__))); sys.path.insert(0, os.getcwd()); @@ -17,10 +16,10 @@ from src.thirdparty.maths import *; from models.generated.commands import *; from src.core.log import *; from src.setup.config import *; -from src.graphs.graph import *; -from src.graphs.tarjan import *; -from src.tsp import *; -from src.hirschberg import *; +from src.models.graphs.graph import *; +from src.algorithms.tarjan.algorithms import *; +from src.algorithms.tsp import *; +from src.algorithms.hirschberg import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # GLOBAL CONSTANTS/VARIABLES diff --git a/code/python/src/graphs/__init__.py b/code/python/src/algorithms/__init__.py similarity index 100% rename from code/python/src/graphs/__init__.py rename to code/python/src/algorithms/__init__.py diff --git a/code/python/src/hirschberg/__init__.py b/code/python/src/algorithms/hirschberg/__init__.py similarity index 77% rename from code/python/src/hirschberg/__init__.py rename to code/python/src/algorithms/hirschberg/__init__.py index 8547acc..65f215b 100644 --- a/code/python/src/hirschberg/__init__.py +++ b/code/python/src/algorithms/hirschberg/__init__.py @@ -5,9 +5,9 @@ # IMPORTS # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -from src.hirschberg.algorithms import *; -from src.hirschberg.constants import *; -from src.hirschberg.display import *; +from src.algorithms.hirschberg.algorithms import *; +from src.models.hirschberg.penalties import *; +from src.algorithms.hirschberg.display import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXPORTS diff --git a/code/python/src/hirschberg/algorithms.py b/code/python/src/algorithms/hirschberg/algorithms.py similarity index 96% rename from code/python/src/hirschberg/algorithms.py rename to code/python/src/algorithms/hirschberg/algorithms.py index ab6103d..f347198 100644 --- a/code/python/src/hirschberg/algorithms.py +++ b/code/python/src/algorithms/hirschberg/algorithms.py @@ -9,11 +9,11 @@ from src.thirdparty.types import *; from src.thirdparty.maths import *; from models.generated.config import *; -from src.hirschberg.constants import *; -from src.hirschberg.display import *; -from src.hirschberg.matrix import *; -from src.hirschberg.paths import *; -from src.hirschberg.types import *; +from src.models.hirschberg.penalties import *; +from src.algorithms.hirschberg.display import *; +from src.algorithms.hirschberg.matrix import *; +from src.algorithms.hirschberg.paths import *; +from src.models.hirschberg.alignment import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXPORTS diff --git a/code/python/src/hirschberg/display.py b/code/python/src/algorithms/hirschberg/display.py similarity index 98% rename from code/python/src/hirschberg/display.py rename to code/python/src/algorithms/hirschberg/display.py index c9c7c88..4bcd6c6 100644 --- a/code/python/src/hirschberg/display.py +++ b/code/python/src/algorithms/hirschberg/display.py @@ -9,7 +9,7 @@ from src.thirdparty.types import *; from src.thirdparty.maths import *; from models.generated.config import *; -from src.hirschberg.constants import *; +from src.models.hirschberg.penalties import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXPORTS diff --git a/code/python/src/hirschberg/matrix.py b/code/python/src/algorithms/hirschberg/matrix.py similarity index 99% rename from code/python/src/hirschberg/matrix.py rename to code/python/src/algorithms/hirschberg/matrix.py index 7252414..21ac93f 100644 --- a/code/python/src/hirschberg/matrix.py +++ b/code/python/src/algorithms/hirschberg/matrix.py @@ -8,7 +8,7 @@ from src.thirdparty.types import *; from src.thirdparty.maths import *; -from src.hirschberg.constants import *; +from src.models.hirschberg import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXPORTS diff --git a/code/python/src/hirschberg/paths.py b/code/python/src/algorithms/hirschberg/paths.py similarity index 99% rename from code/python/src/hirschberg/paths.py rename to code/python/src/algorithms/hirschberg/paths.py index cf815f3..9071d11 100644 --- a/code/python/src/hirschberg/paths.py +++ b/code/python/src/algorithms/hirschberg/paths.py @@ -8,7 +8,7 @@ from src.thirdparty.types import *; from src.thirdparty.maths import *; -from src.hirschberg.constants import *; +from src.models.hirschberg import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXPORTS diff --git a/code/python/src/algorithms/tarjan/__init__.py b/code/python/src/algorithms/tarjan/__init__.py new file mode 100644 index 0000000..a336a86 --- /dev/null +++ b/code/python/src/algorithms/tarjan/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# IMPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +from src.algorithms.tarjan.algorithms import *; + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# EXPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +__all__ = [ + 'tarjan_algorithm', +]; diff --git a/code/python/src/graphs/tarjan.py b/code/python/src/algorithms/tarjan/algorithms.py similarity index 98% rename from code/python/src/graphs/tarjan.py rename to code/python/src/algorithms/tarjan/algorithms.py index 3b37f04..ebdbe92 100644 --- a/code/python/src/graphs/tarjan.py +++ b/code/python/src/algorithms/tarjan/algorithms.py @@ -10,8 +10,8 @@ from __future__ import annotations; from src.thirdparty.types import *; from src.core.log import *; -from src.stacks.stack import *; -from src.graphs.graph import *; +from src.models.stacks import *; +from src.models.graphs import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXPORTS diff --git a/code/python/src/tsp/__init__.py b/code/python/src/algorithms/tsp/__init__.py similarity index 91% rename from code/python/src/tsp/__init__.py rename to code/python/src/algorithms/tsp/__init__.py index 6837097..1d2122b 100644 --- a/code/python/src/tsp/__init__.py +++ b/code/python/src/algorithms/tsp/__init__.py @@ -5,7 +5,7 @@ # IMPORTS # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -from src.tsp.algorithms import *; +from src.algorithms.tsp.algorithms import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXPORTS diff --git a/code/python/src/tsp/algorithms.py b/code/python/src/algorithms/tsp/algorithms.py similarity index 100% rename from code/python/src/tsp/algorithms.py rename to code/python/src/algorithms/tsp/algorithms.py diff --git a/code/python/src/stacks/__init__.py b/code/python/src/models/__init__.py similarity index 100% rename from code/python/src/stacks/__init__.py rename to code/python/src/models/__init__.py diff --git a/code/python/src/models/graphs/__init__.py b/code/python/src/models/graphs/__init__.py new file mode 100644 index 0000000..0abfaa8 --- /dev/null +++ b/code/python/src/models/graphs/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# IMPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +from src.models.graphs.graph import *; + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# EXPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +__all__ = [ + 'Graph', +]; diff --git a/code/python/src/graphs/graph.py b/code/python/src/models/graphs/graph.py similarity index 100% rename from code/python/src/graphs/graph.py rename to code/python/src/models/graphs/graph.py diff --git a/code/python/src/models/hirschberg/__init__.py b/code/python/src/models/hirschberg/__init__.py new file mode 100644 index 0000000..a4443da --- /dev/null +++ b/code/python/src/models/hirschberg/__init__.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# IMPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +from src.models.hirschberg.alignment import *; +from src.models.hirschberg.paths import *; +from src.models.hirschberg.penalties import *; + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# EXPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +__all__ = [ + 'Alignment', + 'AlignmentBasic', + 'AlignmentPair', + 'Directions', + 'gap_penalty', + 'missmatch_penalty', +]; diff --git a/code/python/src/hirschberg/types.py b/code/python/src/models/hirschberg/alignment.py similarity index 100% rename from code/python/src/hirschberg/types.py rename to code/python/src/models/hirschberg/alignment.py diff --git a/code/python/src/models/hirschberg/paths.py b/code/python/src/models/hirschberg/paths.py new file mode 100644 index 0000000..35a1af6 --- /dev/null +++ b/code/python/src/models/hirschberg/paths.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# IMPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +from src.thirdparty.types import *; +from src.setup.config import *; + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# EXPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +__all__ = [ + 'Directions', +]; + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ENUMS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class Directions(Enum): + UNSET = -1; + # Prioritäten hier setzen + DIAGONAL = 0; + HORIZONTAL = 1; + VERTICAL = 2; diff --git a/code/python/src/hirschberg/constants.py b/code/python/src/models/hirschberg/penalties.py similarity index 73% rename from code/python/src/hirschberg/constants.py rename to code/python/src/models/hirschberg/penalties.py index d9be9c3..4013b4c 100644 --- a/code/python/src/hirschberg/constants.py +++ b/code/python/src/models/hirschberg/penalties.py @@ -13,22 +13,10 @@ from src.setup.config import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __all__ = [ - 'Directions', 'gap_penalty', 'missmatch_penalty', ]; -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# ENUMS -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -class Directions(Enum): - UNSET = -1; - # Prioritäten hier setzen - DIAGONAL = 0; - HORIZONTAL = 1; - VERTICAL = 2; - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # PENALTIES # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/code/python/src/models/stacks/__init__.py b/code/python/src/models/stacks/__init__.py new file mode 100644 index 0000000..4954a1e --- /dev/null +++ b/code/python/src/models/stacks/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# IMPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +from src.models.stacks.stack import *; + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# EXPORTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +__all__ = [ + 'Stack', +]; diff --git a/code/python/src/stacks/stack.py b/code/python/src/models/stacks/stack.py similarity index 100% rename from code/python/src/stacks/stack.py rename to code/python/src/models/stacks/stack.py diff --git a/code/python/tests/tests_graphs/test_graph.py b/code/python/tests/tests_graphs/test_graph.py index bff35c2..701f35f 100644 --- a/code/python/tests/tests_graphs/test_graph.py +++ b/code/python/tests/tests_graphs/test_graph.py @@ -11,7 +11,7 @@ from pytest import mark; from pytest import fixture; from unittest import TestCase; -from src.graphs.graph import *; +from src.models.graphs import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # FIXTURES diff --git a/code/python/tests/tests_graphs/test_tarjan.py b/code/python/tests/tests_graphs/test_tarjan.py index f00136f..d743f2a 100644 --- a/code/python/tests/tests_graphs/test_tarjan.py +++ b/code/python/tests/tests_graphs/test_tarjan.py @@ -13,8 +13,8 @@ from unittest import TestCase; from unittest.mock import patch; from src.thirdparty.types import *; -from src.graphs.graph import *; -from src.graphs.tarjan import *; +from src.models.graphs import *; +from src.algorithms.tarjan import *; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # FIXTURES diff --git a/code/python/tests/tests_stacks/test_stack.py b/code/python/tests/tests_stacks/test_stack.py index e8f2514..5370855 100644 --- a/code/python/tests/tests_stacks/test_stack.py +++ b/code/python/tests/tests_stacks/test_stack.py @@ -10,7 +10,7 @@ import pytest; from pytest import mark; from unittest import TestCase; -from src.stacks.stack import Stack; +from src.models.stacks import Stack; # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Fixtures