An integrated Solver Manager: useR! 2013 using R and Python for - - PowerPoint PPT Presentation

an integrated solver manager
SMART_READER_LITE
LIVE PREVIEW

An integrated Solver Manager: useR! 2013 using R and Python for - - PowerPoint PPT Presentation

Energy Systems Planning An integrated Solver Manager: useR! 2013 using R and Python for energy systems Emilio L. Cano Introduction optimization Motivation DSS Solver Manager Architecture Components Emilio L. Cano 1 Antonio Alonso Ayuso 1


slide-1
SLIDE 1

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

An integrated Solver Manager: using R and Python for energy systems

  • ptimization

Emilio L. Cano1 Antonio Alonso Ayuso1 Javier M. Moguerza1 Felipe Ortega1

1DEIO, Universidad Rey Juan Carlos, Madrid

The R user Conference 2013

Albacete July 10-12 2013

The R User Conference 2013 1/27

slide-2
SLIDE 2

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Outline

1

Introduction Motivation DSS

2

Solver Manager Architecture Components

3

Example A simplified model Model instance Solution

The R User Conference 2013 2/27

slide-3
SLIDE 3

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Outline

1

Introduction Motivation DSS

2

Solver Manager Architecture Components

3

Example A simplified model Model instance Solution

The R User Conference 2013 3/27

slide-4
SLIDE 4

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Global changes, local challenges

Global

Regulations: emissions, efficiency De-regulations: market Global warming Resources scarcity Global markets

Local

Users’ confort Security Availability Limited budget New options

The R User Conference 2013 4/27

slide-5
SLIDE 5

Building systems enery flow: Sankey diagram

slide-6
SLIDE 6

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Decision Support Systems

The R User Conference 2013 6/27

slide-7
SLIDE 7

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

EnRiMa DSS

The R User Conference 2013 7/27

slide-8
SLIDE 8

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Outline

1

Introduction Motivation DSS

2

Solver Manager Architecture Components

3

Example A simplified model Model instance Solution

The R User Conference 2013 8/27

slide-9
SLIDE 9

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

DSS Integration

The R User Conference 2013 9/27

slide-10
SLIDE 10

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Solver Manager

The R User Conference 2013 10/27

slide-11
SLIDE 11

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

SM Interface - overview

The SM Interface allows to separate communication tasks and other interaction features from the core features of the Solver Manager

The R User Conference 2013 11/27

slide-12
SLIDE 12

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

SM Interface (Python)

Model Tasks Data Interaction Logs

The R User Conference 2013 12/27

slide-13
SLIDE 13

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Solver Manager core script

Instance checking Input data preparation Call to the Optimiser Result checking Output data preparation Control and log

Libraries

  • ptimr:
  • ptimSMS and
  • ptimInstance S4
  • bjects

gdxrrw: GAMS Interface

The R User Conference 2013 13/27

slide-14
SLIDE 14

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Solver Manager process flow

The R User Conference 2013 14/27

slide-15
SLIDE 15

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Outline

1

Introduction Motivation DSS

2

Solver Manager Architecture Components

3

Example A simplified model Model instance Solution

The R User Conference 2013 15/27

slide-16
SLIDE 16

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Optimization model

min

  • t∈T
  • i∈I

CI t

i · x t i +

  • i∈I,j∈J

COt

i,j · DT t j · yt i,j

  • s.t. :

st

i = st−1 i

+ x t

i − x t−LT i i

∀ i ∈ I, t ∈ T

  • i∈I

yt

i,j = Dt j

∀ j ∈ J , t ∈ T yt

i,j ≤ Gt i,j · st i

∀ i ∈ I, j ∈ J , t ∈ T

The R User Conference 2013 16/27

slide-17
SLIDE 17

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Symbolic Model Specification

showClass("optimSMS") ## Class "optimSMS" [package "optimr"] ## ## Slots: ## ## Name: consts sets vars pars ## Class: data.frame data.frame data.frame data.frame ## ## Name: eqs terms name sDes ## Class: data.frame data.frame character character ## ## Name: lDes ## Class: character data(mod1SMS)

The R User Conference 2013 17/27

slide-18
SLIDE 18

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

SMS Sets and Variables

SMSsets(mod1SMS) ## id symbol tag sDes lDes loc inSet setType dataCom ## 1 1 i NA Technology NA sub NA set NA ## 2 2 j NA Period NA sub NA set NA ## 3 3 t NA Year NA sup NA set NA ##

  • rdered setDom

## 1 NA NA ## 2 NA NA ## 3 NA NA SMSvars(mod1SMS)[, c(1:4, 11)] ## id symbol tag sDes ind ## 1 1 x NA Capacity to be installed 1, 3 ## 2 2 y NA Production plan 1, 2, 3 ## 3 3 s NA Available capacity 1, 3 ## 4 4 z NA Total cost NULL

