def main(args, curr_dir): np.set_printoptions(precision=5, threshold=np.inf) logger.set_up_pyrklog(args.logfile) infile = importlib.import_module(args.infile) si = sim_info.SimInfo(timer=infile.ti, components=infile.components, iso=infile.fission_iso, e=infile.spectrum, n_precursors=infile.n_pg, n_decay=infile.n_dg, kappa=infile.kappa, feedback=infile.feedback, rho_ext=infile.rho_ext, plotdir=args.plotdir) print_logo(curr_dir) # n_components = len(si.components) sol = solve(si=si, y=si.y, infile=infile) log_results(si) plotter.plot(sol, si) pyrklog.critical("\nSimulation succeeded.\n")
def plot_layer_output(self,plot_spec,plot_path,max_images=10): #default all nodes set to value 1 #inp = numpy.random.random(self.conv_input_dim).astype(theano.config.floatX); batch_size = plot_spec['batch_size']; plot_path = plot_path +os.sep +'layer_%d'+os.sep +'batch_%d'+os.sep+'img_%d.png' for layer_idx in xrange(self.conv_layer_num): img_plot_remaining = max_images; layer_out_fn = self.getLayerOutFunction(layer_idx); logger.info('Plotting the layer %d'%layer_idx); file_reader =read_dataset(plot_spec,pad_zeros=True)[0]; while not file_reader.is_finish(): for batch_index in xrange(file_reader.cur_frame_num/batch_size): s_idx = batch_index * batch_size; e_idx = s_idx + batch_size data = layer_out_fn(file_reader.feat[s_idx:e_idx]) e_idx= min(file_reader.cur_frame_num - file_reader.num_pad_frames,s_idx+batch_size); img_plot_remaining = plot(data[s_idx:e_idx],plot_path,layer_idx,batch_index,img_plot_remaining); if img_plot_remaining == 0: break; if img_plot_remaining == 0: break; file_reader.read_next_partition_data(pad_zeros=True);
from timeit import timeit from utils.line import Line from utils.sorter import radixSort # Little test to check if algorithm is working #intList = getRandomRepeatingListWithRange(15, 100) #print(f"Initial: {intList}") #radixSort(intList) #print(f"Final: {intList}") # Change this value to switch from and to test mode testMode = False testDivisor = 100 counts = [10000, 20000, 40000, 70000, 100000, 500000] if testMode: counts = [int(n / testDivisor) for n in counts] numberOfTests = 1 randomLists = [getRandomList(count) for count in counts] elapsedTimes = [ timeit(lambda: radixSort(list), number=numberOfTests) for list in randomLists ] lines = [Line((counts, elapsedTimes), "Caso aleatório", 'b')] plot(lines, figname="products/radix_sort_graph.png")
from utils.plotter import plot from utils.generator import getRandomList from timeit import timeit from utils.line import Line from utils.sorter import countingSort # Little test to check if algorithm is working #list = getRandomList(25) #print(list) #countingSort(list) #print(list) # Change this value to switch from and to test mode testMode = False testDivisor = 100 counts = [10000, 20000, 40000, 70000, 100000, 500000] if testMode: counts = [int(n / testDivisor) for n in counts] randomLists = [getRandomList(count) for count in counts] elapsedTimes = [ timeit(lambda: countingSort(list), number=1) for list in randomLists ] lines = [Line((counts, elapsedTimes), "Caso aleatório", 'b')] plot(lines, figname="products/counting_sort_graph.png")
from utils.plotter import plot from utils.generator import getRandomList, getDecrescentList from timeit import timeit from utils.line import Line from utils.sorter import insertionSort counts = [1000, 2000, 3000, 4000, 5000, 8000, 11000, 15000] randomLists = [getRandomList(count) for count in counts] worstLists = [getDecrescentList(count) for count in counts] elapsedTimes = [timeit(lambda: insertionSort(list), number = 1) for list in randomLists] worstElapsedTimes = [timeit(lambda: insertionSort(list), number = 1) for list in worstLists] lines = [Line((counts, elapsedTimes), "Caso aleatório", 'b'), Line((counts, worstElapsedTimes), "Pior caso", 'k')] plot(lines, figname = "products/insertion_sort_graph.png")
counts = [10000, 20000, 40000, 70000, 100000, 500000] if testMode: counts = [int(n / testDivisor) for n in counts] numberOfTests = 1 randomLists = [getRandomList(count) for count in counts] elapsedTimes = [ timeit(lambda: bucketSort(list), number=numberOfTests) for list in randomLists ] lines = [Line((counts, elapsedTimes), "Caso aleatório", 'b')] plot(lines, "products/bucket_sort_graph.png") bucketNumbers = [1, 10, 100, 1000, 10000, 100000] bucketNumberTimes = [ timeit(lambda: bucketSort(getRandomList(100000), bucketNumber), number=numberOfTests) for bucketNumber in bucketNumbers ] lines = [ Line((bucketNumbers, bucketNumberTimes), "Lista com 100000 elementos", 'b') ] plot(lines, 'products/bucket_number_graph.png', 'Número de buckets') print( "De acordo com as informações obtidas ao analisar o gráfico, sugiro uma quantidade de buckets igual ao tamanho da entrada, ou uma quantidade de buckets igual a 1% do tamanho da entrada." )
import numpy as np from samplers.affineinv import AffineInv from utils.plotter import plot data = np.load('data.npy') paramranges = np.asarray( [ [0.,10.],[0.,10.] ] ) n_walkers = 50 n_steps = 5000 af_sampler = AffineInv(data,paramranges) af_sampler.afinv(n_walkers,n_steps) plot(500)
from utils.plotter import plot from utils.generator import getRandomList from timeit import timeit from utils.line import Line from utils.sorter import mergeSort # Change this value to switch from and to test mode testMode = False testDivisor = 100 counts = [10000, 20000, 40000, 70000, 100000, 500000] if testMode: counts = [int(n / testDivisor) for n in counts] randomLists = [getRandomList(count) for count in counts] elapsedTimes = [ timeit(lambda: mergeSort(list), number=1) for list in randomLists ] lines = [Line((counts, elapsedTimes), "Caso aleatório", 'b')] plot(lines, figname="products/merge_sort_graph.png")
from utils.plotter import plot from utils.generator import getRandomList, getDecrescentList from timeit import timeit from utils.line import Line from utils.sorter import selectionSort counts = [1000, 2000, 3000, 4000, 5000, 8000, 11000, 15000] randomLists = [getRandomList(count) for count in counts] worstLists = [getDecrescentList(count) for count in counts] elapsedTimes = [timeit(lambda: selectionSort(list), number = 1) for list in randomLists] worstElapsedTimes = [timeit(lambda: selectionSort(list), number = 1) for list in worstLists] lines = [Line((counts, elapsedTimes), "Caso aleatório", 'b'), Line((counts, worstElapsedTimes), "Pior caso", 'k')] plot(lines, figname = "products/selection_sort_graph.png")
from utils.plotter import plot from utils.generator import getRandomList from timeit import timeit from utils.line import Line from utils.sorter import shellSort # Little test to check if algorithm is working # list = getRandomList(25) # print(list) # shellSort(list) # print(list) # Change this value to switch from and to test mode testMode = False testDivisor = 100 counts = [10000, 20000, 40000, 70000, 100000, 500000] if testMode: counts = [int(n / testDivisor) for n in counts] randomLists = [getRandomList(count) for count in counts] elapsedTimes = [ timeit(lambda: shellSort(list), number=1) for list in randomLists ] lines = [Line((counts, elapsedTimes), "Caso aleatório", 'b')] plot(lines, figname="products/shell_sort_graph.png")
from utils.plotter import plot from utils.generator import getRandomList, getDecrescentList from timeit import timeit from utils.line import Line from utils.sorter import bubbleSort counts = [1000, 2000, 3000, 4000, 5000, 8000, 11000, 15000] randomLists = [getRandomList(count) for count in counts] worstLists = [getDecrescentList(count) for count in counts] elapsedTimes = [ timeit(lambda: bubbleSort(list), number=1) for list in randomLists ] worstElapsedTimes = [ timeit(lambda: bubbleSort(list), number=1) for list in worstLists ] lines = [ Line((counts, elapsedTimes), "Caso aleatório", 'b'), Line((counts, worstElapsedTimes), "Pior caso", 'k') ] plot(lines, figname="products/bubble_sort_graph.png")