master > master: code py - enum option zum Anzeigen aller Summen
This commit is contained in:
parent
22fe6c6d4a
commit
22801148a6
@ -32,3 +32,4 @@ options:
|
|||||||
verbose: true
|
verbose: true
|
||||||
show:
|
show:
|
||||||
- ALL-WEIGHTS
|
- ALL-WEIGHTS
|
||||||
|
- ALL-SUMS
|
||||||
|
@ -166,3 +166,4 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- ALL-WEIGHTS
|
- ALL-WEIGHTS
|
||||||
|
- ALL-SUMS
|
||||||
|
@ -98,16 +98,19 @@ def display_rucksack(
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
def display_branch_and_bound(values: np.ndarray, steps: List[Step]) -> str:
|
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 = [];
|
rows = [];
|
||||||
used_choices = [];
|
used_choices = [];
|
||||||
index_soln = max([-1] + [ i for i, step in enumerate(steps) if step.move == EnumBranchAndBoundMove.BOUND ]);
|
index_soln = max([-1] + [ i for i, step in enumerate(steps) if step.move == EnumBranchAndBoundMove.BOUND ]);
|
||||||
for i, step in enumerate(steps):
|
for i, step in enumerate(steps):
|
||||||
if step.choice in used_choices:
|
if show_all_sums or step.choice not in used_choices:
|
||||||
expr = f'{step.bound_subtree:g}';
|
# Füge Summen-Ausdrücke für Greedy-Alg hinzu:
|
||||||
else:
|
|
||||||
used_choices.append(step.choice);
|
used_choices.append(step.choice);
|
||||||
expr = display_sum(choice=step.choice, values=values, as_maximum=False, order=step.order, indexes=step.indexes);
|
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);
|
pad_str = ('' if step.pad == MaskValue.UNSET else step.pad.value);
|
||||||
move_str = ('' if step.move == EnumBranchAndBoundMove.NONE else step.move.value);
|
move_str = ('' if step.move == EnumBranchAndBoundMove.NONE else step.move.value);
|
||||||
if i == index_soln:
|
if i == index_soln:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user