master > master: code py - verbesserte Darstellung + »korrekte« Behandlung von Reihenfolgen

- im Kurs wird die Permutation nur für Greedy-Berechnungen angewandt
- die Reihenfolge der Items in der Hauptberechnung bei B&B bleibt wie bei Angaben
This commit is contained in:
RD
2022-06-14 14:40:02 +02:00
parent e3c3bbec37
commit 3b8f80cff9
12 changed files with 169 additions and 147 deletions

View File

@@ -24,10 +24,10 @@ __all__ = [
@dataclass
class SolutionRaw():
vector: Union[List[int], List[float]] = field();
vector: List[float] = field();
items: List[str] = field();
values: List[float] = field(repr=False);
weights: List[float] = field(repr=False);
costs: List[float] = field(repr=False);
class Solution(SolutionRaw):
@property
@@ -40,7 +40,7 @@ class Solution(SolutionRaw):
@property
def total_weight(self) -> float:
return sum([ self.vector[i]*x for (i, x) in zip(self.support, self.weights) ]);
return sum([ self.vector[i]*x for (i, x) in zip(self.support, self.costs) ]);
@property
def total_value(self) -> float: