dexr supports the direct energy exchange (DEX) demonstration environment. The DEX environment includes OGEMA clients dealing on a market server that enables the configuration of various market products and parameters. Clients can be configured to control PV modules, wind turbines, storage and consuming devices.
The package provides various functions to configure and run experiments, load data from db and XML configuration files, convert, and finally visualise it. Therefore, in a chain of production these functions need to be combined. At the same time, there are a number of high level functions which integrate the more basic functions but leave less scope for customisation. These high level functions start with 'hl'.
This gives an overview whereas the configuration is described in Config, running simulations in Run, any analysing results in Analyse.
There is a dexpa
(DEX Parameters) list which contains all project-specific properties, directories,
and parameters. The dexp
a list consists of a number of sublists:
sim
dirs
xml
fig
db
colours
debug
The basic idea is to define a dexpa list for each project and machine and execute the dexpa defining R code every time you start a script with the according project:
Before or within the script, the machine-specific dexpa
configuration (dexpa-maschine_XY.R
) is loaded.
The machine-specific dexpa
file includes the project-specific file (dexpaProject.R.) which also loads the default parameter list. Therefore, the machine-specific file may overwrite certain defaults of project-wide parameters.
## DexpaProject.R #### Load common packages ###################################################### library(kfigr) library(shbasic) library(RPostgreSQL) ### Load default parameters #################################################### if (!exists("dexpa")) dexpa <- dexR::param_getDefaultDexpa() ### Simulation Data ############################################################ dexpa$sim$project <- "Projectname" ### Logger settings ############################################################ futile.logger::flog.threshold(futile.logger::INFO, name='dexr') ### DB Settings ################################################################ if(!is.list(dexpa$db)) dexpa$db <- list() dexpa$db$host <- "localhost" dexpa$db$port <- "5432" dexpa$db$dbname <- "dexr" dexpa$db$username <- "user" dexpa$db$password <- "password" dexpa$db$suname <- "postgres" dexpa$db$supassword <- "supassword"
The script then includes a project-version-specific file dexpa-pversion.R
(e.g. image resolutions)
The script itself may then override particular parameter values with experiment-specific properties (e.g. runID).
Consequently, one can define parameters on four different levels: project > machine > project version > simulation.
Using the parameter set during an initial execution of the machine-dependent scripts at startup, each
script using dexR should load the dexpa
code anew. During that process, the entire dexpa
list
including all possible changes are removed from memory and loaded anew. Following above suggestions,
a script first loading the setting/scenario specific dexpa.R
would look like this:
# Only contained when the particular script is only executed on a specific machine! # Otherwise. the machine-specific file needs to be executed before. source("/PATH-TO/dexpa-machine_XY.R") # dexpa$dirs$scripts is set by machine-specific file: setwd(paste(dexpa$dirs$scripts, sep="/")) # usually, the project version specific `dexpa` file is a level above: source("../dexpa-pversion_pversion.R")
Colours for different purposes are defined in sublists of dexpa$colours$products
, eg. products
and statuses
.
Each simulation run should have a unique ID which is to be assigned to dexpa$sim$id
.
Since DEX stores data to a PostGreSQL database, data of different runs should be stored in different databases. To this end, the main database DEX is writing to needs to be either dumped to a file or duplicated to another database:
dexR::input_db_db2dump(dexpa, dumpdir = paste("dump_", dexpa$sim$id, sep="")) dp1 <- dexpa dp1$db$dbname <- "enavi_01-01" dexR::input_db_dump2db(dp1, dumpfile=paste("dump_", dp1$sim$id, sep=""))
dexR uses the package futile.logger
. Initially, it sets up a console outputter
to log everything on INFO
level. However, the logger can be configured in a detailed way.
futile.logger::flog.threshold(futile.logger::DEBUG, name='dexr') futile.logger::flog.threshold(futile.logger::TRACE, name='dexr.input')
It is also possible to add handlers for further sinks.
futile.logger::flog.appender(appender.file(filename), name='dexr.output')
Compare the documentation for package futile.logger
for more detailed information.
A tutorial is also available.
Usually, a previous instance of the market server is still running.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.