|
|
|
@ -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: |
|
|
|
|