コード例 #1
0
 def test_accept_logger(self):
     """Test that the simulator can accept a :py:class:`SimLogger`."""
     sim = self.sim(*self.args,
                    **self.kwargs,
                    logger=SimLogger('n_households'))
     sim.step(*self.args_step, **self.kwargs_step)
     self.assertEqual(type(sim.logger), SimLogger)
コード例 #2
0
        'household_type': 4,
        'hh_work_type': '1_fulltime_1_halftime'
    },  # ' One full-time and one part-time working person, three children'
]

n_hh_sim = 50
sim_act = SubgroupsActivitySimulator(
    corresponding_gtou_subgroups,
    [n_hh_sim for i in corresponding_gtou_subgroups],
)

sim_app = OccupancyApplianceSimulator(
    corresponding_gtou_subgroups,
    [n_hh_sim for i in corresponding_gtou_subgroups],
    initial_active_occupancy=sim_act.get_active_occupancy(),
    logger=SimLogger('get_energy_consumption', aggregated=False))

n_days = 3
for i in range(n_days * 24 * 6):
    sim_act.step()
    for i in range(10):
        sim_app.step(sim_act.get_active_occupancy())

sim_app.logger.plot(aggregate=True)

demod_profiles = sim_app.logger.get('get_energy_consumption')

median_profiles = []
for i in range(11):
    subgroup_profiles = demod_profiles[:, i * 50:(i + 1) * 50]
    med_ind = np.argsort(np.sum(subgroup_profiles, axis=0))[25]
コード例 #3
0
ファイル: bottaccioli.py プロジェクト: epfl-herus/demod
from demod.datasets.Germany.loader import GermanDataHerus
from demod.simulators.activity_simulators import SubgroupsIndividualsActivitySimulator, SemiMarkovSimulator, MarkovChain1rstOrder

# %%
n_households = 5

data = GermanDataHerus(version='vBottaccioli')

hh_subgroups, probs, _ = data.load_population_subgroups()

n_hh_list = sample_population(n_households, probs)

sim = SubgroupsIndividualsActivitySimulator(hh_subgroups,
                                            n_hh_list,
                                            logger=SimLogger(
                                                'get_activity_states',
                                                'current_time',
                                                aggregated=False),
                                            subsimulator=SemiMarkovSimulator,
                                            data=data,
                                            use_week_ends_days=True)

sim_app = ActivityApplianceSimulator(
    n_households,
    initial_activities_dict=sim.get_activity_states(),
    data=data,
    equipped_sampling_algo="subgroup",
    subgroups_list=hh_subgroups,
    n_households_list=n_hh_list,
    logger=SimLogger('current_time',
                     'get_current_power_consumptions',
                     aggregated=False))
コード例 #4
0
ファイル: semi_markov.py プロジェクト: epfl-herus/demod
    'n_residents': 2
}, {
    'household_type': 3,
    'n_residents': 3
}, {
    'household_type': 4,
    'n_residents': 5
}]
subgroup_households_to_persons(hh_subgroups)
n_hh_list = [300, 200, 100]
reload(demod.simulators.activity_simulators)
from demod.simulators.activity_simulators import SubgroupsIndividualsActivitySimulator, SemiMarkovSimulator, MarkovChain1rstOrder
sim = SubgroupsIndividualsActivitySimulator(hh_subgroups,
                                            n_hh_list,
                                            logger=SimLogger(
                                                'get_activity_states',
                                                'current_time'),
                                            subsimulator=MarkovChain1rstOrder,
                                            use_7days=True)

for i in range(9 * 144):
    sim.step()

# %%
dict_states = sim.logger.get('get_activity_states')
time_axis = sim.logger.get('current_time')

plot_household_activities(dict_states, time_axis=time_axis, colors=None)

# %%
コード例 #5
0
from demod.simulators.base_simulators import SimLogger
from demod.datasets.GermanTOU.loader import GTOU
from demod.datasets.OpenPowerSystems.loader import OpenPowerSystemClimate

from demod.simulators.crest_simulators import Crest4StatesModel
from demod.simulators.weather_simulators import RealClimate
from demod.simulators.lighting_simulators import FisherLightingSimulator

n_households = 100
# Start of the simulation
start_datetime = datetime.datetime(2014, 3, 1, 0, 0, 0)

climate_sim = RealClimate(
    data=OpenPowerSystemClimate('Germany'),  # A climate dataset
    start_datetime=start_datetime,  # Specifiy the start of the simulaiton
    logger=SimLogger('get_irradiance'))

activity_sim = Crest4StatesModel(
    n_households,
    data=GTOU('4_States'),  # Time of use survey for germany
    start_datetime=start_datetime,  # Specifiy the start of the simulaiton
    logger=SimLogger('get_active_occupancy'))

lighting_sim = FisherLightingSimulator(
    n_households,
    # Gets the initial values from other simulators
    initial_active_occupancy=activity_sim.get_occupancy(),
    initial_irradiance=climate_sim.get_irradiance(),
    logger=SimLogger('get_power_consumption'))
# No data was specified, it will use a default dataset.
コード例 #6
0
    'n_residents': 5,
    'household_type': 4,
}  # n° residents should be consisten with the household type
# Here the available household types:
# 1 = One person household
# 2 = Couple without kids
# 3 = Single Parent with at least one kid under 18 and the other under 27
# 4 = Couple with at least one kid under 18 and the other under 27
# 5 = Others

# Occupancy
occ_sim = SparseTransitStatesSimulator(n_households,
                                       subgroup,
                                       data,
                                       logger=SimLogger(
                                           'get_active_occupancy',
                                           'get_occupancy'),
                                       start_datetime=time_)

# Climate
climate_sim = RealInterpolatedClimate(
    data,
    start_datetime=time_,
    logger=SimLogger('get_irradiance', 'get_outside_temperature'),
    # choose the one minute step size
    step_size=datetime.timedelta(minutes=1),
)

# Heating system
# It integrates (1) heating demand, (2) thermostat, (3) building thermal
# dynamics, (4) heating system control and (5) operation
コード例 #7
0
import os
import sys

sys.path.insert(1, os.path.join(sys.path[0], '..'))

from demod.simulators.load_simulators import LoadSimulator
# Import the DatasetLoader
from demod.datasets.CREST.loader import Crest

from demod.simulators.base_simulators import SimLogger

sim = LoadSimulator(n_households=100, data=Crest())

sim = LoadSimulator(n_households=1,
                    data=Crest(),
                    logger=SimLogger('current_time', 'get_power_demand',
                                     'get_temperatures'))

for i in range(24 * 60):
    sim.step()

# Plots all the logged data one by one
sim.logger.plot()
# plots all the data in column
sim.logger.plot_column()
# Gets array of the data, can be used for your own purpose
elec_cons = sim.logger.get('get_power_demand')