setReadonlyWorkset {openMpp}R Documentation

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

Description

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

Usage

setReadonlyWorkset(dbCon, defRs, isReadonly, worksetId)

Arguments

dbCon

database connection

defRs

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

isReadonly

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

worksetId

id of parameters working set, must be positive integer

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 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: http://ompp.sourceforge.net/wiki/

See Also

getModel getDefaultWorksetId getWorksetIdByName copyWorksetParameterFromRun setReadonlyDefaultWorkset 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 workset  
  setId <- 3L
  if (setReadonlyWorkset(theDb, defRs, FALSE, setId) <= 0L) {
    stop("workset not found: ", setId, " for model: ", defRs$modelDic$model_name, " ", defRs$modelDic$model_digest)
  }
  
  # you can update model parameters now:
  #
  # updateWorksetParameter(theDb, defRs, setId, ageSex)
  
  # make workset read-only in order to run the model
  setReadonlyWorkset(theDb, defRs, TRUE, setId)
  
  dbDisconnect(theDb)
  #
  # you can run the model now with new parameter values in workset id = 3
  #

[Package openMpp version 0.8.1 Index]