|
|
|
@ -111,14 +111,16 @@ def display_branch_and_bound(values: np.ndarray, steps: List[Step]) -> str:
|
|
|
|
|
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}'; |
|
|
|
|
expr = ''; |
|
|
|
|
bound_str = f'{step.bound:+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: |
|
|
|
|
move_str = f'{move_str} *'; |
|
|
|
|
bound_str = f'* \x1b[92;1m{bound_str}\x1b[0m'; |
|
|
|
|
rows.append({ |
|
|
|
|
'bound': f'{step.bound:+g}', |
|
|
|
|
'bound_subtree': expr, |
|
|
|
|
'bound': f'{bound_str}', |
|
|
|
|
'bound_subtree': f'{step.bound_subtree:g}', |
|
|
|
|
'bound_subtree_sum': expr, |
|
|
|
|
'stack': step.stack_str, |
|
|
|
|
'pad': f'\x1b[2m{pad_str}\x1b[0m', |
|
|
|
|
'move': f'\x1b[2m{move_str}\x1b[0m', |
|
|
|
@ -128,10 +130,10 @@ def display_branch_and_bound(values: np.ndarray, steps: List[Step]) -> str:
|
|
|
|
|
# benutze pandas-Dataframe + tabulate, um schöner darzustellen: |
|
|
|
|
repr = tabulate( |
|
|
|
|
table, |
|
|
|
|
headers=['bound', 'g(TOP(S))', 'S — stack', '\x1b[2mpad?\x1b[0m', '\x1b[2mmove\x1b[0m'], |
|
|
|
|
headers=['bound', 'g(TOP(S))', '', 'S — stack', '\x1b[2mpad?\x1b[0m', '\x1b[2mmove\x1b[0m'], |
|
|
|
|
showindex=False, |
|
|
|
|
colalign=('left', 'left', 'right', 'center', 'left'), |
|
|
|
|
tablefmt='rst' |
|
|
|
|
colalign=('right', 'right', 'left', 'right', 'center', 'left'), |
|
|
|
|
tablefmt='simple' |
|
|
|
|
); |
|
|
|
|
return repr; |
|
|
|
|
|
|
|
|
@ -169,5 +171,5 @@ def display_sum(
|
|
|
|
|
expr = '\x1b[2m+\x1b[0m'.join(map(render, parts)); |
|
|
|
|
|
|
|
|
|
if as_maximum: |
|
|
|
|
return f'{value:g} \x1b[2m=\x1b[0m {expr}'; |
|
|
|
|
return f'-{value:g} \x1b[2m= -(\x1b[0m{expr}\x1b[2m)\x1b[0m'; |
|
|
|
|
return f'\x1b[2m=\x1b[0m {expr}'; |
|
|
|
|
return f'\x1b[2m= -(\x1b[0m{expr}\x1b[2m)\x1b[0m'; |
|
|
|
|