update_SimInput: Update simulation xml input files.

View source: R/update_SimInput.R

update_SimInputR Documentation

Update simulation xml input files.

Description

This function takes an xml input file for the simulator and updates it according to the set of new parameters specified in the input parameter list newParam. The schema definition of the xml file is also required as an input parameter to validate the structure of the output file.

Usage

update_SimInput(xmlSimInput, newParam, xsdName, newFileName = NULL)

Arguments

xmlSimInput

Object of class xml_document from package xml2 or of class character specifying the path of the simulation input xml file to update.

newParam

list with the new values of the parameters to be updated

xsdName

character of length 1 with the name of xsd file containing the schema definition of the xml input file.

newFileName

character of length 1 with the name of the updated xml input file.

Details

Return an xml-document object of package xml2 with the parameters updated according to the specified input parameters. If newFileName is specified, this object is written in the corresponding xml file.

Examples

library(fs)
rootPath <- system.file(package = "simutils")
xmlSimInput <- file.path(rootPath, "extdata/input_files", "simulation.xml")
newParam.lst <- list(
  end_time = 11,
  movement_pattern = structure(list(
    manhattan_grid = structure(
      list(x_step = 40, y_step = 40, x_origin = 0, y_origin = 0),
      type = "home_work_manhattan"
    )
  ))
)
xsdName <- file.path(
  rootPath,
  "extdata/metadata/input_files/schema_definition", "simulation_dict.xsd"
)
newSimInputFile <- file.path(path_home(), "newSimulation.xml")
update_SimInput(
  xmlSimInput = xmlSimInput,
  newParam = newParam.lst,
  xsdName = xsdName,
  newFileName = newSimInputFile
)


bogdanoancea/simutils documentation built on April 4, 2022, 2:58 p.m.