From 5219ba4b321b2aeb85af8683aaeea8f3108583ce Mon Sep 17 00:00:00 2001 From: hsonne Date: Wed, 27 Nov 2019 07:40:51 +0100 Subject: [PATCH] Add argument "no.iff" -> switch off iff in gompred The modified version of gompred accepts an additional command line parameter "no-iff". If this parameter is set to "1", the condition probabilities for inspected pipes for are calculated differently. No pipe and age-specific iff values are calculated and the transition matrixes that are used in the Markov Chain are based on the marginal survival curves instead of on the non-marginal survival curves. --- R/gompred.R | 7 +++++-- R/run.R | 7 +++++-- man/runGompitzPrediction.Rd | 5 ++++- man/runGompredInDirectory.Rd | 6 +++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/R/gompred.R b/R/gompred.R index a2d2072..603a1fa 100644 --- a/R/gompred.R +++ b/R/gompred.R @@ -11,6 +11,8 @@ #' @param strategy strategy identifier. Must be one of 0 (do nothing), 1 #' (length-driven strategy), 2 (budget-driven strategy), or 3 (optimised #' strategy).") +#' @param no.iff logical whether to let Gompitz use iff values +#' (\code{no.iff = FALSE}, the default) or not (\code{no.iff = TRUE}) #' @param \dots arguments passed to the corresponding #' \code{.fileContentStrategy} functions, such as \code{range.years} #' (two-element vector with first and last year of prediction), @@ -39,8 +41,8 @@ #' # For an example, see the Tutorial vignette "How to Use the Package" #' runGompitzPrediction <- function( - input.data, subset = NULL, calibration, strategy = 0, ..., verbose = 1, - do.stop = TRUE, clear.observations = TRUE, + input.data, subset = NULL, calibration, strategy = 0, no.iff = FALSE, ..., + verbose = 1, do.stop = TRUE, clear.observations = TRUE, VERSION = getOperatingSystemType(), use.data.table = getOption("kwbGompitz.use.data.table", FALSE) ) @@ -156,6 +158,7 @@ runGompitzPrediction <- function( input.file = paths$input.file, sep = sep, strategy = strategy, + no.iff = no.iff, verbose = verbose, VERSION = VERSION )) diff --git a/R/run.R b/R/run.R index ad5de5d..3db3c05 100644 --- a/R/run.R +++ b/R/run.R @@ -24,17 +24,19 @@ runGompcalInDirectory <- function( #' @param input.file path to input file #' @param sep column separator #' @param strategy integer number specifying the strategy to be applied +#' @param no.iff logical whether to let Gompitz use iff values +#' (\code{no.iff = FALSE}, the default) or not (\code{no.iff = TRUE}) #' @param \dots arguments that are passed to .runModuleInDirectory, such as #' \code{verbose} or \code{show.error} #' runGompredInDirectory <- function( target.dir = tempdir(), input.file = exampleFile("obs.txt"), sep = ";", - strategy = 0, ... + strategy = 0, no.iff = FALSE, ... ) { error_code <- .runModuleInDirectory( "gompred", target.dir, input.file, sep, ..., - options = as.character(strategy) + options = c(as.character(strategy), if (no.iff) "1" else NULL) ) # Check the output for an error message @@ -140,6 +142,7 @@ open_file_if_not_on_unix <- function(file) files <- file.path("log", sprintf("%s_%s.txt", module, c("out", "err"))) .catLogMessageIf(verbose > 1, sprintf("command: '%s'\n", command)) + kwb.utils::printIf(verbose > 1, args) error_code <- system2(command, args, stdout = files[1], stderr = files[2]) diff --git a/man/runGompitzPrediction.Rd b/man/runGompitzPrediction.Rd index 322cdb3..5a6bc0d 100644 --- a/man/runGompitzPrediction.Rd +++ b/man/runGompitzPrediction.Rd @@ -5,7 +5,7 @@ \title{Run Gompitz Predicion} \usage{ runGompitzPrediction(input.data, subset = NULL, calibration, - strategy = 0, ..., verbose = 1, do.stop = TRUE, + strategy = 0, no.iff = FALSE, ..., verbose = 1, do.stop = TRUE, clear.observations = TRUE, VERSION = getOperatingSystemType(), use.data.table = getOption("kwbGompitz.use.data.table", FALSE)) } @@ -23,6 +23,9 @@ if \code{NULL}, all rows in \code{input.data} will be used.} (length-driven strategy), 2 (budget-driven strategy), or 3 (optimised strategy).")} +\item{no.iff}{logical whether to let Gompitz use iff values +(\code{no.iff = FALSE}, the default) or not (\code{no.iff = TRUE})} + \item{\dots}{arguments passed to the corresponding \code{.fileContentStrategy} functions, such as \code{range.years} (two-element vector with first and last year of prediction), diff --git a/man/runGompredInDirectory.Rd b/man/runGompredInDirectory.Rd index 6f9026a..309ce9f 100644 --- a/man/runGompredInDirectory.Rd +++ b/man/runGompredInDirectory.Rd @@ -5,7 +5,8 @@ \title{Run gompred.exe in given Directory} \usage{ runGompredInDirectory(target.dir = tempdir(), - input.file = exampleFile("obs.txt"), sep = ";", strategy = 0, ...) + input.file = exampleFile("obs.txt"), sep = ";", strategy = 0, + no.iff = FALSE, ...) } \arguments{ \item{target.dir}{path to target directory} @@ -16,6 +17,9 @@ runGompredInDirectory(target.dir = tempdir(), \item{strategy}{integer number specifying the strategy to be applied} +\item{no.iff}{logical whether to let Gompitz use iff values +(\code{no.iff = FALSE}, the default) or not (\code{no.iff = TRUE})} + \item{\dots}{arguments that are passed to .runModuleInDirectory, such as \code{verbose} or \code{show.error}} }