The R User Conference 2013 18/27

slide-19
SLIDE 19

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

SMS parameters and expressions

SMSpars(mod1SMS)[, c(1:4, 7, 12)] ## id symbol tag sDes units ind ## 1 1 LT NA Lifetime years 1 ## 2 2 D NA Demand Level kW 2, 3 ## 3 3 G NA Technology Availability kW/kW 1, 2, 3 ## 4 4 CI NA Investment Cost EUR/kW 1, 3 ## 5 5 CO NA Operational Cost EUR/kWh 1, 2, 3 ## 6 6 DT NA Duration time of period hours 2, 3 getExpr(mod1SMS, "vars", 2, "gams") ## [1] "y(i,j,t)"

The R User Conference 2013 19/27

slide-20
SLIDE 20

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

SMS equations

SMSeqs(mod1SMS)[1:4, c(1, 2, 5, 6, 7)] ## id symbol lDes nature relation ## 1 1 aux1 NA aux eq ## 2 2 aux2 NA aux eq ## 3 3 eqAvail NA constraint eq ## 4 4 eqDemand NA constraint eq mod1SMS@terms[1:4, c(1, 6:10)] ## id eq side parent nature item ## 1 1 1 l NA sets 3 ## 2 2 1 r sets 3 ## 3 3 1 r 0 consts 1 ## 4 1 2 l NA sets 3 getEq(mod1SMS, 5, "tex") ## [1] " \\mathit{y}_{i,j}^{t} \\leq \\mathit{G}_{i,j}^{t} \\cdot

The R User Conference 2013 20/27

slide-21
SLIDE 21

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Optimization Instance

showClass("optimInstance") ## Class "optimInstance" [package "optimr"] ## ## Slots: ## ## Name: id name sDes lDes sets ## Class: integer character character character list ## ## Name: vars pars eqs sms ## Class: list list list

  • ptimSMS

The R User Conference 2013 21/27

slide-22
SLIDE 22

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Instance data

names(mod1Instance@pars) ## [1] "LT" "CI" "D" "G" "DT" "CO" head(instancePars(mod1Instance, "CI"), 4) ## i t value ## 1 PV 2013 700 ## 2 CHP 2013 1182 ## 3 PV 2014 490 ## 4 CHP 2014 1123 instanceSets(mod1Instance, "i") ## [1] "RTE" "PV" "CHP"

The R User Conference 2013 22/27

slide-23
SLIDE 23

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Getting the solution

setwd("~/gamsdir") wProblem(mod1Instance, "mod1.gms", "gams", "lp") library(gdxrrw) igdx("~/Programs/gams") ## The GDX library has been loaded ## GDX library load path: /home/emilio/Programs/gams gams("mod1.gms") ## [1] 0 importGams(mod1Instance) <- "outSolDeterministic1.gdx" instanceVars(mod1Instance, "x") ## i t value ## 1 RTE 2013 6.30 ## 2 PV 2015 17.50 ## 3 PV 2016 1.75 ## 4 CHP 2013 1.40

The R User Conference 2013 23/27

slide-24
SLIDE 24

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Late motivation

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 L

AT

EX would be very helpful for mathematicians, physicists, astronomers, and other communities publishing in L

AT

EX.”

The R User Conference 2013 24/27

slide-25
SLIDE 25

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Summary

New challenges for building managers. Decision Support Systems are needed. Solver Manager: flexible and extensible.

The R User Conference 2013 25/27

slide-26
SLIDE 26

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Summary

New challenges for building managers. Decision Support Systems are needed. Solver Manager: flexible and extensible. Outlook

Improve optimr package More complex instances More modeling and optimization softwares, solvers, alogorithms and benchmarking.

The R User Conference 2013 25/27

slide-27
SLIDE 27

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Acknowledgements

This work has been partially funded by the project Energy Efficiency and Risk Management in Public Buildings (EnRiMa) EC’s FP7 project (number 260041)

We also acknowledge the projects:

OPTIMOS3 (MTM2012-36163-C06-06) Project RIESGOS-CM: code S2009/ESP-1685 HAUS: IPT-2011-1049-430000 EDUCALAB: IPT-2011-1071-430000 DEMOCRACY4ALL: IPT-2011-0869-430000 CORPORATE COMMUNITY: IPT-2011-0871-430000 CONTENT & INTELIGENCE: IPT-2012-0912-430000 and the Young Scientists Summer Program (YSSP) at the International Institute of Applied Systems Analysis (IIASA).

The R User Conference 2013 26/27

slide-28
SLIDE 28

Energy Systems Planning useR! 2013 Emilio L. Cano Introduction

Motivation DSS

Solver Manager

Architecture Components

Example

A simplified model Model instance Solution

Discussion

Thanks !

emilio.lopez@urjc.es

@emilopezcano http://www.proyectum.es

The R User Conference 2013 27/27