From 0145f1f873744ac1ac523f0a3abe6a4345ad2ff5 Mon Sep 17 00:00:00 2001 From: raj_mathe Date: Fri, 10 Jun 2022 12:40:55 +0200 Subject: [PATCH] =?UTF-8?q?master=20>=20master:=20code=20py=20-=20config?= =?UTF-8?q?=20optionen=20f=C3=BCr=20richtungsprios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/python/assets/commands.yaml | 2 +- code/python/assets/config.yaml | 8 +++++++- code/python/models/config-schema.yaml | 17 ++++++++++++++++- code/python/src/models/hirschberg/paths.py | 6 +++--- code/python/src/models/hirschberg/penalties.py | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/code/python/assets/commands.yaml b/code/python/assets/commands.yaml index d5c3bf9..7da31fa 100644 --- a/code/python/assets/commands.yaml +++ b/code/python/assets/commands.yaml @@ -7,7 +7,7 @@ [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' diff --git a/code/python/assets/config.yaml b/code/python/assets/config.yaml index 4c89437..0a3b044 100644 --- a/code/python/assets/config.yaml +++ b/code/python/assets/config.yaml @@ -9,8 +9,14 @@ options: tsp: verbose: true hirschberg: - penality-missmatch: 1 + # standardwerte sind (1, 1) und (2, 1): penality-gap: 1 + penality-mismatch: 1 + # niedrigerer Wert ==> höhere Priorität: + move-priorities: + diagonal: 0 + horizontal: 1 + vertical: 2 verbose: - COSTS - MOVES diff --git a/code/python/models/config-schema.yaml b/code/python/models/config-schema.yaml index 85248ed..5a563da 100644 --- a/code/python/models/config-schema.yaml +++ b/code/python/models/config-schema.yaml @@ -57,12 +57,27 @@ components: hirschberg: type: object properties: - penality-missmatch: + penality-mismatch: type: number default: 1 penality-gap: type: number default: 1 + move-priorities: + type: object + properties: + diagonal: + type: integer + minimum: 0 + default: 0 + horizontal: + type: integer + minimum: 0 + default: 1 + vertical: + type: integer + minimum: 0 + default: 2 verbose: type: array items: diff --git a/code/python/src/models/hirschberg/paths.py b/code/python/src/models/hirschberg/paths.py index 35a1af6..234751f 100644 --- a/code/python/src/models/hirschberg/paths.py +++ b/code/python/src/models/hirschberg/paths.py @@ -23,6 +23,6 @@ __all__ = [ class Directions(Enum): UNSET = -1; # Prioritäten hier setzen - DIAGONAL = 0; - HORIZONTAL = 1; - VERTICAL = 2; + DIAGONAL = OPTIONS.hirschberg.move_priorities.diagonal; + HORIZONTAL = OPTIONS.hirschberg.move_priorities.horizontal; + VERTICAL = OPTIONS.hirschberg.move_priorities.vertical; diff --git a/code/python/src/models/hirschberg/penalties.py b/code/python/src/models/hirschberg/penalties.py index 4013b4c..a00a7e6 100644 --- a/code/python/src/models/hirschberg/penalties.py +++ b/code/python/src/models/hirschberg/penalties.py @@ -25,4 +25,4 @@ def gap_penalty(x: str): return OPTIONS.hirschberg.penality_gap; def missmatch_penalty(x: str, y: str): - return 0 if x == y else OPTIONS.hirschberg.penality_missmatch; + return 0 if x == y else OPTIONS.hirschberg.penality_mismatch;