master > master: code py - models + config implementiert

This commit is contained in:
RD
2022-06-10 11:50:59 +02:00
parent 67f6caf2d5
commit 0523c68100
21 changed files with 538 additions and 94 deletions

View File

@@ -6,18 +6,23 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import os;
import sys;
import sys
from token import MINUS;
os.chdir(os.path.join(os.path.dirname(__file__), '..'));
os.chdir(os.path.join(os.path.dirname(__file__)));
sys.path.insert(0, os.getcwd());
from src.core.log import *;
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.travel.naive import *;
from src.tsp import *;
from src.hirschberg import *;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# GLOBAL CONSTANTS/VARIABLES
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -29,38 +34,21 @@ from src.hirschberg import *;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def enter():
# ## Beispiel für Seminarwoche 9 (Blatt 8):
# tsp_naive_algorithm(
# dist = np.asarray([
# [0, 7, 4, 3],
# [7, 0, 5, 6],
# [2, 5, 0, 5],
# [2, 7, 4, 0],
# ], dtype=float),
# optimise=min,
# verbose=True,
# );
## Beispiel für Seminarwoche 10 (Blatt 9):
hirschberg_algorithm(
# Y = 'ANSPANNEN',
# X = 'ANSTRENGEN',
# Y = 'AGAT',
# X = 'ACGAAG',
Y = 'apples',
X = 'happily ever after',
# Y = 'applses',
# X = 'happily ever, lol',
# Y = 'apple',
# X = 'happily',
# once = True,
# verb = VerboseMode.COSTS,
# verb = VerboseMode.MOVES,
verb = VerboseMode.COSTS_AND_MOVES,
show = [
# DisplayOptions.ATOMS,
DisplayOptions.TREE,
],
);
for command in COMMANDS:
if isinstance(command, CommandTsp):
tsp_algorithm(
dist = np.asarray(command.dist, dtype=float),
optimise = min if command.optimise == EnumTspOptimise.min else max,
verbose = command.verbose,
);
elif isinstance(command, CommandHirschberg):
hirschberg_algorithm(
X = command.word1,
Y = command.word2,
once = command.once,
verb = command.verbose,
show = command.show,
);
return;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~