master > master: code py - enum option zum Anzeigen aller Summen

This commit is contained in:
RD 2022-06-15 10:07:37 +02:00
parent 22fe6c6d4a
commit 22801148a6
3 changed files with 9 additions and 4 deletions

View File

@ -32,3 +32,4 @@ options:
verbose: true
show:
- ALL-WEIGHTS
- ALL-SUMS

View File

@ -166,3 +166,4 @@ components:
type: string
enum:
- ALL-WEIGHTS
- ALL-SUMS

View File

@ -98,16 +98,19 @@ def display_rucksack(
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def display_branch_and_bound(values: np.ndarray, steps: List[Step]) -> str:
# füge Summen-Ausdrücke für Greedy-Alg hinzu:
show_options = config.OPTIONS.rucksack.show;
show_all_sums = (EnumRucksackShow.all_sums in show_options);
rows = [];
used_choices = [];
index_soln = max([-1] + [ i for i, step in enumerate(steps) if step.move == EnumBranchAndBoundMove.BOUND ]);
for i, step in enumerate(steps):
if step.choice in used_choices:
expr = f'{step.bound_subtree:g}';
else:
if show_all_sums or step.choice not in used_choices:
# Füge Summen-Ausdrücke für Greedy-Alg hinzu:
used_choices.append(step.choice);
expr = display_sum(choice=step.choice, values=values, as_maximum=False, order=step.order, indexes=step.indexes);
else:
expr = f'{step.bound_subtree:g}';
pad_str = ('' if step.pad == MaskValue.UNSET else step.pad.value);
move_str = ('' if step.move == EnumBranchAndBoundMove.NONE else step.move.value);
if i == index_soln: