master > master: code-py - refactoring von config/models
- manche command-optionen wie verbosity nach config.yaml umgezogen.
This commit is contained in:
parent
0523c68100
commit
97295b71cd
@ -47,5 +47,8 @@ Man kann auch mit einem guten Editor/IDE die Tests einzeln ausführen.
|
|||||||
## Testfälle durch Config-Datei ##
|
## Testfälle durch Config-Datei ##
|
||||||
|
|
||||||
Statt den Code immer anfassen zu müssen, kann man Fälle für die verschiedenen Algorithmen
|
Statt den Code immer anfassen zu müssen, kann man Fälle für die verschiedenen Algorithmen
|
||||||
in der **[./assets/commands](assets/commands.yaml)** erfassen und (mittels `just run`)
|
in der **[./assets/commands.yaml](assets/commands.yaml)** erfassen und (mittels `just run`)
|
||||||
das Programm ausführen.
|
das Programm ausführen.
|
||||||
|
|
||||||
|
Weitere globale Einstellungen (z. B. über Verbosity, Penalty-Konstanten, usw.) kann man in
|
||||||
|
**[./assets/config.yaml](assets/config.yaml)** einstellen.
|
||||||
|
@ -6,28 +6,24 @@
|
|||||||
- [2, 5, 0, 5]
|
- [2, 5, 0, 5]
|
||||||
- [2, 7, 4, 0]
|
- [2, 7, 4, 0]
|
||||||
optimise: MIN
|
optimise: MIN
|
||||||
verbose: true
|
# Beispiele für Seminarwoche 10 (Blatt 9)
|
||||||
## Beispiele für Seminarwoche 10 (Blatt 9)
|
- name: HIRSCHBERG
|
||||||
- &command_hirschberg
|
|
||||||
name: HIRSCHBERG
|
|
||||||
once: true
|
|
||||||
verbose:
|
|
||||||
- COSTS
|
|
||||||
- MOVES
|
|
||||||
# show:
|
|
||||||
# # - ATOMS
|
|
||||||
# - TREE
|
|
||||||
word1: 'happily ever after'
|
word1: 'happily ever after'
|
||||||
word2: 'apples'
|
word2: 'apples'
|
||||||
- <<: *command_hirschberg
|
once: false
|
||||||
word1: 'ANSTRENGEN'
|
- name: HIRSCHBERG
|
||||||
word2: 'ANSPANNEN'
|
|
||||||
- <<: *command_hirschberg
|
|
||||||
word1: 'ACGAAG'
|
|
||||||
word2: 'AGAT'
|
|
||||||
- <<: *command_hirschberg
|
|
||||||
word1: 'happily ever, lol'
|
|
||||||
word2: 'apple'
|
|
||||||
- <<: *command_hirschberg
|
|
||||||
word1: 'happily'
|
word1: 'happily'
|
||||||
word2: 'applses'
|
word2: 'applses'
|
||||||
|
once: false
|
||||||
|
- name: HIRSCHBERG
|
||||||
|
word1: 'happily ever, lol'
|
||||||
|
word2: 'apple'
|
||||||
|
once: false
|
||||||
|
- name: HIRSCHBERG
|
||||||
|
word1: 'ACGAAG'
|
||||||
|
word2: 'AGAT'
|
||||||
|
once: false
|
||||||
|
- name: HIRSCHBERG
|
||||||
|
word1: 'ANSTRENGEN'
|
||||||
|
word2: 'ANSPANNEN'
|
||||||
|
once: false
|
||||||
|
@ -5,4 +5,15 @@ info:
|
|||||||
Ein Code-Projekt, das Algorithmen und Datenstrukturen aus dem Kurs
|
Ein Code-Projekt, das Algorithmen und Datenstrukturen aus dem Kurs
|
||||||
ADS2 an der Universität Leipzig (Sommersemester 2022)
|
ADS2 an der Universität Leipzig (Sommersemester 2022)
|
||||||
implementiert.
|
implementiert.
|
||||||
options: {}
|
options:
|
||||||
|
tsp:
|
||||||
|
verbose: true
|
||||||
|
hirschberg:
|
||||||
|
penality-missmatch: 1
|
||||||
|
penality-gap: 1
|
||||||
|
verbose:
|
||||||
|
- COSTS
|
||||||
|
- MOVES
|
||||||
|
# show:
|
||||||
|
# # - ATOMS
|
||||||
|
# - TREE
|
||||||
|
@ -22,7 +22,6 @@ from src.graphs.tarjan import *;
|
|||||||
from src.tsp import *;
|
from src.tsp import *;
|
||||||
from src.hirschberg import *;
|
from src.hirschberg import *;
|
||||||
|
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# GLOBAL CONSTANTS/VARIABLES
|
# GLOBAL CONSTANTS/VARIABLES
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -39,15 +38,15 @@ def enter():
|
|||||||
tsp_algorithm(
|
tsp_algorithm(
|
||||||
dist = np.asarray(command.dist, dtype=float),
|
dist = np.asarray(command.dist, dtype=float),
|
||||||
optimise = min if command.optimise == EnumTspOptimise.min else max,
|
optimise = min if command.optimise == EnumTspOptimise.min else max,
|
||||||
verbose = command.verbose,
|
verbose = OPTIONS.tsp.verbose,
|
||||||
);
|
);
|
||||||
elif isinstance(command, CommandHirschberg):
|
elif isinstance(command, CommandHirschberg):
|
||||||
hirschberg_algorithm(
|
hirschberg_algorithm(
|
||||||
X = command.word1,
|
X = command.word1,
|
||||||
Y = command.word2,
|
Y = command.word2,
|
||||||
once = command.once,
|
once = command.once,
|
||||||
verb = command.verbose,
|
verb = OPTIONS.hirschberg.verbose,
|
||||||
show = command.show,
|
show = OPTIONS.hirschberg.show,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -62,9 +62,6 @@ components:
|
|||||||
type: number
|
type: number
|
||||||
optimise:
|
optimise:
|
||||||
$ref: '#/components/schemas/EnumTSPOptimise'
|
$ref: '#/components/schemas/EnumTSPOptimise'
|
||||||
verbose:
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# Command - Algorithm: Hirschberg
|
# Command - Algorithm: Hirschberg
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -87,16 +84,6 @@ components:
|
|||||||
once:
|
once:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
verbose:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/EnumHirschbergVerbosity'
|
|
||||||
default: []
|
|
||||||
show:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/EnumHirschbergShow'
|
|
||||||
default: []
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# Enum Algorithm Names
|
# Enum Algorithm Names
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -118,23 +105,3 @@ components:
|
|||||||
enum:
|
enum:
|
||||||
- MIN
|
- MIN
|
||||||
- MAX
|
- MAX
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
# Enum Hirschberg - Verbosity options
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
EnumHirschbergVerbosity:
|
|
||||||
description: |-
|
|
||||||
Enumeration of verbosity options for Hirschberg
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- COSTS
|
|
||||||
- MOVES
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
# Enum Hirschberg - display options
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
EnumHirschbergShow:
|
|
||||||
description: |-
|
|
||||||
Enumeration of verbosity options for Hirschberg
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- TREE
|
|
||||||
- ATOMS
|
|
||||||
|
@ -47,3 +47,49 @@ components:
|
|||||||
description: |-
|
description: |-
|
||||||
Options pertaining to the rudimentary setup of the app.
|
Options pertaining to the rudimentary setup of the app.
|
||||||
type: object
|
type: object
|
||||||
|
properties:
|
||||||
|
tsp:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
verbose:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
hirschberg:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
penality-missmatch:
|
||||||
|
type: number
|
||||||
|
default: 1
|
||||||
|
penality-gap:
|
||||||
|
type: number
|
||||||
|
default: 1
|
||||||
|
verbose:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/EnumHirschbergVerbosity'
|
||||||
|
default: []
|
||||||
|
show:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/EnumHirschbergShow'
|
||||||
|
default: []
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# Enum Hirschberg - Verbosity options
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
EnumHirschbergVerbosity:
|
||||||
|
description: |-
|
||||||
|
Enumeration of verbosity options for Hirschberg
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- COSTS
|
||||||
|
- MOVES
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# Enum Hirschberg - display options
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
EnumHirschbergShow:
|
||||||
|
description: |-
|
||||||
|
Enumeration of verbosity options for Hirschberg
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- TREE
|
||||||
|
- ATOMS
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
from src.thirdparty.types import *;
|
from src.thirdparty.types import *;
|
||||||
from src.thirdparty.maths import *;
|
from src.thirdparty.maths import *;
|
||||||
|
|
||||||
from models.generated.commands import *;
|
from models.generated.config import *;
|
||||||
from src.hirschberg.constants import *;
|
from src.hirschberg.constants import *;
|
||||||
from src.hirschberg.display import *;
|
from src.hirschberg.display import *;
|
||||||
from src.hirschberg.matrix import *;
|
from src.hirschberg.matrix import *;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
from src.thirdparty.types import *;
|
from src.thirdparty.types import *;
|
||||||
|
from src.setup.config import *;
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# EXPORTS
|
# EXPORTS
|
||||||
@ -33,7 +34,7 @@ class Directions(Enum):
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
def gap_penalty(x: str):
|
def gap_penalty(x: str):
|
||||||
return 1;
|
return OPTIONS.hirschberg.penality_gap;
|
||||||
|
|
||||||
def missmatch_penalty(x: str, y: str):
|
def missmatch_penalty(x: str, y: str):
|
||||||
return 0 if x == y else 1;
|
return 0 if x == y else OPTIONS.hirschberg.penality_missmatch;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
from src.thirdparty.types import *;
|
from src.thirdparty.types import *;
|
||||||
from src.thirdparty.maths import *;
|
from src.thirdparty.maths import *;
|
||||||
|
|
||||||
from models.generated.commands import *;
|
from models.generated.config import *;
|
||||||
from src.hirschberg.constants import *;
|
from src.hirschberg.constants import *;
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Loading…
x
Reference in New Issue
Block a user