Compare commits

...

2 Commits

Author SHA1 Message Date
92f038d4dd master > master: code py - darstellung
- erzwinge `+`-Vorzeichen
- Spaltennamen ausführlicher (`b` -> `bound`)
- pad-Spalte ganz rechts, um als optional zu verdeutlichen
2022-06-14 20:10:54 +02:00
a9eb961eec master > master: code py - commands, bsp. aus VL 2022-06-14 20:02:38 +02:00
2 changed files with 19 additions and 5 deletions

View File

@@ -72,7 +72,7 @@
once: false
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Beispiele für Seminarwoche 11 (Blatt 10)
# Beispiele für Vorlesung + Seminarwoche 11 (VL + Blatt 10)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- &rucksack_1
@@ -89,6 +89,20 @@
allow-fractional: true
- <<: *rucksack_1
algorithm: BRANCH-AND-BOUND
- name: RUCKSACK
algorithm: BRANCH-AND-BOUND
max-cost: 460
items: [
'Lakritze',
'Esspapier',
'Gummibärchen',
'Schokolade',
'Apfelringe',
]
costs:
[220, 80, 140, 90, 100]
values:
[100, 10, 70, 80, 100]
- name: RUCKSACK
algorithm: BRANCH-AND-BOUND
max-cost: 90

View File

@@ -95,17 +95,17 @@ def display_branch_and_bound(
else:
used_choices.append(choice);
expr = display_sum(choice=choice, values=values, as_maximum=False, order=order);
rows.append((f'{lb_estimate:g}', expr, ('' if pad == MaskValue.UNSET else pad.value), S));
rows.append((f'{lb_estimate:+g}', expr, S, ('' if pad == MaskValue.UNSET else pad.value)));
table = pd.DataFrame(rows) \
.rename(columns={0: 'b', 1: 'g(TOP(S))', 2: 'pad?', 3: 'S'}) \
.rename(columns={0: 'bound', 1: 'g(TOP(S))', 2: 'S', 3: 'pad?'}) \
.reset_index(drop=True);
# benutze pandas-Dataframe + tabulate, um schöner darzustellen:
repr = tabulate(
table,
headers=['b', 'g(TOP(S))', 'pad?', 'S'],
headers=['bound', 'g(TOP(S))', 'S — stack', 'pad?'],
showindex=False,
colalign=('left', 'left', 'center', 'right'),
colalign=('left', 'left', 'right', 'center'),
tablefmt='rst'
);
return repr;