International Business Environments and Operations 16th Global Edition test b...
R tool for energy efficient building investment decisions under uncertainty
1. Decision Making under Uncertainty:
R implementation for Energy Efficient Buildings
Emilio L. Cano1 Javier M. Moguerza1
1 Department of Statistics and Operations Research
University Rey Juan Carlos, Spain
The 8th International R Users Meeting
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 1/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
2. Outline
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 2/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
3. Outline
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 3/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
4. Introduction
The model described in this talk has been developed within
the project EnRiMa: Energy Efficiency and Risk Management
in Public Buildings, funded by the EC.
The overall objective of EnRiMa is to develop a
decision-support system (DSS) for operators of
energy-efficient buildings and spaces of public use.
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 4/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
5. Introduction
The model described in this talk has been developed within
the project EnRiMa: Energy Efficiency and Risk Management
in Public Buildings, funded by the EC.
The overall objective of EnRiMa is to develop a
decision-support system (DSS) for operators of
energy-efficient buildings and spaces of public use.
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 4/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
6. Consortium
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 5/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
7. Outline
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 6/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
8. EnRiMa DSS
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 7/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
9. Outline
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 8/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
10. Optimization Scope
Strategic Model Interaction
Strategic decisions concerning The strategic model includes
which technologies to install a simplified version of
and/or decommission in the long operational energy-balance
term constraints
The operational model
Operational Model includes the realisation of
Energy portfolio selection in the the strategic decisions as
short term parameters
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 9/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
11. Optimization Scope
Strategic Model Interaction
Strategic decisions concerning The strategic model includes
which technologies to install a simplified version of
and/or decommission in the long operational energy-balance
term constraints
The operational model
Operational Model includes the realisation of
Energy portfolio selection in the the strategic decisions as
short term parameters
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 9/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
12. Optimization Scope
Strategic Model Interaction
Strategic decisions concerning The strategic model includes
which technologies to install a simplified version of
and/or decommission in the long operational energy-balance
term constraints
The operational model
Operational Model includes the realisation of
Energy portfolio selection in the the strategic decisions as
short term parameters
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 9/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
13. Scheme of the Project
EnRiMaDSS
Strate ic
g
Strategic DVs
Module
Strategic Upper-Level
Constraints Operational DVs
Upper-Level Lower-Level
Energy-Balance Operational DVs
Constraints
Lower-Level
Energy-Balance
Operational Constraints
Module
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 10/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
14. Scenario trees
Stage 1 Stage 2 Stage 3
Scenario 1
Scenario 2
Scenario 3
Scenario 4
Scenario 5
Scenario 6
1 2 3 4 5 6 7 8 9
Decision Time
Illustrative scenario tree
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 11/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
15. Outline
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 12/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
16. Objective Function (example)
min CIip,0 · Gi · siip CISjp,0 · GSj · xijp
p∈P i∈I j ∈J
p p p p
+ Gi CDip−a1 sdia1,a2 + CDSjp−a1 xdja1,a2
i∈I a1=0 a2=a1+1 j ∈J a1=0 a2=a1+1
p p,m,t p,m,t
+ DMm COi,k · zi,k
m∈M i∈I k ∈K t∈T
p p,m,t p,m,t
+ DMm COSk ,j · rk ,j
m∈M j ∈J k ∈K t∈T
p p,m,t p,m,t,mm
− DMm PPi,k ,n · uk ,n
m∈M i∈I k ∈K n∈NS (k ) mm∈MA t∈T
p p,m,t p,m,t,mm
− DMm SPi,k ,n · wk ,n
m∈M i∈I k ∈K n∈NS (k ) mm∈MS t∈T
− SUip · Gi · siip
i∈I
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 13/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
17. Constraints (two examples)
Energy Balance (operational):
p,m,t p,m,t,mm
zi,k + uk ,n
i∈I n∈NB(k ) mm∈MA
p,m,t p,m,t,mm p,m,t p,m,t
− yi,k − wk ,n qik ,j ≥ Dk
i∈I mm∈MS n∈NS (k ) j ∈JS
p,m,t
− qok ,j − Φp,m,t
j − p,m,t
ODk ,j · xjp · Dk
j ∈JS j ∈JPS j ∈JPU
p ∈ P, m ∈ M, t ∈ T, k ∈ K
Emissions limit (strategic):
p,m,t p,m,t,mm
p
DMm Hi,k ,l · yi,k Ci,l,n · uk ,n ≤ PLp
l
m∈M i∈I k ∈K t∈T n∈N k ∈K t∈T
p ∈ P, l ∈ L
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 14/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
18. Outline
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 15/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
19. Symbolic Model Specification
The formulation reached models complex systems
Moreover, the Symbolic Model Specification should be:
Flexible
Replicable
Reproducible
Scalable
Portable
Thus, a suitable structure is needed
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 16/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
20. Data model
Model and Instance Classes, data attributes, input/output methods
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 17/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
21. Outline
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 18/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
22. Algebraic Languages
Needs
Statistical Software
Data Visualization
Data Analysis
Mathematical
Representation
Solver Input
Generation
Output
Documentation
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 19/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
23. R as an Integrated Environment
Advantages
Open Source
Reproducible Research and Literate Programming capabilities.
Integrated framework for SMS, data, equations and solvers.
Data Analysis (pre- and post-), graphics and reporting.
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 20/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
24. R Code Example
> cat ( getEq ( mySMS , 1 , format = " gams " ) , " n " )
genTechAvail (p , i ) .. s (i , p ) = e = G ( i ) * Sum (( a ) , AG (i , a ) * (
si (i , p ) - Sum (( q ) , sd (i ,p , q ) ) ) ;
> cat ( getEq ( mySMS , 1 , format = " tex " ) , " n " )
mathit { s } _ { i }^{ p } = mathit { G } _ { i }^{} cdot sum _ { a
in mathcal { A }} mathit { AG } _ { i }^{ a } cdot left (
mathit { si } _ { i }^{ p } - sum _ { q in mathcal { Q }}
mathit { sd } _ { i }^{ p , q } right ) qquad forall ; p in
mathcal { P } ,; i in mathcal { I }
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 21/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
25. Solution and report
Sweave file example:
%
documentclass [ a4paper ]{ article }
usepackage { Sweave }
title { Example Symbolic Model Specification }
author { urjc }
begin { document }
maketitle
section { Data analysis }
< < > >=
# Some code for importing the
# Symbolic Model and analyzing the
# input data ...
# Generate tex file
wProblem ( myImplem ,
filename = " myImplem . tex " ,
format = " tex " ,
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 22/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
26. Solution and report (cont.)
solver = " lp " )
# generate gams file
wProblem ( initStochImplem ,
filename = " myImplem . gms " ,
format = " gams " ,
solver = " lp " )
@
section { Symbolic Model Specification }
% Write the LaTeX equations
input { myImplem }
section { Call to solver }
< < > >=
require ( gdxrrw )
gams ( " myImplem . gms -- outfile = mySol . gdx " )
@
section { Solution Analysis }
< < > >=
lst <- list ( name = ' solvestat ' , form = ' full ' , compress = TRUE )
solverResults <- rgdx ( " mySol . gdx " , lst )
# Some analysis and charts over solverResults object
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 23/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
27. Solution and report (cont.)
@
end { document }
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 24/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
28. Summary
In this presentation the models developed for the EnRiMa
DSS have been described
An integrated framework allows to integrate analysis,
representation and solution of optimization problems
Examples of use have been presented
Outlook
Integration of scenarios for stochastic optimization
Extend representation formats: HTML, ODF, . . .
Further formats: AMPL, MPS, XML, . . .
A contributed package?
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 25/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
29. Summary
In this presentation the models developed for the EnRiMa
DSS have been described
An integrated framework allows to integrate analysis,
representation and solution of optimization problems
Examples of use have been presented
Outlook
Integration of scenarios for stochastic optimization
Extend representation formats: HTML, ODF, . . .
Further formats: AMPL, MPS, XML, . . .
A contributed package?
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 25/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
30. References
[1] Michel Berkelaar and others. lpSolve: Interface to Lp solve v. 5.5 to solve
linear/integer programs, 2011. URL
http://CRAN.R-project.org/package=lpSolve. R package version 5.6.6.
[2] COIN-OR Foundation. Internet, 2012. URL http://www.coin-or.org/. retrieved
2012-06-12.
[3] A.J. Conejo, M. Carri´n, and J.M. Morales. Decision Making Under Uncertainty in
o
Electricity Markets. International Series in Operations Research and Management
Science Series. Springer, 2010. ISBN 9781441974204. URL
http://books.google.es/books?id=zta0qWS_W98C.
[4] EnRiMa. Energy efficiency and risk management in public buildings.
www.enrima-project.eu, 2012.
[5] GAMS. gdxrrw: interfacing gams and R. Internet, 2012. URL
http://support.gams-software.com/doku.php?id=gdxrrw:
interfacing_gams_and_r. retrieved 2012-03-06.
[6] Chris Marnay, Joseph Chard, Kristina Hamachi, Tim Lipman, Mithra Moezzi,
Boubekeur Ouaglal, and Afzal Siddiqui. Modeling of customer adoption of
distributed energy resources. Technical report, Lawrence Berkeley National
Laboratory, 2001. URL http://der.lbl.gov/publications/
modeling-customer-adoption-distributed-energy-resources.
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 26/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
31. References (cont.)
[7] R Development Core Team. R: A Language and Environment for Statistical
Computing. R Foundation for Statistical Computing, Vienna, Austria, 2012. URL
http://www.R-project.org/. ISBN 3-900051-07-0.
[8] Afzal S. Siddiqui, Chris Marnay, Jennifer L. Edwards, Ryan Firestone, Srijay
Ghosh, and Michael Stadler. Effects of carbon tax on microgrid combined heat
and power adoption. Journal of Energy Engineering, 131(1):2–25, 2005. doi:
10.1061/(ASCE)0733-9402(2005)131:1(2). URL
http://link.aip.org/link/?QEY/131/2/1.
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 27/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
32. Acknowledgements
R-project
GAMS Software
EnRiMa project partners
Project RIESGOS-CM: code S2009/ESP-1685
This work has been partially funded by the projects:
Energy Efficiency and Risk Management in Public Buildings (EnRiMa) EC’s FP7
project (number 260041)
AGORANET project (IPT-430000-2010-32)
HAUS: IPT-2011-1049-430000
EDUCALAB: IPT-2011-1071-430000
DEMOCRACY4ALL: IPT-2011-0869-430000
CORPORATE COMMUNITY: IPT-2011-0871-430000
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 28/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation
33. Discussion
Thanks for your attention !
emilio.lopez@urjc.es
@emilopezcano
Use R! 2012, Vanderbilt University, Nashville, June 14 2012 29/1
Emilio L. Cano and Javier M. Moguerza Decision Making under Uncertainty: R implementation