setReadonlyDefaultWorkset {openMpp}R Documentation

Set or clear read-only status for default working set of model parameters

Description

Set or clear read-only status for default working set of model parameters

Usage

setReadonlyDefaultWorkset(dbCon, defRs, isReadonly)

Arguments

dbCon

database connection

defRs

model definition: database rows describing model input parameters and output tables

isReadonly

if TRUE then mark default working set as read-only else clear read-only status

Details

Workset must be NOT read-only in order to update parameters by updateWorksetParameter. And workset must be read-only to run the model, so, typically you want to wrap updateWorksetParameter by setReadonlyDefaultWorkset or setReadonlyWorkset calls.

Workset is a working set of model parameters and can be a full set, which include values of all model parameters or subset and include only some parameters.

Each model must have "default" workset. Default workset is a first workset of the model with set_id = min(set_id) for that model. Default workset always include ALL model parameters (it is a full set).

You must use getModel function in order to find model definition defRs.

Value

Return working set id of default workset or 0L if not found

Note

To run examples you must have modelOne database modelOne.sqlite in current directory

Author(s)

amc1999

References

OpenM++ documentation: https://github.com/openmpp/openmpp.github.io/wiki

See Also

getModel getDefaultWorksetId getWorksetIdByName copyWorksetParameterFromRun setReadonlyWorkset updateWorksetParameter

Examples

  theDb <- dbConnect(RSQLite::SQLite(), "modelOne.sqlite", synchronous = "full")
  invisible(dbGetQuery(theDb, "PRAGMA busy_timeout = 86400")) # recommended
  
  # get model by name: use such call if you have only one version of the model
  defRs <- getModel(theDb, "modelOne")
  
  # reset read-only status of default workset  
  setId <- setReadonlyDefaultWorkset(theDb, defRs, FALSE)
  if (setId <= 0L) stop("no any worksets exists for model: ", defRs$modelDic$model_name, " ", defRs$modelDic$model_digest)

  # you can update model parameters now:
  #
  # updateWorksetParameter(theDb, defRs, setId, ageSex, salaryAge)
  
  # make workset read-only in order to run the model
  setReadonlyDefaultWorkset(theDb, defRs, TRUE)
  
  dbDisconnect(theDb)
  #
  # you can run the model now with new parameters in default workset
  #

[Package openMpp version 0.8.6 Index]