diff options
author | Karel Kočí <cynerd@email.cz> | 2015-05-20 11:07:15 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-05-20 11:07:15 +0200 |
commit | 66596b96df5600a3f98565cf6a4a30997d55e06b (patch) | |
tree | bc09a3d42022d3d4ac6725001eab12950ef7b497 | |
parent | 882325accf37d7868e48ceee7cfe8d9c2447cff9 (diff) | |
download | linux-conf-perf-66596b96df5600a3f98565cf6a4a30997d55e06b.tar.gz linux-conf-perf-66596b96df5600a3f98565cf6a4a30997d55e06b.tar.bz2 linux-conf-perf-66596b96df5600a3f98565cf6a4a30997d55e06b.zip |
Add base reduction for evaluate
-rwxr-xr-x | scripts/evaluate.py | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/scripts/evaluate.py b/scripts/evaluate.py index 38a6cad..bf16166 100755 --- a/scripts/evaluate.py +++ b/scripts/evaluate.py @@ -8,12 +8,49 @@ from conf import conf from conf import sf import utils +def reduce_matrix_search_for_base_recurse(wset, columns, contains, ignore): + bases = [] + for x in range(0, len(columns)): + if x in contains or x in ignore: + continue + colide = False + for i in range(0, len(wset)): + if wset[i] == 1 and columns[x][i] == 1: + colide = True + break + if not colide: + newset = list(wset) + onecount = 0 + for i in range(0, len(newset)): + newset[i] = newset[i] | columns[x][i] + if (newset[i] == 1): + onecount += 1 + contains.add(x) + if onecount == len(newset): + bases.append(set(contains)) + else: + rbases = reduce_matrix_search_for_base_recurse(newset, columns, contains, ignore) + for rbase in rbases: + if not rbase in bases: + bases.append(rbase) + contains.remove(x) + return bases +0 +def reduce_matrix_search_for_base(columns): + bases = [] + ignore = [] + for i in range(0, len(columns)): + wset = list(columns[i]) + ignore.append(i) + bases.extend(reduce_matrix_search_for_base_recurse(wset, columns, {i}, ignore)) + return bases + def reduce_matrix_remove_symbol(A, symrow, indx): del symrow[indx] for i in range(0, len(A)): del A[i][indx] -def reduce_matrix(A, symrow): +def reduce_matrix(A, symrow, bases): # Remove fixed symbols i = len(A[0]) - 1 while i >= 0: @@ -41,6 +78,18 @@ def reduce_matrix(A, symrow): columns.append(column) i -= 1 + # Search for Bases + basesx = reduce_matrix_search_for_base(columns) + if bases: + for base in basesx: + bases[0].append(base) + + # Generate new Base + if not bases: + for x in range(0, len(A)): + A[x].append(1) + symrow.append(0) + def collect_data(): hashs = {} for fl in os.listdir(sf(conf.result_folder)): @@ -93,11 +142,8 @@ def evaluate(): # Reduce matrix A print('Simplify matrix...') - reduce_matrix(A, symrow) - - for x in range(0, len(A)): - A[x].append(1) - symrow.append(0) + bases = [] + reduce_matrix(A, symrow, [bases]) # Calculate value print('Figuring values...') @@ -110,6 +156,9 @@ def evaluate(): if symrow[i] == 0: print("Base", end=' ') else: + for base in bases: + if i in base: + print("Base", end=' ') for s in symrow[i]: print(utils.smap[s], end=' ') print("=", end=' ') |