gmpl.make.dat.file: Generates a GMPL data file

Description Usage Arguments Examples

View source: R/rgmpl.R

Description

Generates a GMPL data file for the model specified in dat.file sets and param are lists that contain the values of the sets and parameters that are specified in the GMPL model

Usage

1
gmpl.make.dat.file(sets = NULL, param = NULL, mod.file, dat.file = NULL)

Arguments

sets

a list with the sets used by the gmpl model

param

a list with the parameters used by the gmpl model

mod.file

path of the .mod file in which the gmpl model is specified

dat.file

path of the .dat file in which the data shall be written

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Not run: 
  
  # Model of power plant investments and dispatch included in package
  mod.file = paste(.path.package(package = "rgmpl"),"/data/power.mod",sep="")
    
  # Name of dat file, will be generated locally
  dat.file = "power.dat"
  
  # Example data
  
  # Sets
  PLANTS = c("coal","gas")
  PERIODS = 1:4
  sets = list(PLANTS=PLANTS,PERIODS=PERIODS)
  
  # Parameters
  fc = c(12,6)  # fixed cost 
  vc = c(18,30) # variable cost
  load = c(30,50,25,20) # electricity demand
  T = length(PERIODS)
  param = list(vc=vc,fc=fc,load=load,T=T)
  
  # Generate a GMPL .dat file
  gmpl.make.dat.file(sets=sets,param=param,mod.file=mod.file, dat.file=dat.file)
  
  # Solve the model
  res = gmpl.solve(mod.file=mod.file,dat.file=dat.file, delete.lp =FALSE)
  res
  
  # Show production levels graphically
  library(ggplot2)
  qplot(data=res$sol$q, x=PERIODS,y=q,fill=PLANTS,geom="bar",stats="identity", xlab="Period",ylab="Production")
  

## End(Not run)

skranz/rgmpl documentation built on Dec. 15, 2021, 1:49 a.m.