def test_score(in_dirpath=IN_DIRPATH, out_dirpath=OUT_DIRPATH, source='example'): in_filepath = os.path.join(in_dirpath, source + '.in') network = Network.load(in_filepath) print(network) out_filepath = os.path.join(out_dirpath, source + '.out') caching = Caching.load(out_filepath) print(caching.score(network))
def test_fill(in_dirpath=IN_DIRPATH, out_dirpath=OUT_DIRPATH, source='example'): in_filepath = os.path.join(in_dirpath, source + '.in') network = Network.load(in_filepath) out_filepath = os.path.join(out_dirpath, source + '.out') caching = CachingRandom(network.num_caches) caching.fill(network) print(repr(caching)) print('Random Caching - Score: {}'.format(caching.score(network)))
def test_method(in_dirpath=IN_DIRPATH, out_dirpath=OUT_DIRPATH, sources=SOURCES, caching_method=Caching): tot_score = 0 for source in sources: in_filepath = os.path.join(in_dirpath, source + '.in') network = Network.load(in_filepath) out_filepath = os.path.join(out_dirpath, source + '.out') caching = caching_method(network.num_caches) caching.fill(network) caching.save(out_filepath) score = caching.score(network) tot_score += score print('{} score: {}'.format(source, score)) print('\nTOTAL SCORE: {}\n'.format(tot_score))
def test_method(in_dirpath=IN_DIRPATH, out_dirpath=OUT_DIRPATH, source='example', fill_cls=Caching, *fill_args, **fill_kws): if not os.path.isdir(out_dirpath): os.makedirs(out_dirpath) in_filepath = os.path.join(in_dirpath, source + '.in') network = Network.load(in_filepath) out_filepath = os.path.join(out_dirpath, source + '.out') caching = fill_cls(network.num_caches) caching.fill(network, *fill_args, **fill_kws) caching.save(out_filepath) score = caching.score(network) print('{:20s} final score: {}'.format(source, score), flush=True) return score
def test_method_seq(in_dirpath=IN_DIRPATH, out_dirpath=OUT_DIRPATH, sources=SOURCES, fill_cls=Caching, *fill_args, **fill_kws): if not os.path.isdir(out_dirpath): os.makedirs(out_dirpath) tot_score = 0 for source in sources: in_filepath = os.path.join(in_dirpath, source + '.in') network = Network.load(in_filepath) out_filepath = os.path.join(out_dirpath, source + '.out') caching = fill_cls(network.num_caches) caching.fill(network, *fill_args, **fill_kws) caching.save(out_filepath) score = caching.score(network) tot_score += score print('{:40s} score: {}'.format(source, score)) print('\nTOTAL SCORE: {}\n'.format(tot_score))
def test_network_input(in_dirpath=IN_DIRPATH, sources=SOURCES): for source in sources: in_filepath = os.path.join(in_dirpath, source + '.in') network = Network.load(in_filepath) print(network)