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))
Esempio n. 2
0
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()
Esempio n. 3
0
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
Esempio n. 4
0
power = data[:, 4]
time = (np.arange(len(power)) * 6 + 6) / 3600

resampled_power, resampled_time = resample(power,
                                           t=time,
                                           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()
Esempio n. 5
0
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
Esempio n. 6
0
#!/usr/bin/env python3

import optess as oe


sig = oe.DataFactory.distorted_sin(npoints=100, mu=0, seed=30349)
obj = oe.Objective('exact', 0)
stor = oe.Storage(max(abs(sig.vals)), 0.95, 500)

hyb = oe.HybridDia(sig, stor, obj)
hyb.compute_parallel(cuts=[0.25, 0.5, 0.75], curves=2, workers=4)
hyb.pplot()

dummybreakpoint = True
Esempio n. 7
0
Loads a predefined factory setup, feeds optimization class and prints some
outputs.
"""

import optess as oe

signal = oe.DataFactory.rand(200,
                             mu=1,
                             freq=(6, 10),
                             amp=(1, 3),
                             time=100,
                             seed=200)
signal.pplot()
objective = oe.Objective('energy', 190)
power = 1.2
storage = oe.Storage(power, 0.95, 300)
opt = oe.OptimizeSingleESS(signal, storage, objective)
opt.solve_pyomo_model()
energy = opt.results.energycapacity
print('Single: power = {}, energy = {}'.format(power, energy))

base = oe.Storage(0.5 * power, 0.95, 1e50)
peak = oe.Storage(0.5 * power, 0.95, 1e50)
opthyb = oe.OptimizeHybridESS(signal, base, peak, objective)
opthyb.solve_pyomo_model()
baseenergy = opthyb.results.baseenergycapacity
peakenergy = opthyb.results.peakenergycapacity
print('Hybrid: baseenergy = {}, peakenergy = {}'.format(
    baseenergy, peakenergy))

virtualbreakpoint = True
Esempio n. 8
0
#!/usr/bin/env python3
"""
Loads a predefined factory setup, feeds optimization class and prints some
outputs.
"""

import timeit

import optess as oe

peakcut = 3
objective = oe.Objective('power', peakcut)
for npoints in [44, 66, 88, 110, 220, 440]:
    name = 'std_{}'.format(npoints)
    signal = oe.DataFactory.std(npoints)
    storagepower = (max(signal.vals) - peakcut)
    storage = oe.Storage(storagepower, 0.95, 1000)
    start = timeit.default_timer()
    dia = oe.HybridDia(signal, storage, objective, name=name)
    dia.calculate_curves()
    dia.calculate_area((7, 7))
    end = timeit.default_timer() - start
    print('Hybrid Dia Calculation npoints = {} went for {} seconds'.format(
        npoints, end))
    dia.pplot()
    dia.save()

virtualbreakpoint = True
Esempio n. 9
0
#!/usr/bin/env python3

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,