def main(npoints, nprocesses): # Define and create signal start = timeit.default_timer() mu = 100 freq = [int(npoints * f) for f in [0.005, 0.02, 0.05, 0.2]] ampl = [1, 2, 4, 8] time = 3600 seed = npoints * 10 signal = oe.DataFactory.rand(npoints, mu, freq, ampl, time, seed) # Read some Signal infor pmin = signal.amv pmax = max(signal.vals) peakcut = (pmax - pmin) * 0.4 + pmin storagepower = pmax - peakcut end = timeit.default_timer() - start print('Preprocessing... {} seconds'.format(end)) # Define, create objective and storage objective = oe.Objective('power', peakcut) storage = oe.Storage(storagepower, 0.95, 1e6) name = 'single{}'.format(npoints) # Start calculation start = timeit.default_timer() dia = oe.HybridDia(signal, storage, objective, name=name, nprocesses=nprocesses) end = timeit.default_timer() - start print('Single Calculation ... {} seconds'.format(end)) # Save start = timeit.default_timer() dia.save() end = timeit.default_timer() - start print('Saving... {} seconds'.format(end))
def main(npoints, nprocesses): mu = 100 freq = [int(npoints * f) for f in [0.005, 0.02, 0.05, 0.2]] ampl = [1, 2, 4, 8] time = 3600 seed = npoints signal = oe.DataFactory.rand(npoints, mu, freq, ampl, time, seed) pmin = signal.amv pmax = max(signal.vals) peakcut = (pmax - pmin) * 0.3 + pmin storagepower = pmax - peakcut objective = oe.Objective('power', peakcut) storage = oe.Storage(storagepower, 0.95, 1e5) name = 'all{}'.format(npoints) start = timeit.default_timer() dia = oe.HybridDia(signal, storage, objective, name=name, nprocesses=nprocesses) end = timeit.default_timer() - start print('Single Calc went for {} seconds'.format(end)) start = timeit.default_timer() dia.calculate_curves() end = timeit.default_timer() - start print('Curve Calculation went for {} seconds'.format(end)) start = timeit.default_timer() dia.calculate_area((11, 11)) end = timeit.default_timer() - start print('Area Calculation went for {} seconds'.format(end)) print('Calculated points: {}'.format(len(dia.area.keys()))) dia.save()
import optess as oe sig = oe.DataFactory.rand(npoints=128, seed=123) obj = oe.Objective('power', 12) stor = oe.Storage(max(sig.vals) - 12, 0.95, 1e6) hyb = oe.HybridDia(sig, stor, obj) hyb.compute_serial(cuts=[0.4, 0.6], curves=2) hyb.pplot() dummybreakpoint = True
num=int( np.floor(len(time) / 10 / 15))) signal = oe.Signal(time, power) resampled_signal = oe.Signal(resampled_time, resampled_power) peakcut = 1050 storpower = max(resampled_signal.vals) - peakcut objective = oe.Objective('power', peakcut) storage = oe.Storage(storpower, 0.95, 1e-3) # ax = plt.figure().add_subplot(1, 1, 1) # signal.pplot(ax=ax) # resampled_signal.pplot(ax=ax) print('Initializing HybridDia Object...') start = timeit.default_timer() hybdia = oe.HybridDia(resampled_signal, storage, objective, name='Stahlwerk Unna') end = timeit.default_timer() - start print('Initialized... Time: {} seconds'.format(end)) start = timeit.default_timer() hybdia.calculate_curves(cuts=(0.25, 0.4, 0.55, 0.8)) end = timeit.default_timer() - start print('Calculated... Time: {} seconds'.format(end)) a = 'asdf'
hybdias = list() seeds = [1234] noises = [0, 1] npoints = 256 mu = 40 freqs = [3, 10, 50] ampl = [0.3, 2] peakcut = 41 objective = oe.Objective('power', peakcut) for seed, noise in itertools.product(seeds, noises): print('----- Calculating seed={}, noise={} -----'.format(seed, noise)) sig = oe.DataFactory.rand(npoints, mu, freqs, ampl + [noise], seed=seed) storagepower = max(sig.vals) - peakcut storage = oe.Storage(storagepower, 0.95, 1e16) hyb = oe.HybridDia(sig, storage, objective) hyb.calculate_curves([0.4, 0.6, 0.8]) hybdias.append(hyb) for hyb, (seed, noise) in zip(hybdias, itertools.product(seeds, noises)): hyb.pplot() plt.savefig('hyb_seed_{}_noise_{:.2f}.png'.format(seed, noise), bbox_inches='tight') plt.savefig('hyb_seed_{}_noise_{:.2f}.eps'.format(seed, noise), bbox_inches='tight') dummybreakpoint = None
pointslist += [1500, 3000, 6000, 12000, 24000, 48000, 96000, 192000] pointslist += [ 13000, 13001, 30000, 30001, 55000, 55001, 115000, 115001, 175000, 175001 ] for npoints in pointslist: # Define signal mu = 100 freq = [int(npoints * f) for f in [0.005, 0.02, 0.05, 0.2]] ampl = [1, 2, 4, 8] time = 3600 seed = npoints * 10 signal = oe.DataFactory.rand(npoints, mu, freq, ampl, time, seed) # Read some Signal info pmin = signal.amv pmax = max(signal.vals) peakcut = (pmax - pmin) * 0.4 + pmin storagepower = pmax - peakcut objective = oe.Objective('power', peakcut) storage = oe.Storage(storagepower, 0.95, 1e7) name = 'signal_{}'.format(npoints) hyb = oe.HybridDia(signal, storage, objective, name=name) print('Submit {}'.format(npoints)) hyb.compute_torque(wt=1.5, mem=1.2, returninfo=False) dummybreakpoint = True
import os import optess as oe # sig = oe.DataFactory.freq(128, time=5, seed=1234) sig = oe.DataFactory.freq(256, mu=0.5, time=20, seed=314159) # sdia = oe.SingleDia(sig, rel_obj_fronts=[0.8], resolution=4) # sdia.compute_parallel() objval = 11.578 obj = oe.Objective('energy', objval) storval = 2.25 stor = oe.Storage(storval, 0.95, 50) if os.path.isfile('medenergy.hyb'): hyb = oe.HybridDia(sig, stor, obj, name='medenergy') hyb.compute_parallel(cuts=[0.2, 0.5, 0.8], curves=1) hyb.save('medenergy.hyb') else: hyb = oe.HybridDia.load('medenergy.hyb') overmixed = oe.OverdimDia(sig, stor, hyb.inter[0.5], obj, name='medenergy') overmixed.build_mesh_arrays() overmixed.compute_parallel() overdim = oe.overdimdia.OverdimDiaDim(sig, stor, hyb.inter[0.5], obj, name='medenergy') overdim.build_mesh_arrays()