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 ##
|
||||
|
||||
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.
|
||||
|
||||
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, 7, 4, 0]
|
||||
optimise: MIN
|
||||
verbose: true
|
||||
## Beispiele für Seminarwoche 10 (Blatt 9)
|
||||
- &command_hirschberg
|
||||
name: HIRSCHBERG
|
||||
once: true
|
||||
verbose:
|
||||
- COSTS
|
||||
- MOVES
|
||||
# show:
|
||||
# # - ATOMS
|
||||
# - TREE
|
||||
# Beispiele für Seminarwoche 10 (Blatt 9)
|
||||
- name: HIRSCHBERG
|
||||
word1: 'happily ever after'
|
||||
word2: 'apples'
|
||||
- <<: *command_hirschberg
|
||||
word1: 'ANSTRENGEN'
|
||||
word2: 'ANSPANNEN'
|
||||
- <<: *command_hirschberg
|
||||
word1: 'ACGAAG'
|
||||
word2: 'AGAT'
|
||||
- <<: *command_hirschberg
|
||||
word1: 'happily ever, lol'
|
||||
word2: 'apple'
|
||||
- <<: *command_hirschberg
|
||||
once: false
|
||||
- name: HIRSCHBERG
|
||||
word1: 'happily'
|
||||
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
|
||||
ADS2 an der Universität Leipzig (Sommersemester 2022)
|
||||
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.hirschberg import *;
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# GLOBAL CONSTANTS/VARIABLES
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -39,15 +38,15 @@ def enter():
|
||||
tsp_algorithm(
|
||||
dist = np.asarray(command.dist, dtype=float),
|
||||
optimise = min if command.optimise == EnumTspOptimise.min else max,
|
||||
verbose = command.verbose,
|
||||
verbose = OPTIONS.tsp.verbose,
|
||||
);
|
||||
elif isinstance(command, CommandHirschberg):
|
||||
hirschberg_algorithm(
|
||||
X = command.word1,
|
||||
Y = command.word2,
|
||||
once = command.once,
|
||||
verb = command.verbose,
|
||||
show = command.show,
|
||||
verb = OPTIONS.hirschberg.verbose,
|
||||
show = OPTIONS.hirschberg.show,
|
||||
);
|
||||
return;
|
||||
|
||||
|
@ -62,9 +62,6 @@ components:
|
||||
type: number
|
||||
optimise:
|
||||
$ref: '#/components/schemas/EnumTSPOptimise'
|
||||
verbose:
|
||||
type: boolean
|
||||
default: false
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Command - Algorithm: Hirschberg
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -87,16 +84,6 @@ components:
|
||||
once:
|
||||
type: boolean
|
||||
default: false
|
||||
verbose:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/EnumHirschbergVerbosity'
|
||||
default: []
|
||||
show:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/EnumHirschbergShow'
|
||||
default: []
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Enum Algorithm Names
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -118,23 +105,3 @@ components:
|
||||
enum:
|
||||
- MIN
|
||||
- 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: |-
|
||||
Options pertaining to the rudimentary setup of the app.
|
||||
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.maths import *;
|
||||
|
||||
from models.generated.commands import *;
|
||||
from models.generated.config import *;
|
||||
from src.hirschberg.constants import *;
|
||||
from src.hirschberg.display import *;
|
||||
from src.hirschberg.matrix import *;
|
||||
|
@ -6,6 +6,7 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
from src.thirdparty.types import *;
|
||||
from src.setup.config import *;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# EXPORTS
|
||||
@ -33,7 +34,7 @@ class Directions(Enum):
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def gap_penalty(x: str):
|
||||
return 1;
|
||||
return OPTIONS.hirschberg.penality_gap;
|
||||
|
||||
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.maths import *;
|
||||
|
||||
from models.generated.commands import *;
|
||||
from models.generated.config import *;
|
||||
from src.hirschberg.constants import *;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
Loading…
x
Reference in New Issue
Block a user