Welcome to GcSim’s documentation!¶
Indices and tables¶
-
class
gcsim.
GCDaemon
(*args, **kwargs)¶ Bases:
daemons.prefab.run.RunDaemon
-
static
run
()¶ Perform the daemon logic.
-
static
Simulator¶
This module allows for starting, stopping and checking the status of the simulator and eventually of the optimizer
-
gcclient.
start
(args)¶ It starts the first simulator and eventually the optimizer :param args: command line arguments :return:
- Args:
- args:
-
gcclient.
start_optimizer
(optimizer, policy)¶ - Args:
- optimizer: the optimizer to start (should be supported dummy, eurecat, oslo) policy: the optimization policy (Es: cheapest, greenest, earliest)
- Returns:
- None
-
gcclient.
start_simulator
(args)¶ It will start the agents based simulator :return:
- Args:
- args:
-
gcclient.
stop
(args)¶ It stops both the simulator and the optimizer :param args: :return:
- Args:
- args:
-
gcclient.
stop_optimizer
(optimizer)¶ - Args:
- optimizer:
-
gcclient.
stop_simulator
()¶ It will stop the simulator component :return:
Setup¶
This agent deals with the creation of the message queue.
-
class
agents.setup.
AbstractDevice
(id='0', house='0', type='0', name='0')¶ Bases:
object
This class defines an abstract device, will be implemented by other classes.
-
class
agents.setup.
Abstract_event
(device='0', house='0', creation_time='0', type2=0)¶ Bases:
object
This class defines an abstract event.
-
class
agents.setup.
BackGroundLoad
(id='0', house='0', name='0')¶ Bases:
agents.setup.AbstractDevice
This class defines an background load.
-
class
agents.setup.
Battery
(id=0, house=0, name='0', capacity='0', max_ch_pow_ac='0', max_ch_pow_cc='0', max_dis_pow='0', max_all_en='0', min_all_en='0', sb_ch='0', sb_dis='0', ch_eff='0', dis_eff='0')¶ Bases:
agents.setup.AbstractDevice
This class defines an Battery device.
-
class
agents.setup.
ChargingPoint
(type='0', id='0', houseid='0', conntype='0', peakload='0')¶ Bases:
object
This class defines a charging Point.
-
class
agents.setup.
ChargingStation
(type='0', id='0', peakload='0', numcp=0)¶ Bases:
object
This class defines a charging Station.
-
class
agents.setup.
Device
(id='0', type='0', name='0', house='0')¶ Bases:
agents.setup.AbstractDevice
This class defines a schedulable device or a producer device.
-
class
agents.setup.
EV
(id=0, house=0, chargingPoint=0, name='0', capacity='0', max_ch_pow_ac='0', max_ch_pow_cc='0', max_dis_pow_ac='0', max_dis_pow_cc='0', max_all_en='0', min_all_en='0', sb_ch='0', sb_dis='0', ch_eff='0', dis_eff='0')¶ Bases:
agents.setup.AbstractDevice
This class defines an EV device.
-
class
agents.setup.
Energy_Cost
(type='0', profile='0')¶ Bases:
object
This class defines an energy cost event.
-
class
agents.setup.
Energy_Mix
(type='0', profile='0')¶ Bases:
object
This class defines an energy mix event.
-
class
agents.setup.
EnqueuedEvent
(timestamp, event, unique_id=None)¶ Bases:
object
This class overrides the comparison methods for the shared queue.
-
class
agents.setup.
Entities
¶ Bases:
object
This class is used to enqueue/get an object in/from the queue.
-
classmethod
enqueue_event
(timestamp, event, unique_id=None)¶ This method is used to enqueue an event in the event queue.
- Args:
- timestamp: Event time. event: The event. unique_id: An unique id in case of same timestamp for two events.
Returns:
-
classmethod
next_event
()¶ This method is used to dequeue an event from the event queue.
-
classmethod
-
class
agents.setup.
EventBackground
(device='0', house='0', creation_time='0', profile='0')¶ Bases:
agents.setup.Abstract_event
This class defines a background load event.
-
class
agents.setup.
EventBattery
(device='0', house='0', Soc_at_arrival='0', booking_time='0', start_time='0', end_time='0', target_soc='0')¶ Bases:
agents.setup.Abstract_event
This class defines a battery event.
-
class
agents.setup.
EventDelete
(device='0', house='0', creation_time='0', consumption=0)¶ Bases:
agents.setup.Abstract_event
This class defines a delete event.
-
class
agents.setup.
EventEcar
(device='0', house='0', Soc_at_arrival='0', booking_time='0', planned_arrival_time='0', planned_departure_time='0', actual_arrival_time='0', actual_departure_time='0', target_soc='0', v2g='0', priority='0')¶ Bases:
agents.setup.Abstract_event
This class defines an EV event.
-
class
agents.setup.
EventGeneral
(device='0', house='0', est='0', lst='0', creation_time='0', profile='0', type2=0)¶ Bases:
agents.setup.Abstract_event
This class defines a schedulable event.
-
class
agents.setup.
EventHeaterCooler
(device='0', house='0', creation_time='0', profile='0')¶ Bases:
agents.setup.Abstract_event
This class defines a heater/cooler load event.
-
class
agents.setup.
EventProducer
(device='0', house='0', est='0', lst='0', creation_time='0', profile='0', type2=0, energycost='0')¶ Bases:
agents.setup.Abstract_event
This class defines a producer event.
-
class
agents.setup.
ExternalSourceAgent
(address, passw, pathneigh, pathload)¶ Bases:
spade.agent.Agent
This Agent deals to the creation of simulation data from xml files.
-
class
agents.setup.
HeaterCooler
(id='0', house='0', name='0')¶ Bases:
agents.setup.AbstractDevice
This class defines an heater/cooler device.
-
class
agents.setup.
House
(type='0', id='0', peakload='0', numcp=0)¶ Bases:
object
This class defines an house.
-
class
agents.setup.
Neighborhood
(type='0', peakload='0')¶ Bases:
object
This class defines a neighborhood.
-
agents.setup.
copyInscheduler
()¶ This method copy the scenario to the web directory to allow the scheduler to download the files.
-
agents.setup.
createDevicesList
()¶ This method read from neighborhood.xml all the devices, sort them by type and append them to device list.
-
agents.setup.
createEventList
()¶ This method read from loads.xml the events info and append them to loadslist.
-
agents.setup.
makeNewSimulation
(pathneigh, pathload)¶ This Method create all simulation directories.
- Args:
- pathneigh: The neighborhood.xml path. pathload: The loads.xml path.
-
agents.setup.
now
()¶ Returns new datetime object representing current time local to tz.
- tz
- Timezone object.
If no tz is specified, uses local timezone.
-
agents.setup.
switchInTime
()¶ This method Convert Timestamps of a timeseries of an X day in timestamps of simulation day.
-
agents.setup.
uploadInInputRepository
()¶ This method enqueue objects in the shared queue.
Manager¶
This agent starts and stops the simulation.
-
class
agents.manager.
SetupModule
(jid, password, verify_security=False)¶ Bases:
spade.agent.Agent
SetupModule Agent is used for start/stop dispatching messages.
- Args:
- Agent: The spade Agent.
-
class
StartService
¶ Bases:
spade.behaviour.OneShotBehaviour
The startService Behaviour is used for start dispatcher.
- Args:
- OneShotBehaviour: The behaviour’s type.
-
run
()¶ Body of the behaviour. To be implemented by user.
-
class
StopService
¶ Bases:
spade.behaviour.OneShotBehaviour
The stopService Behaviour is used for stop dispatcher.
- Args:
- OneShotBehaviour: The behaviour’s type.
-
run
()¶ Body of the behaviour. To be implemented by user.
-
setup
()¶ The setup method is used for add behaviours to the agent.
Dispatcher¶
This agent deals with the message queue management.
-
agents.dispatcher.
calculateConsumption
(file)¶ This method calculates consumption in KW of a load consumer. It is used in the delete message.
- Args:
- file: Timeseries whose consumption is to be calculated
-
agents.dispatcher.
calculateTime
(file)¶ - This function calculates the execution time of a scheduled load. It is used to put DeleteMessage in sharedQueue
- at the right time.
- Args:
- file: Timeseries whose time delta is to be calculated
-
agents.dispatcher.
switchInTime
(file, ast)¶ This function shifts a timeseries over time based on the ast received from the scheduler.
- Args:
- file: Timeseries whose time is to be shift ast: New assigned starting Time
RESTAdaptor¶
This agent create a REST server in order to communicate with REST schedulers.
-
class
agents.restAdaptor.
Adaptor
(jid, password, verify_security=False)¶ Bases:
spade.agent.Agent
Adaptor used for the REST protocol.
- Args:
- Agent: The spade Agent.
-
class
MessageManager
(period, start_at=None)¶ Bases:
spade.behaviour.PeriodicBehaviour
-
run
()¶ Body of the behaviour. To be implemented by user.
-
-
exposeGetRestAPI
(request)¶ GET API used by schedulers to get a message.
- Args:
- request: the REST request
-
exposePostRestAPI
(request)¶ POST API used by schedulers to post an answer to the dispatcher. It recieve a file and write the content in simulation directory or a general message.
- Args:
- request: the REST request
-
get_time
(request)¶ GET API used by schedulers to get simulation time.
- Args:
- request: the REST request
-
setup
()¶ Setup agent before startup. This coroutine may be overloaded.
XMPPAdaptor¶
This agent create a REST server in order to communicate with XMPP schedulers.
-
class
agents.xmppAdaptor.
Adaptor
(jid, password, verify_security=False)¶ Bases:
spade.agent.Agent
Adaptor used for the XMPP protocol.
- Args:
- Agent: The spade Agent.
-
class
XMPPMessageManager
(period, start_at=None)¶ Bases:
spade.behaviour.PeriodicBehaviour
-
run
()¶ Body of the behaviour. To be implemented by user.
-
-
exposePostRestAPI
(request)¶ POST API used by schedulers to post a timeseries. It recieve a file and write the content in simulation directory
- Args:
- request: the REST request
-
setup
()¶ Setup agent before startup. This coroutine may be overloaded.
Config¶
This class is used to load the configuration file.
Message Factory¶
This Class deals with the message creation from data.
-
class
utils.MessageFactory.
MessageFactory
¶ Bases:
object
This Class deals with the message creation from data.
-
classmethod
background
(device, time, protocol_version)¶ This method creates the Background message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
booking_request
(device, time, protocol_version)¶ This method creates the booking_request message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
chargingpoint
(device, time, protocol_version)¶ This method creates the EnergyHub for Charging Point message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
chargingstation
(device, time, protocol_version)¶ This method creates the EnergyHub for Charging Station message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
create_Battery
(device, time, protocol_version)¶ This method creates the Create Battery message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
create_ev
(device, time, protocol_version)¶ This method creates the Create Ev message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
create_load
(device, time, protocol_version)¶ This method creates the Create Load message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
create_producer
(device, time, protocol_version)¶ This method creates the Create Producer message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
delete_load
(device, time, protocol_version)¶ This method creates the Delete load message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
end
(actual_time)¶ This method creates the end message.
- Args:
- actual_time: Simulation Time.
-
classmethod
energyCost
(device, time, protocol_version)¶ This method creates the EnergyCost message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
energyCostProducer
(device, time, protocol_version)¶ This method creates the EnergyCost for producers message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
energyMix
(device, time, protocol_version)¶ This method creates the EnergyMix message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
heatercooler
(device, time, protocol_version)¶ This method creates the HeaterCooler message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
house
(device, time, protocol_version)¶ This method creates the EnergyHub for houses message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
init_parameters
()¶ This Method initializes the parameters useful to the class.
-
classmethod
neighborhood
(device, time, protocol_version)¶ This method creates the EnergyHub for neighborhood message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
update_producer
(device, time, protocol_version)¶ This method creates the Update Producer message.
- Args:
- device: Device the message refers to. time: Simulation Time. protocol_version: Distinguish between schedulers.
-
classmethod
Visualization¶
This Class deals with the creation of outputs data and charts.
-
class
utils.visualization.
Intersection
¶ Bases:
object
This class compute the intersection between two curve using different methods.
-
classmethod
interp
(f, x, z)¶ - Args:
- f: x: z:
-
classmethod
intersect1
(x, y1, y2)¶ - Args:
- x: y1: y2:
-
static
intersect2
(f1, f2, xx)¶ - Args:
- f1: f2: xx:
-
classmethod
solve
(f, x)¶ - Args:
- f: x:
-
classmethod
-
utils.visualization.
callExternal
(folder, out_path='.')¶ - Args:
- folder: out_path:
-
utils.visualization.
ce2e
(yy)¶ - Args:
- yy:
-
utils.visualization.
ce2p
(xx, yy, positive=True)¶ - Args:
- xx: yy: positive:
-
utils.visualization.
compute_area
(ffunc, xx, a, b)¶ This code compute the area below the curve ffunc, between a and b
- Args:
- ffunc: xx: a: b:
-
utils.visualization.
ev2maxself
(ev_ce, xx, res_energy, filename)¶ This function change the energy profile of an ev to optimize the usage of residual green energy :param ev_ce: :param xx: :param res_energy: :param filename: :return:
- Args:
- ev_ce: xx: res_energy: filename:
-
utils.visualization.
p2ce
(xx, yy)¶ - Args:
- xx: yy:
-
utils.visualization.
plot_output
(sim_output, path='.')¶ - Args:
- sim_output: path:
-
utils.visualization.
plot_power
(groups, colr=None)¶ - Args:
- groups: colr:
-
utils.visualization.
shift_load
(shift_time, infile, outfile)¶ This code shift a timeseries :param shift_time: :param infile: :param outfile: :return:
- Args:
- shift_time: infile: outfile: