DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Energy-efficient technology investments using a decision
support system framework
Emilio L. Cano1 Javier M. Moguerza1
Tatiana Ermolieva2 Yurii Yermoliev2
1Rey Juan Carlos University
2International Institute for Applied Systems Analysis (IIASA)
Salamanca, May 31 - June 2 2016
Computational Management Science 2016 1/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Outline
1 An Integrated Framework
2 Stochastic Models
3 Conclusions
Computational Management Science 2016 2/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Outline
1 An Integrated Framework
2 Stochastic Models
3 Conclusions
Computational Management Science 2016 3/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Decision Support Systems
Algorithms
Model
Symbolic model
Variables, relations
Underlying theory
Methodology, technique
Uncertainty modelling
Data
Deterministic data
Uncertain data -
Stochastic processes
Data analysis
Solution
Data treatment
Analysis
Visualization
DSS
Interpretation
Computational Management Science 2016 4/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Decision Support Systems
Algorithms
Model
Symbolic model
Variables, relations
Underlying theory
Methodology, technique
Uncertainty modelling
Data
Deterministic data
Uncertain data -
Stochastic processes
Data analysis
Solution
Data treatment
Analysis
Visualization
DSS
Stakeholders Dialog
Interpretation
Computational Management Science 2016 4/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Decision Support Systems
Computational Management Science 2016 4/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
DSS Framework
Computational Management Science 2016 5/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
DSS Framework
Requirements
Statistical software
Data visualization
Mathematical modeling
Solver input generation
Call to the solver
Output documentation
Computational Management Science 2016 5/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
DSS Framework
Requirements
Statistical software
Data visualization
Mathematical modeling
Solver input generation
Call to the solver
Output documentation
Copy-paste
Inconsistencies
Errors
Out-of-date
non-reproducible
Painful changes
Computational Management Science 2016 5/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
DSS Framework
Requirements
Statistical software
Data visualization
Mathematical modeling
Solver input generation
Call to the solver
Output documentation
Black box
Compiled software for specific
solutions
Changes require re-programming
Not reproducible
Computational Management Science 2016 5/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
DSS Framework
Requirements
Statistical software
Data visualization
Mathematical modeling
Solver input generation
Call to the solver
Output documentation
Framework
Reproducible Research & Literate Programming
omptimr R package & Algebraic Modeling Languages (AMLs)
“The goal of RR is to tie specific instructions to data analysis and
experimental data [and modeling] so that results can be recreated,
better understood and verified”
“LP: a document that is a combination of content and data analysis
code [and models]”
Computational Management Science 2016 5/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
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.
Computational Management Science 2016 6/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
optimr Package
Computational Management Science 2016 7/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
optimr Package
Computational Management Science 2016 7/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
optimr Package
getEq(model1SMS, 4, format = "gams")
## [1] "eqDemand(j,t) ..nt Sum((i), y(i,j,t)) =e= D(j,t) n;n"
Computational Management Science 2016 7/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Solution and Analysis
wProblem(mod1Instance, "mod1.gms", "gams", "lp")
library(gdxrrw)
igdx(" /Programs/gams")
gams("mod1.gms")
importGams(mod1Instance) <- "outSolDeterministic1.gdx"
0
50
100
150
200
0
50
100
150
200
scenario1scenario2
1 2
Period
Units
a
0
1
Available units
profile1 profile2 profile3 profile4
0
50
100
150
200
0
50
100
150
200
0
50
100
150
200
Node3Node4Node5
time2
time3
time4
time5
time2
time3
time4
time5
time2
time3
time4
time5
time2
time3
time4
time5
t
Supply(kWh)
i
PV
Electricity generation
Computational Management Science 2016 8/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Integration
Sweave("comprehensiveExample.Rnw")
library(tools)
texi2pdf("comprehensiveExample.tex")
Computational Management Science 2016 9/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Integration
Sweave("comprehensiveExample.Rnw")
library(tools)
texi2pdf("comprehensiveExample.tex")
Comprehensive Example for “An Integrated
Framework for the Representation and Solution
of Stochastic Energy Optimization Problems”
Emilio L. Cano
January 6, 2014
1 Introduction
This document is an example on how to use R as an integrated environment for
optimization. It is assumed that the optimr package is installed.
Here we can include any statistical analysis, for example a time series analysis
to forecast the future energy prices, saving the values as parameters. We can
also show graphical representations of the parameter values, as in Figure 1, or
tables with data, e.g. Table 1.
100 scenarios simulation
20
40
60
80
2013 2014 2015 2016
Demandlevel(kW)
Energy demand
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
CHPPVRTE
2013 2014 2015 2016 2017
EUR/kW
Investment cost
0.1
0.2
0.3
0.1
0.2
0.3
CHPRTE
2013 2014 2015 2016
EUR/kWh
25
50
75
100
Scenario
Energy price
Figure 1: Parameter values for the stochastic parameters.
The equations or any item of the model can be printed automatically from
the model2SMS object. For example, the following command fetches the objec-
tive function:
> cat("$$", getEq(model2SMS, 6, "tex", only = "rExpr"), "$$")
n∈N
Pn ·
t∈T


i∈I
CI t
i,n · xt
i +
i∈I,j∈J
COt
i,j,n · DTt
j · yt
i,j,n


1
j n t value
1 winter 1 2013 17.06
2 spring 1 2013 21.93
3 summer 1 2013 34.12
4 autumn 1 2013 24.37
5 winter 1 2014 19.89
6 spring 1 2014 25.58
Table 1: Example D parameter values (first 6 values).
2 Solving the problem
Once we have the instance in an optimInstance object, it can be solved and
the solution imported (see source code). Results checking is also possible as this
information is also stored:
We can embed calculations within the text, for example the value of the
objective function (68595), or we can print pretty LATEX tables with the optimal
values, as the ones in Tables 2 and 3, or any other analysis and representation
(see Figure 2). See the .Rnw source file to see the code.
i t value
RTE 2013 45.65
PV 2013 57.65
PV 2014 1.78
Table 2: Optimal values for x
i j n t value
RTE winter 1 2014 2.31
RTE winter 1 2015 4.27
RTE winter 1 2016 8.96
RTE winter 1 2017 7.92
RTE winter 2 2014 1.76
RTE winter 2 2015 5.21
Table 3: Optimal values for y (first 6 values)
3 Conclusion
This document can be compiled at any time, by any researcher. Note that if
any value is changed, for example in the script that contain the parameters
("../data/model2Instance2.R"), the whole report is updated automatically
(including tables, equations and charts). If we use simulation during the re-
search, we can simply fix the seed to allow the verification of the results by
third parties. Different reports for different stakeholders can be produced using
a common structure and tailoring the outputs.
2
0
10
20
30
2013 2014 2015 2016 2017
Year
kW
Technology
RTE
PV
Optimal production plans (Autumn)
Figure 2: Output data representation.
3
Gold Standard
Computational Management Science 2016 9/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
comprehensiveExample.Rnw
 documentclass [ a4paper ]{ a r t i c l e }
 usepackage {Sweave}
 t i t l e { Comprehensive Example f o r
``An I n t e g r a t e d Framework f o r the
R e p r e s e n t a t i o n and S o l u t i o n of S t o c h a s t i c
Energy Optimization Problems ' '}
 author { Emilio L . Cano}
<<i n t r o , echo=FALSE , r e s u l t s=hide>>=
## System r e q u i r e m e n t s
## − The R s o f t w a r e and the packages loaded below
## − A l i c e n c e d GAMS i n s t a l l a t i o n . I f GAMS d i r e c t o r y
## i s other than ”˜/ app/gams23 . 9 ” , change the l i n e
## ' igdx (”˜/ app/gams23 . 9 ”) '
## − A LaTeX d i s t r i b u t i o n f o r the c u r r e n t system
## Load needed packages
l i b r a r y ( k n i t r )
l i b r a r y ( optimr )
l i b r a r y ( gdxrrw )
l i b r a r y ( x t a b l e )
l i b r a r y ( ggplot2 )
l i b r a r y ( g r i d )
## T e l l gdxrrw where GAMS i s i n s t a l l e d
igdx (”˜/ app/gams23 . 9 ”)
## Run s c r i p t s with data
## D e t e r m i n i s t i c model
Computational Management Science 2016 10/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
comprehensiveExample.Rnw (cont.)
source ( ”. / data /model1SMS .R ”)
## S t o c h a s t i c e x t e n s i o n
source ( ”. / data /model2SMS .R ”)
## I n s t a n c e with 100 s c e n a r i o s
source ( ”. / data / model2Instance2 .R ”)
@
 begin {document}
SweaveOpts{ concordance=TRUE}
 m a k e t i t l e
 s e c t i o n { I n t r o d u c t i o n }
This document i s an example on how to use  t e x t s f {R} as an i n t e g r a t e d
environment f o r o p t i m i z a t i o n . I t i s assumed that the  t e x t s f { optimr } package i s
Here we can i n c l u d e any s t a t i s t i c a l a n a l y s i s , f o r example a time s e r i e s a n a l y s i s
to f o r e c a s t the f u t u r e energy p r i c e s , s a v i n g the v a l u e s as parameters . We can
a l s o show g r a p h i c a l r e p r e s e n t a t i o n s of the parameter values , as i n Figure ˜ r e f { f
 begin { f i g u r e }[ htp ]
 begin { c e n t e r }
<<examplepar , f i g=TRUE, echo=FALSE , width=10>>=
## Demand
dtoPlot <− i n s t a n c e P a r s ( model2Instance2 , ”D”)
d t o P l o t $ i d <− 1:20
pD <− ggplot ( data = dtoPlot , aes ( x = id , y = value , group=n , c o l=n ))
pD <− pD + geom path ()
pD <− pD + s c a l e x d i s c r e t e (name = ”” , breaks = seq (1 ,21 , by =5) , l a b e l s = 2013:2
pD <− pD + g g t i t l e ( ”Energy demand ”)
Computational Management Science 2016 11/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
comprehensiveExample.Rnw (cont.)
pD <− pD + s c a l e y c o n t i n u o u s (name =”Demand l e v e l (kW) ”)
pD <− pD + theme ( legend . p o s i t i o n = ”none ”)
pD <− pD + stat summary ( fun . y=mean , c o l o u r =”darkred ”, geom=”l i n e ”, aes ( group =1) ,
## Investment c o s t
dtoPlot <− i n s t a n c e P a r s ( model2Instance2 , ”CI ”)
pCI <− ggplot ( data = dtoPlot , aes ( x = t , y = value , group=n , c o l=n ))
pCI <− pCI + geom path ()
pCI <− pCI + f a c e t g r i d ( i ˜ . )
pCI <− pCI + s c a l e x c o n t i n u o u s (name = ””)
pCI <− pCI + g g t i t l e ( ”Investment c o s t ”)
pCI <− pCI + s c a l e y c o n t i n u o u s (name =”EUR/kW”)
pCI <− pCI + theme ( legend . p o s i t i o n = ”none ”)
pCI <− pCI + stat summary ( fun . y=mean , c o l o u r =”darkred ”, geom=”l i n e ”, aes ( group =1
## Operation c o s t
dtoPlot <− i n s t a n c e P a r s ( model2Instance2 , ”CO”)
d t o P l o t $ i d <− 1:20
pCO <− ggplot ( data = dtoPlot , aes ( x = id , y = value , group=n , c o l=n ))
pCO <− pCO + geom path ()
pCO <− pCO + f a c e t g r i d ( i ˜ . )
pCO <− pCO + s c a l e x d i s c r e t e (name = ”” , breaks = seq (1 ,21 , by =5) , l a b e l s = 2013
pCO <− pCO + g g t i t l e ( ”Energy p r i c e ”)
pCO <− pCO + s c a l e y c o n t i n u o u s (name =”EUR/kWh”)
pCO <− pCO + g u i d e s ( c o l o r = g u i d e c o l o u r b a r ( t i t l e = ”S c e na ri o ”) )
pCO <− pCO + stat summary ( fun . y=mean , c o l o u r =”darkred ”, geom=”l i n e ”, aes ( group =1
g r i d . newpage ()
v p A l l <− viewport ( l a y o u t = g r i d . l a y o u t (2 , 3 ,
widths = c (1/3 , 1/3 , 1/3) ,
Computational Management Science 2016 12/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
comprehensiveExample.Rnw (cont.)
h e i g h t s = c ( 0 . 1 , 0 . 9 ) ) )
vpT <− viewport ( l a y o u t . pos . c o l = 1:3 , l a y o u t . pos . row = 1 , name = ” t i t l e ”)
vpD <− viewport ( l a y o u t . pos . c o l = 1 , l a y o u t . pos . row = 2 , name = ”D”)
vpCI <− viewport ( l a y o u t . pos . c o l = 2 , l a y o u t . pos . row = 2 , name = ”CI ”)
vpCO <− viewport ( l a y o u t . pos . c o l = 3 , l a y o u t . pos . row = 2 , name = ”CO”)
s p l o t <− vpTree ( vpAll , v p L i s t (vpT , vpD , vpCI , vpCO ))
pushViewport ( s p l o t )
seekViewport ( ” t i t l e ”)
g r i d . t e x t (”100 s c e n a r i o s s i m u l a t i o n ”, gp = gpar ( cex =2))
seekViewport ( ”D”)
p r i n t (pD, newpage = FALSE)
seekViewport ( ”CI ”)
p r i n t ( pCI , newpage = FALSE)
seekViewport ( ”CO”)
p r i n t (pCO, newpage = FALSE)
@
 c a p t i o n { Parameter v a l u e s f o r the s t o c h a s t i c parameters .}
 l a b e l { f i g : examplepar }
end{ c e n t e r }
end{ f i g u r e }
<<echo=FALSE , r e s u l t s=tex>>=
x t a b l e ( head ( i n s t a n c e P a r s ( model2Instance2 , ”D”) ) ,
l a b e l = ”tab : exampletable ”,
c a p t i o n = ”Example $D$ parameter v a l u e s ( f i r s t 6 v a l u e s ) . ”)
@
The e q u a t i o n s or any item of the model can be p r i n t e d a u t o m a t i c a l l y from the
Computational Management Science 2016 13/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
comprehensiveExample.Rnw (cont.)
 t e x t s f {model2SMS} o b j e c t . For example , the f o l l o w i n g command f e t c h e s the
o b j e c t i v e f u n c t i o n :
<<r e s u l t s=tex>>=
cat ( ”$$ ”, getEq ( model2SMS , 6 , ”tex ”, only = ”rExpr ”) , ”$$ ”)
@
 s e c t i o n { S o l v i n g the problem }
Once we have the i n s t a n c e i n an  t e x t t t { optimInstance } object , i t can be s o l v e d
<<sol , echo=FALSE , r e s u l t s=hide>>=
wProblem ( model2Instance2 ,
f i l e n a m e = ”. / data / model2Instance2 . gms ”,
format = ”gams ”,
s o l v e r = ”LP ”)
r e s <− gams ( ”. / data / model2Instance2 . gms −−o u t f i l e =./ data / model2Instance2 . gdx ”)
data ( gamsOut )
i f ( r e s == 0){
importGams ( model2Instance2 ) <− ”. / data / model2Instance2 . gdx ”
message ( ”Optimization okn ”,
” tModel Status : ”,
as . c h a r a c t e r ( s u bs e t ( gamsModelStatusCode ,
i d == model2Instance2@result$model , desc , drop = TRUE) ) ,
” n t S o l v e r Status : ”,
as . c h a r a c t e r ( s u bs e t ( gamsSolverStatusCode ,
i d == m o d e l 2 I n s t a n c e 2 @ r e s u l t $ s o l v e , desc , drop = TRUE) ) )
} e l s e {
warning ( ”Check the l i s t i n g f i l e , something was wrong : ”,
s ub s e t ( gamsOutCode , i d == res , desc , drop = TRUE))
Computational Management Science 2016 14/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
comprehensiveExample.Rnw (cont.)
}
@
We can embed c a l c u l a t i o n s w i t h i n the text , f o r example the v a l u e of the
o b j e c t i v e f u n c t i o n ( Sexpr { round ( m o d e l 2 I n s t a n c e 2 @ r e s u l t $ o b j )}) , or we can p r i n t
LaTeX˜ t a b l e s with the optimal values , as the ones i n Tables  r e f { tab : x} and  r e
other a n a l y s i s and r e p r e s e n t a t i o n ( see Figure ˜ r e f { f i g : r e s } ) . See the  t e x t t t {.R
<<r e s u l t s=tex , echo=FALSE>>=
p r i n t ( x t a b l e ( i n s t a n c e V a r s ( model2Instance2 , ”x ”) ,
”Optimal v a l u e s f o r $x$ ”,
”tab : x ”) , i n c l u d e . rownames = FALSE)
p r i n t ( x t a b l e ( head ( i n s t a n c e V a r s ( model2Instance2 , ”y ”) ) ,
”Optimal v a l u e s f o r $y$ ( f i r s t 6 v a l u e s ) ”,
”tab : y ”) , i n c l u d e . rownames = FALSE)
@
 begin { f i g u r e }[ htp ]
 begin { c e n t e r }
<<bar , echo=FALSE , f i g=TRUE>>=
d f 2 p l o t <− s ub s e t ( i n s t a n c e V a r s ( model2Instance2 , ”y ”) , j == ”autumn ”)
d f 2 p l o t <− aggregate ( v a l u e ˜ i + t , data = df2plot , FUN = mean)
d f 2 p l o t $ t <− as . i n t e g e r ( as . c h a r a c t e r ( d f 2 p l o t $ t ))
p <− ggplot ( df2plot , aes ( x=t ))
p <− p + geom area ( aes ( y=value , f i l l =i ))
p <− p + l a b s ( t i t l e = ”Optimal production p l a n s (Autumn ) ”, x = ”Year ”, y = ”kW”)
p <− p + s c a l e f i l l d i s c r e t e ( ”Technology ”)
p r i n t ( p )
@
Computational Management Science 2016 15/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
comprehensiveExample.Rnw (cont.)
end{ c e n t e r }
 c a p t i o n {Output data r e p r e s e n t a t i o n . l a b e l { f i g : r e s }}
end{ f i g u r e }
 s e c t i o n { Conclusion }
This document can be compiled at any time , by any r e s e a r c h e r . Note that i f any
v a l u e i s changed , f o r example i n the s c r i p t that c o n t a i n the parameters
( t e x t t t { ”. . / data / model2Instance2 .R”} ) , the whole r e p o r t i s updated a u t o m a t i c a l l
( i n c l u d i n g t a b l e s , e q u a t i o n s and c h a r t s ) .
I f we use s i m u l a t i o n during the research , we can simply f i x the seed to a l l o w
the v e r i f i c a t i o n of the r e s u l t s by t h i r d p a r t i e s . D i f f e r e n t r e p o r t s f o r d i f f e r e n
end{document}
Computational Management Science 2016 16/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Workflow
Computational Management Science 2016 17/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Outline
1 An Integrated Framework
2 Stochastic Models
3 Conclusions
Computational Management Science 2016 18/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage models
Rolling horizon
In Cano EL, Moguerza JM, Ermolieva T and Ermoliev Y
(2014). “Energy efficiency and risk management in public
buildings: Strategic model for robust planning.”
Computational Management Science, 11, pp. 25-44
Moving random time horizons
In Cano EL, Moguerza JM, Ermolieva T and Ermoliev Y (under
review). “A strategic decision support system framework for
energy-efficient technology investments.” TOP.
Computational Management Science 2016 19/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage instance
Five periods, two technologies (CHP, PV), only electricity.
100 scenarios simulation
20
40
60
80
2013 2014 2015 2016
Demandlevel(kW)
Energy demand
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
CHPPVRTE
2013 2014 2015 2016 2017
EUR/kW
Investment cost
0.1
0.2
0.3
0.1
0.2
0.3
CHPRTE
2013 2014 2015 2016
EUR/kWh
25
50
75
100
Scenario
Energy price
Computational Management Science 2016 20/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage instance
Five periods, two technologies (CHP, PV), only electricity.
100 scenarios simulation
20
40
60
80
2013 2014 2015 2016
Demandlevel(kW)
Energy demand
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
CHPPVRTE
2013 2014 2015 2016 2017
EUR/kW
Investment cost
0.1
0.2
0.3
0.1
0.2
0.3
CHPRTE
2013 2014 2015 2016
EUR/kWh
25
50
75
100
Scenario
Energy price
Fdet (x∗det ) = 66, 920 EUR.
Computational Management Science 2016 20/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage instance
Five periods, two technologies (CHP, PV), only electricity.
100 scenarios simulation
20
40
60
80
2013 2014 2015 2016
Demandlevel(kW)
Energy demand
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
CHPPVRTE
2013 2014 2015 2016 2017
EUR/kW
Investment cost
0.1
0.2
0.3
0.1
0.2
0.3
CHPRTE
2013 2014 2015 2016
EUR/kWh
25
50
75
100
Scenario
Energy price
Fdet (x∗det ) = 66, 920 EUR.
Fsto(x∗sto) = 68, 595 EUR.
Computational Management Science 2016 20/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage instance
Five periods, two technologies (CHP, PV), only electricity.
100 scenarios simulation
20
40
60
80
2013 2014 2015 2016
Demandlevel(kW)
Energy demand
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
CHPPVRTE
2013 2014 2015 2016 2017
EUR/kW
Investment cost
0.1
0.2
0.3
0.1
0.2
0.3
CHPRTE
2013 2014 2015 2016
EUR/kWh
25
50
75
100
Scenario
Energy price
Fdet (x∗det ) = 66, 920 EUR.
Fsto(x∗sto) = 68, 595 EUR.
VSS = Fsto(x∗det ) − Fsto(x∗sto) = ∞
Computational Management Science 2016 20/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage instance
Five periods, two technologies (CHP, PV), only electricity.
100 scenarios simulation
20
40
60
80
2013 2014 2015 2016
Demandlevel(kW)
Energy demand
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
CHPPVRTE
2013 2014 2015 2016 2017
EUR/kW
Investment cost
0.1
0.2
0.3
0.1
0.2
0.3
CHPRTE
2013 2014 2015 2016
EUR/kWh
25
50
75
100
Scenario
Energy price
Fdet (x∗det ) = 66, 920 EUR. Infeasible 56/100
Fsto(x∗sto) = 68, 595 EUR.
VSS = Fsto(x∗det ) − Fsto(x∗sto) = ∞
Computational Management Science 2016 20/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage instance
Five periods, two technologies (CHP, PV), only electricity.
100 scenarios simulation
20
40
60
80
2013 2014 2015 2016
Demandlevel(kW)
Energy demand
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
0
500
1000
1500
2000
2500
CHPPVRTE
2013 2014 2015 2016 2017
EUR/kW
Investment cost
0.1
0.2
0.3
0.1
0.2
0.3
CHPRTE
2013 2014 2015 2016
EUR/kWh
25
50
75
100
Scenario
Energy price
Fdet (x∗det ) = 66, 920 EUR. Infeasible 56/100
Fsto(x∗sto) = 68, 595 EUR. Robust, optimal against all
VSS = Fsto(x∗det ) − Fsto(x∗sto) = ∞
Computational Management Science 2016 20/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Multi-stage model
Complete model with risk
In Cano EL, Moguerza JM and Alonso-Ayuso A (2016). “A
multi-stage stochastic optimization model for energy systems
planning and risk management.” Energy and Buildings, 110,
pp. 49–56.
Reproducible data and code
In Cano EL, Moguerza JM and Alonso-Ayuso A (2015).
“Optimization instances for deterministic and stochastic
problems on energy efficient investments planning at the
building level.” Data in Brief, 5, pp. 805–809.
Computational Management Science 2016 21/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Multi-stage model with risk management
Different objectives: min cost, emissions, or energy use
Risk measure CVaR [Rockafellar and Uryasev (2000)]
Weighted objective function
Computational Management Science 2016 22/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage vs. Multi-stage
Dynamic two-stage
First-stage decisions: strategic
Second-stage decisions: operational
Solution: trajectory, recalculated at each step
Computational Management Science 2016 23/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage vs. Multi-stage
Dynamic two-stage
First-stage decisions: strategic
Second-stage decisions: operational
Solution: trajectory, recalculated at each step
Computational Management Science 2016 23/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage vs. Multi-stage
Dynamic two-stage
First-stage decisions: strategic
Second-stage decisions: operational
Solution: trajectory, recalculated at each step
Multi-stage
First-stage decisions: before branching
2nd -, . . . , nth-stage decisions: after branching
Solution: strategy, recalculated at each step
Computational Management Science 2016 23/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage vs. Multi-stage
Dynamic two-stage
First-stage decisions: strategic
Second-stage decisions: operational
Solution: trajectory, recalculated at each step
Multi-stage
First-stage decisions: before branching
2nd -, . . . , nth-stage decisions: after branching
Solution: strategy, recalculated at each step
Computational Management Science 2016 23/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Two-stage vs. Multi-stage
Dynamic two-stage
First-stage decisions: strategic
Second-stage decisions: operational
Solution: trajectory, recalculated at each step
Multi-stage
First-stage decisions: before branching
2nd -, . . . , nth-stage decisions: after branching
Solution: strategy, recalculated at each step
Computational Management Science 2016 23/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Outline
1 An Integrated Framework
2 Stochastic Models
3 Conclusions
Computational Management Science 2016 24/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Conclusions
Results
Reproducible Research methods in Optimization
The stakeholders dialog viewpoint for DSSs
The optimr library
Comprehensive example demonstrating the framework
Computational Management Science 2016 25/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Conclusions
Results
Reproducible Research methods in Optimization
The stakeholders dialog viewpoint for DSSs
The optimr library
Comprehensive example demonstrating the framework
Further Research
Two-stage vs Multi-stage applicability
New models for energy storage systems
Productize package. Extend to further formats
Explore new reproducible research paths (R Markdown,
interactive visualisation, . . . )
Computational Management Science 2016 25/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Conclusions
Results
Reproducible Research methods in Optimization
The stakeholders dialog viewpoint for DSSs
The optimr library
Comprehensive example demonstrating the framework
Further Research
Two-stage vs Multi-stage applicability
New models for energy storage systems
Productize package. Extend to further formats
Explore new reproducible research paths (R Markdown,
interactive visualisation, . . . )
Links
Publications: http://emilio.lcano.com/content/en/
publicaciones.html
optimr package:
https://github.com/emilopezcano/optimr
Computational Management Science 2016 25/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
DSS Mission
Joseph Kallrath (2012). Algebraic Modeling
Systems, Springer. Chapter 12: A Practioner’s
Wish List Towards Algebraic Modeling Systems
“The automatic generation of a model’s documentation in
LATEX would be very helpful for mathematicians, physicists,
astronomers, and other communities publishing in LATEX.”
Computational Management Science 2016 26/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Acknowledgements
We acknowledge projects:
OPTIMOS3 (MTM2012-36163-C06-06)
GROMA (MTM2015-63710-P)
PPI (RTC-2015-3580-7)
UNIKO (RTC-2015-3521-7)
and the Young Scientists Summer Program (YSSP) at the International Institute
of Applied Systems Analysis (IIASA).
Computational Management Science 2016 27/28
DSS framework
CMS 2016
Emilio L. Cano
An Integrated
Framework
Stochastic
Models
Conclusions
Discussion
Thanks !
emilio.lopez@urjc.es
@emilopezcano
http://emilio.lcano.com
Computational Management Science 2016 28/28

Energy-efficient technology investments using a decision support system framework

  • 1.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Energy-efficient technology investments using a decision support system framework Emilio L. Cano1 Javier M. Moguerza1 Tatiana Ermolieva2 Yurii Yermoliev2 1Rey Juan Carlos University 2International Institute for Applied Systems Analysis (IIASA) Salamanca, May 31 - June 2 2016 Computational Management Science 2016 1/28
  • 2.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Outline 1 An Integrated Framework 2 Stochastic Models 3 Conclusions Computational Management Science 2016 2/28
  • 3.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Outline 1 An Integrated Framework 2 Stochastic Models 3 Conclusions Computational Management Science 2016 3/28
  • 4.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Decision Support Systems Algorithms Model Symbolic model Variables, relations Underlying theory Methodology, technique Uncertainty modelling Data Deterministic data Uncertain data - Stochastic processes Data analysis Solution Data treatment Analysis Visualization DSS Interpretation Computational Management Science 2016 4/28
  • 5.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Decision Support Systems Algorithms Model Symbolic model Variables, relations Underlying theory Methodology, technique Uncertainty modelling Data Deterministic data Uncertain data - Stochastic processes Data analysis Solution Data treatment Analysis Visualization DSS Stakeholders Dialog Interpretation Computational Management Science 2016 4/28
  • 6.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Decision Support Systems Computational Management Science 2016 4/28
  • 7.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions DSS Framework Computational Management Science 2016 5/28
  • 8.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions DSS Framework Requirements Statistical software Data visualization Mathematical modeling Solver input generation Call to the solver Output documentation Computational Management Science 2016 5/28
  • 9.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions DSS Framework Requirements Statistical software Data visualization Mathematical modeling Solver input generation Call to the solver Output documentation Copy-paste Inconsistencies Errors Out-of-date non-reproducible Painful changes Computational Management Science 2016 5/28
  • 10.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions DSS Framework Requirements Statistical software Data visualization Mathematical modeling Solver input generation Call to the solver Output documentation Black box Compiled software for specific solutions Changes require re-programming Not reproducible Computational Management Science 2016 5/28
  • 11.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions DSS Framework Requirements Statistical software Data visualization Mathematical modeling Solver input generation Call to the solver Output documentation Framework Reproducible Research & Literate Programming omptimr R package & Algebraic Modeling Languages (AMLs) “The goal of RR is to tie specific instructions to data analysis and experimental data [and modeling] so that results can be recreated, better understood and verified” “LP: a document that is a combination of content and data analysis code [and models]” Computational Management Science 2016 5/28
  • 12.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions 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. Computational Management Science 2016 6/28
  • 13.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions optimr Package Computational Management Science 2016 7/28
  • 14.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions optimr Package Computational Management Science 2016 7/28
  • 15.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions optimr Package getEq(model1SMS, 4, format = "gams") ## [1] "eqDemand(j,t) ..nt Sum((i), y(i,j,t)) =e= D(j,t) n;n" Computational Management Science 2016 7/28
  • 16.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Solution and Analysis wProblem(mod1Instance, "mod1.gms", "gams", "lp") library(gdxrrw) igdx(" /Programs/gams") gams("mod1.gms") importGams(mod1Instance) <- "outSolDeterministic1.gdx" 0 50 100 150 200 0 50 100 150 200 scenario1scenario2 1 2 Period Units a 0 1 Available units profile1 profile2 profile3 profile4 0 50 100 150 200 0 50 100 150 200 0 50 100 150 200 Node3Node4Node5 time2 time3 time4 time5 time2 time3 time4 time5 time2 time3 time4 time5 time2 time3 time4 time5 t Supply(kWh) i PV Electricity generation Computational Management Science 2016 8/28
  • 17.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Integration Sweave("comprehensiveExample.Rnw") library(tools) texi2pdf("comprehensiveExample.tex") Computational Management Science 2016 9/28
  • 18.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Integration Sweave("comprehensiveExample.Rnw") library(tools) texi2pdf("comprehensiveExample.tex") Comprehensive Example for “An Integrated Framework for the Representation and Solution of Stochastic Energy Optimization Problems” Emilio L. Cano January 6, 2014 1 Introduction This document is an example on how to use R as an integrated environment for optimization. It is assumed that the optimr package is installed. Here we can include any statistical analysis, for example a time series analysis to forecast the future energy prices, saving the values as parameters. We can also show graphical representations of the parameter values, as in Figure 1, or tables with data, e.g. Table 1. 100 scenarios simulation 20 40 60 80 2013 2014 2015 2016 Demandlevel(kW) Energy demand 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 CHPPVRTE 2013 2014 2015 2016 2017 EUR/kW Investment cost 0.1 0.2 0.3 0.1 0.2 0.3 CHPRTE 2013 2014 2015 2016 EUR/kWh 25 50 75 100 Scenario Energy price Figure 1: Parameter values for the stochastic parameters. The equations or any item of the model can be printed automatically from the model2SMS object. For example, the following command fetches the objec- tive function: > cat("$$", getEq(model2SMS, 6, "tex", only = "rExpr"), "$$") n∈N Pn · t∈T   i∈I CI t i,n · xt i + i∈I,j∈J COt i,j,n · DTt j · yt i,j,n   1 j n t value 1 winter 1 2013 17.06 2 spring 1 2013 21.93 3 summer 1 2013 34.12 4 autumn 1 2013 24.37 5 winter 1 2014 19.89 6 spring 1 2014 25.58 Table 1: Example D parameter values (first 6 values). 2 Solving the problem Once we have the instance in an optimInstance object, it can be solved and the solution imported (see source code). Results checking is also possible as this information is also stored: We can embed calculations within the text, for example the value of the objective function (68595), or we can print pretty LATEX tables with the optimal values, as the ones in Tables 2 and 3, or any other analysis and representation (see Figure 2). See the .Rnw source file to see the code. i t value RTE 2013 45.65 PV 2013 57.65 PV 2014 1.78 Table 2: Optimal values for x i j n t value RTE winter 1 2014 2.31 RTE winter 1 2015 4.27 RTE winter 1 2016 8.96 RTE winter 1 2017 7.92 RTE winter 2 2014 1.76 RTE winter 2 2015 5.21 Table 3: Optimal values for y (first 6 values) 3 Conclusion This document can be compiled at any time, by any researcher. Note that if any value is changed, for example in the script that contain the parameters ("../data/model2Instance2.R"), the whole report is updated automatically (including tables, equations and charts). If we use simulation during the re- search, we can simply fix the seed to allow the verification of the results by third parties. Different reports for different stakeholders can be produced using a common structure and tailoring the outputs. 2 0 10 20 30 2013 2014 2015 2016 2017 Year kW Technology RTE PV Optimal production plans (Autumn) Figure 2: Output data representation. 3 Gold Standard Computational Management Science 2016 9/28
  • 19.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions comprehensiveExample.Rnw documentclass [ a4paper ]{ a r t i c l e } usepackage {Sweave} t i t l e { Comprehensive Example f o r ``An I n t e g r a t e d Framework f o r the R e p r e s e n t a t i o n and S o l u t i o n of S t o c h a s t i c Energy Optimization Problems ' '} author { Emilio L . Cano} <<i n t r o , echo=FALSE , r e s u l t s=hide>>= ## System r e q u i r e m e n t s ## − The R s o f t w a r e and the packages loaded below ## − A l i c e n c e d GAMS i n s t a l l a t i o n . I f GAMS d i r e c t o r y ## i s other than ”˜/ app/gams23 . 9 ” , change the l i n e ## ' igdx (”˜/ app/gams23 . 9 ”) ' ## − A LaTeX d i s t r i b u t i o n f o r the c u r r e n t system ## Load needed packages l i b r a r y ( k n i t r ) l i b r a r y ( optimr ) l i b r a r y ( gdxrrw ) l i b r a r y ( x t a b l e ) l i b r a r y ( ggplot2 ) l i b r a r y ( g r i d ) ## T e l l gdxrrw where GAMS i s i n s t a l l e d igdx (”˜/ app/gams23 . 9 ”) ## Run s c r i p t s with data ## D e t e r m i n i s t i c model Computational Management Science 2016 10/28
  • 20.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions comprehensiveExample.Rnw (cont.) source ( ”. / data /model1SMS .R ”) ## S t o c h a s t i c e x t e n s i o n source ( ”. / data /model2SMS .R ”) ## I n s t a n c e with 100 s c e n a r i o s source ( ”. / data / model2Instance2 .R ”) @ begin {document} SweaveOpts{ concordance=TRUE} m a k e t i t l e s e c t i o n { I n t r o d u c t i o n } This document i s an example on how to use t e x t s f {R} as an i n t e g r a t e d environment f o r o p t i m i z a t i o n . I t i s assumed that the t e x t s f { optimr } package i s Here we can i n c l u d e any s t a t i s t i c a l a n a l y s i s , f o r example a time s e r i e s a n a l y s i s to f o r e c a s t the f u t u r e energy p r i c e s , s a v i n g the v a l u e s as parameters . We can a l s o show g r a p h i c a l r e p r e s e n t a t i o n s of the parameter values , as i n Figure ˜ r e f { f begin { f i g u r e }[ htp ] begin { c e n t e r } <<examplepar , f i g=TRUE, echo=FALSE , width=10>>= ## Demand dtoPlot <− i n s t a n c e P a r s ( model2Instance2 , ”D”) d t o P l o t $ i d <− 1:20 pD <− ggplot ( data = dtoPlot , aes ( x = id , y = value , group=n , c o l=n )) pD <− pD + geom path () pD <− pD + s c a l e x d i s c r e t e (name = ”” , breaks = seq (1 ,21 , by =5) , l a b e l s = 2013:2 pD <− pD + g g t i t l e ( ”Energy demand ”) Computational Management Science 2016 11/28
  • 21.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions comprehensiveExample.Rnw (cont.) pD <− pD + s c a l e y c o n t i n u o u s (name =”Demand l e v e l (kW) ”) pD <− pD + theme ( legend . p o s i t i o n = ”none ”) pD <− pD + stat summary ( fun . y=mean , c o l o u r =”darkred ”, geom=”l i n e ”, aes ( group =1) , ## Investment c o s t dtoPlot <− i n s t a n c e P a r s ( model2Instance2 , ”CI ”) pCI <− ggplot ( data = dtoPlot , aes ( x = t , y = value , group=n , c o l=n )) pCI <− pCI + geom path () pCI <− pCI + f a c e t g r i d ( i ˜ . ) pCI <− pCI + s c a l e x c o n t i n u o u s (name = ””) pCI <− pCI + g g t i t l e ( ”Investment c o s t ”) pCI <− pCI + s c a l e y c o n t i n u o u s (name =”EUR/kW”) pCI <− pCI + theme ( legend . p o s i t i o n = ”none ”) pCI <− pCI + stat summary ( fun . y=mean , c o l o u r =”darkred ”, geom=”l i n e ”, aes ( group =1 ## Operation c o s t dtoPlot <− i n s t a n c e P a r s ( model2Instance2 , ”CO”) d t o P l o t $ i d <− 1:20 pCO <− ggplot ( data = dtoPlot , aes ( x = id , y = value , group=n , c o l=n )) pCO <− pCO + geom path () pCO <− pCO + f a c e t g r i d ( i ˜ . ) pCO <− pCO + s c a l e x d i s c r e t e (name = ”” , breaks = seq (1 ,21 , by =5) , l a b e l s = 2013 pCO <− pCO + g g t i t l e ( ”Energy p r i c e ”) pCO <− pCO + s c a l e y c o n t i n u o u s (name =”EUR/kWh”) pCO <− pCO + g u i d e s ( c o l o r = g u i d e c o l o u r b a r ( t i t l e = ”S c e na ri o ”) ) pCO <− pCO + stat summary ( fun . y=mean , c o l o u r =”darkred ”, geom=”l i n e ”, aes ( group =1 g r i d . newpage () v p A l l <− viewport ( l a y o u t = g r i d . l a y o u t (2 , 3 , widths = c (1/3 , 1/3 , 1/3) , Computational Management Science 2016 12/28
  • 22.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions comprehensiveExample.Rnw (cont.) h e i g h t s = c ( 0 . 1 , 0 . 9 ) ) ) vpT <− viewport ( l a y o u t . pos . c o l = 1:3 , l a y o u t . pos . row = 1 , name = ” t i t l e ”) vpD <− viewport ( l a y o u t . pos . c o l = 1 , l a y o u t . pos . row = 2 , name = ”D”) vpCI <− viewport ( l a y o u t . pos . c o l = 2 , l a y o u t . pos . row = 2 , name = ”CI ”) vpCO <− viewport ( l a y o u t . pos . c o l = 3 , l a y o u t . pos . row = 2 , name = ”CO”) s p l o t <− vpTree ( vpAll , v p L i s t (vpT , vpD , vpCI , vpCO )) pushViewport ( s p l o t ) seekViewport ( ” t i t l e ”) g r i d . t e x t (”100 s c e n a r i o s s i m u l a t i o n ”, gp = gpar ( cex =2)) seekViewport ( ”D”) p r i n t (pD, newpage = FALSE) seekViewport ( ”CI ”) p r i n t ( pCI , newpage = FALSE) seekViewport ( ”CO”) p r i n t (pCO, newpage = FALSE) @ c a p t i o n { Parameter v a l u e s f o r the s t o c h a s t i c parameters .} l a b e l { f i g : examplepar } end{ c e n t e r } end{ f i g u r e } <<echo=FALSE , r e s u l t s=tex>>= x t a b l e ( head ( i n s t a n c e P a r s ( model2Instance2 , ”D”) ) , l a b e l = ”tab : exampletable ”, c a p t i o n = ”Example $D$ parameter v a l u e s ( f i r s t 6 v a l u e s ) . ”) @ The e q u a t i o n s or any item of the model can be p r i n t e d a u t o m a t i c a l l y from the Computational Management Science 2016 13/28
  • 23.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions comprehensiveExample.Rnw (cont.) t e x t s f {model2SMS} o b j e c t . For example , the f o l l o w i n g command f e t c h e s the o b j e c t i v e f u n c t i o n : <<r e s u l t s=tex>>= cat ( ”$$ ”, getEq ( model2SMS , 6 , ”tex ”, only = ”rExpr ”) , ”$$ ”) @ s e c t i o n { S o l v i n g the problem } Once we have the i n s t a n c e i n an t e x t t t { optimInstance } object , i t can be s o l v e d <<sol , echo=FALSE , r e s u l t s=hide>>= wProblem ( model2Instance2 , f i l e n a m e = ”. / data / model2Instance2 . gms ”, format = ”gams ”, s o l v e r = ”LP ”) r e s <− gams ( ”. / data / model2Instance2 . gms −−o u t f i l e =./ data / model2Instance2 . gdx ”) data ( gamsOut ) i f ( r e s == 0){ importGams ( model2Instance2 ) <− ”. / data / model2Instance2 . gdx ” message ( ”Optimization okn ”, ” tModel Status : ”, as . c h a r a c t e r ( s u bs e t ( gamsModelStatusCode , i d == model2Instance2@result$model , desc , drop = TRUE) ) , ” n t S o l v e r Status : ”, as . c h a r a c t e r ( s u bs e t ( gamsSolverStatusCode , i d == m o d e l 2 I n s t a n c e 2 @ r e s u l t $ s o l v e , desc , drop = TRUE) ) ) } e l s e { warning ( ”Check the l i s t i n g f i l e , something was wrong : ”, s ub s e t ( gamsOutCode , i d == res , desc , drop = TRUE)) Computational Management Science 2016 14/28
  • 24.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions comprehensiveExample.Rnw (cont.) } @ We can embed c a l c u l a t i o n s w i t h i n the text , f o r example the v a l u e of the o b j e c t i v e f u n c t i o n ( Sexpr { round ( m o d e l 2 I n s t a n c e 2 @ r e s u l t $ o b j )}) , or we can p r i n t LaTeX˜ t a b l e s with the optimal values , as the ones i n Tables r e f { tab : x} and r e other a n a l y s i s and r e p r e s e n t a t i o n ( see Figure ˜ r e f { f i g : r e s } ) . See the t e x t t t {.R <<r e s u l t s=tex , echo=FALSE>>= p r i n t ( x t a b l e ( i n s t a n c e V a r s ( model2Instance2 , ”x ”) , ”Optimal v a l u e s f o r $x$ ”, ”tab : x ”) , i n c l u d e . rownames = FALSE) p r i n t ( x t a b l e ( head ( i n s t a n c e V a r s ( model2Instance2 , ”y ”) ) , ”Optimal v a l u e s f o r $y$ ( f i r s t 6 v a l u e s ) ”, ”tab : y ”) , i n c l u d e . rownames = FALSE) @ begin { f i g u r e }[ htp ] begin { c e n t e r } <<bar , echo=FALSE , f i g=TRUE>>= d f 2 p l o t <− s ub s e t ( i n s t a n c e V a r s ( model2Instance2 , ”y ”) , j == ”autumn ”) d f 2 p l o t <− aggregate ( v a l u e ˜ i + t , data = df2plot , FUN = mean) d f 2 p l o t $ t <− as . i n t e g e r ( as . c h a r a c t e r ( d f 2 p l o t $ t )) p <− ggplot ( df2plot , aes ( x=t )) p <− p + geom area ( aes ( y=value , f i l l =i )) p <− p + l a b s ( t i t l e = ”Optimal production p l a n s (Autumn ) ”, x = ”Year ”, y = ”kW”) p <− p + s c a l e f i l l d i s c r e t e ( ”Technology ”) p r i n t ( p ) @ Computational Management Science 2016 15/28
  • 25.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions comprehensiveExample.Rnw (cont.) end{ c e n t e r } c a p t i o n {Output data r e p r e s e n t a t i o n . l a b e l { f i g : r e s }} end{ f i g u r e } s e c t i o n { Conclusion } This document can be compiled at any time , by any r e s e a r c h e r . Note that i f any v a l u e i s changed , f o r example i n the s c r i p t that c o n t a i n the parameters ( t e x t t t { ”. . / data / model2Instance2 .R”} ) , the whole r e p o r t i s updated a u t o m a t i c a l l ( i n c l u d i n g t a b l e s , e q u a t i o n s and c h a r t s ) . I f we use s i m u l a t i o n during the research , we can simply f i x the seed to a l l o w the v e r i f i c a t i o n of the r e s u l t s by t h i r d p a r t i e s . D i f f e r e n t r e p o r t s f o r d i f f e r e n end{document} Computational Management Science 2016 16/28
  • 26.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Workflow Computational Management Science 2016 17/28
  • 27.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Outline 1 An Integrated Framework 2 Stochastic Models 3 Conclusions Computational Management Science 2016 18/28
  • 28.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage models Rolling horizon In Cano EL, Moguerza JM, Ermolieva T and Ermoliev Y (2014). “Energy efficiency and risk management in public buildings: Strategic model for robust planning.” Computational Management Science, 11, pp. 25-44 Moving random time horizons In Cano EL, Moguerza JM, Ermolieva T and Ermoliev Y (under review). “A strategic decision support system framework for energy-efficient technology investments.” TOP. Computational Management Science 2016 19/28
  • 29.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage instance Five periods, two technologies (CHP, PV), only electricity. 100 scenarios simulation 20 40 60 80 2013 2014 2015 2016 Demandlevel(kW) Energy demand 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 CHPPVRTE 2013 2014 2015 2016 2017 EUR/kW Investment cost 0.1 0.2 0.3 0.1 0.2 0.3 CHPRTE 2013 2014 2015 2016 EUR/kWh 25 50 75 100 Scenario Energy price Computational Management Science 2016 20/28
  • 30.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage instance Five periods, two technologies (CHP, PV), only electricity. 100 scenarios simulation 20 40 60 80 2013 2014 2015 2016 Demandlevel(kW) Energy demand 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 CHPPVRTE 2013 2014 2015 2016 2017 EUR/kW Investment cost 0.1 0.2 0.3 0.1 0.2 0.3 CHPRTE 2013 2014 2015 2016 EUR/kWh 25 50 75 100 Scenario Energy price Fdet (x∗det ) = 66, 920 EUR. Computational Management Science 2016 20/28
  • 31.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage instance Five periods, two technologies (CHP, PV), only electricity. 100 scenarios simulation 20 40 60 80 2013 2014 2015 2016 Demandlevel(kW) Energy demand 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 CHPPVRTE 2013 2014 2015 2016 2017 EUR/kW Investment cost 0.1 0.2 0.3 0.1 0.2 0.3 CHPRTE 2013 2014 2015 2016 EUR/kWh 25 50 75 100 Scenario Energy price Fdet (x∗det ) = 66, 920 EUR. Fsto(x∗sto) = 68, 595 EUR. Computational Management Science 2016 20/28
  • 32.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage instance Five periods, two technologies (CHP, PV), only electricity. 100 scenarios simulation 20 40 60 80 2013 2014 2015 2016 Demandlevel(kW) Energy demand 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 CHPPVRTE 2013 2014 2015 2016 2017 EUR/kW Investment cost 0.1 0.2 0.3 0.1 0.2 0.3 CHPRTE 2013 2014 2015 2016 EUR/kWh 25 50 75 100 Scenario Energy price Fdet (x∗det ) = 66, 920 EUR. Fsto(x∗sto) = 68, 595 EUR. VSS = Fsto(x∗det ) − Fsto(x∗sto) = ∞ Computational Management Science 2016 20/28
  • 33.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage instance Five periods, two technologies (CHP, PV), only electricity. 100 scenarios simulation 20 40 60 80 2013 2014 2015 2016 Demandlevel(kW) Energy demand 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 CHPPVRTE 2013 2014 2015 2016 2017 EUR/kW Investment cost 0.1 0.2 0.3 0.1 0.2 0.3 CHPRTE 2013 2014 2015 2016 EUR/kWh 25 50 75 100 Scenario Energy price Fdet (x∗det ) = 66, 920 EUR. Infeasible 56/100 Fsto(x∗sto) = 68, 595 EUR. VSS = Fsto(x∗det ) − Fsto(x∗sto) = ∞ Computational Management Science 2016 20/28
  • 34.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage instance Five periods, two technologies (CHP, PV), only electricity. 100 scenarios simulation 20 40 60 80 2013 2014 2015 2016 Demandlevel(kW) Energy demand 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 0 500 1000 1500 2000 2500 CHPPVRTE 2013 2014 2015 2016 2017 EUR/kW Investment cost 0.1 0.2 0.3 0.1 0.2 0.3 CHPRTE 2013 2014 2015 2016 EUR/kWh 25 50 75 100 Scenario Energy price Fdet (x∗det ) = 66, 920 EUR. Infeasible 56/100 Fsto(x∗sto) = 68, 595 EUR. Robust, optimal against all VSS = Fsto(x∗det ) − Fsto(x∗sto) = ∞ Computational Management Science 2016 20/28
  • 35.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Multi-stage model Complete model with risk In Cano EL, Moguerza JM and Alonso-Ayuso A (2016). “A multi-stage stochastic optimization model for energy systems planning and risk management.” Energy and Buildings, 110, pp. 49–56. Reproducible data and code In Cano EL, Moguerza JM and Alonso-Ayuso A (2015). “Optimization instances for deterministic and stochastic problems on energy efficient investments planning at the building level.” Data in Brief, 5, pp. 805–809. Computational Management Science 2016 21/28
  • 36.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Multi-stage model with risk management Different objectives: min cost, emissions, or energy use Risk measure CVaR [Rockafellar and Uryasev (2000)] Weighted objective function Computational Management Science 2016 22/28
  • 37.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage vs. Multi-stage Dynamic two-stage First-stage decisions: strategic Second-stage decisions: operational Solution: trajectory, recalculated at each step Computational Management Science 2016 23/28
  • 38.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage vs. Multi-stage Dynamic two-stage First-stage decisions: strategic Second-stage decisions: operational Solution: trajectory, recalculated at each step Computational Management Science 2016 23/28
  • 39.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage vs. Multi-stage Dynamic two-stage First-stage decisions: strategic Second-stage decisions: operational Solution: trajectory, recalculated at each step Multi-stage First-stage decisions: before branching 2nd -, . . . , nth-stage decisions: after branching Solution: strategy, recalculated at each step Computational Management Science 2016 23/28
  • 40.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage vs. Multi-stage Dynamic two-stage First-stage decisions: strategic Second-stage decisions: operational Solution: trajectory, recalculated at each step Multi-stage First-stage decisions: before branching 2nd -, . . . , nth-stage decisions: after branching Solution: strategy, recalculated at each step Computational Management Science 2016 23/28
  • 41.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Two-stage vs. Multi-stage Dynamic two-stage First-stage decisions: strategic Second-stage decisions: operational Solution: trajectory, recalculated at each step Multi-stage First-stage decisions: before branching 2nd -, . . . , nth-stage decisions: after branching Solution: strategy, recalculated at each step Computational Management Science 2016 23/28
  • 42.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Outline 1 An Integrated Framework 2 Stochastic Models 3 Conclusions Computational Management Science 2016 24/28
  • 43.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Conclusions Results Reproducible Research methods in Optimization The stakeholders dialog viewpoint for DSSs The optimr library Comprehensive example demonstrating the framework Computational Management Science 2016 25/28
  • 44.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Conclusions Results Reproducible Research methods in Optimization The stakeholders dialog viewpoint for DSSs The optimr library Comprehensive example demonstrating the framework Further Research Two-stage vs Multi-stage applicability New models for energy storage systems Productize package. Extend to further formats Explore new reproducible research paths (R Markdown, interactive visualisation, . . . ) Computational Management Science 2016 25/28
  • 45.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Conclusions Results Reproducible Research methods in Optimization The stakeholders dialog viewpoint for DSSs The optimr library Comprehensive example demonstrating the framework Further Research Two-stage vs Multi-stage applicability New models for energy storage systems Productize package. Extend to further formats Explore new reproducible research paths (R Markdown, interactive visualisation, . . . ) Links Publications: http://emilio.lcano.com/content/en/ publicaciones.html optimr package: https://github.com/emilopezcano/optimr Computational Management Science 2016 25/28
  • 46.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions DSS Mission Joseph Kallrath (2012). Algebraic Modeling Systems, Springer. Chapter 12: A Practioner’s Wish List Towards Algebraic Modeling Systems “The automatic generation of a model’s documentation in LATEX would be very helpful for mathematicians, physicists, astronomers, and other communities publishing in LATEX.” Computational Management Science 2016 26/28
  • 47.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Acknowledgements We acknowledge projects: OPTIMOS3 (MTM2012-36163-C06-06) GROMA (MTM2015-63710-P) PPI (RTC-2015-3580-7) UNIKO (RTC-2015-3521-7) and the Young Scientists Summer Program (YSSP) at the International Institute of Applied Systems Analysis (IIASA). Computational Management Science 2016 27/28
  • 48.
    DSS framework CMS 2016 EmilioL. Cano An Integrated Framework Stochastic Models Conclusions Discussion Thanks ! emilio.lopez@urjc.es @emilopezcano http://emilio.lcano.com Computational Management Science 2016 28/28