komentarze
This commit is contained in:
parent
6ab8c4af87
commit
bfe9b967b1
4
main.py
4
main.py
@ -37,13 +37,13 @@ def knapsack(dostepne, cap, mode):
|
|||||||
plecak = items
|
plecak = items
|
||||||
return
|
return
|
||||||
|
|
||||||
if mode in [1, 2] and waga >= cap: # alfa cięcie
|
if mode in [1, 2] and waga >= cap: # alfa cięcie part 1
|
||||||
return
|
return
|
||||||
|
|
||||||
if mode in [2] and max_val >= val + ograniczenie(dostepne[i:], cap-waga): # beta cięcie
|
if mode in [2] and max_val >= val + ograniczenie(dostepne[i:], cap-waga): # beta cięcie
|
||||||
return
|
return
|
||||||
|
|
||||||
if waga + dostepne[i].waga <= cap:
|
if waga + dostepne[i].waga <= cap: # alfa cięcie part 2
|
||||||
temp = items[:]
|
temp = items[:]
|
||||||
temp.append(dostepne[i])
|
temp.append(dostepne[i])
|
||||||
rekurencja(i+1, waga + dostepne[i].waga, val + dostepne[i].wartosc, temp)
|
rekurencja(i+1, waga + dostepne[i].waga, val + dostepne[i].wartosc, temp)
|
||||||
|
Loading…
Reference in New Issue
Block a user