Skip to contents

Prepares the copy of ContinuousTimeSEM.jl that ships inside this ctsem installation. The engine source itself is vendored in inst/julia/ – no repository credentials and no network access are involved in getting that – but its Julia package dependencies still have to be instantiated, which reaches the network on a machine where they are not already cached. That step is consent-gated exactly as in ctJuliaInstall: asked for interactively, skipped with a message when the environment is already instantiated, and declined by default in a non-interactive session unless agree = TRUE or CTSEM_JULIA_AGREE=yes said otherwise in advance.

Usage

ctJuliaSetup(
  project = NULL,
  julia_bin = NULL,
  threads = NULL,
  force = FALSE,
  agree = NULL
)

Arguments

project

Optional local ContinuousTimeSEM.jl checkout to use instead of the copy that ships with ctsem. Rarely needed: the engine is part of ctsem and is edited in place under inst/julia/.

julia_bin

Optional Julia binary directory.

threads

Number of Julia threads, fixed for the life of the session. The engine splits its subject loop across them, and ctFit's cores cannot exceed this count: Julia fixes it at process start, so setting it here takes effect only if no Julia session is running yet – pass force = TRUE to restart one. NULL, the default, starts a session at getOption("mc.cores", 2) threads unless JULIA_NUM_THREADS is set; a session started by a call with a cores argument – a fit, ctFitUncertainty, ctLOO and the rest – is instead as wide as that call's cores, if more. A number given here is also the ceiling for any call that sets none. A fit that asks for more cores than the session has threads says so; see ctFit.

force

Reconfigure an existing Julia session.

agree

TRUE to consent to instantiating the engine's Julia package dependencies without being asked, FALSE to refuse. NULL, the default, asks in an interactive session and refuses otherwise; see ctJuliaInstall.

Value

A Julia-engine status list, invisibly.

Details

The first call downloads and precompiles those dependencies (roughly 120 MB) and compiles the engine, which takes several minutes; later calls in new sessions reuse both.

The engine is compiled in advance, by fitting a small model on each route, and every model of a route runs that same compiled code: a model's sizes, parameters and state-dependent cells are data to the engine rather than part of its types. So the first fit of a new model in a session compiles little, and takes seconds more than later fits rather than minutes. A model with a categorical indicator, or a Laplace unit with more than four random effects, compiles a little more the first time. ctFit(forcerecompile = TRUE) compiles a heavily state-dependent model's expressions for faster gradients, at a minute or more of compile.

Pressing Escape (or Ctrl-C) during a julia fit returns to the R prompt at once, and keeps the Julia session and everything it has compiled. Julia stops the interrupted work at its next iteration; work that has no iterations, such as compiling for a new model shape, finishes in the background. If it is still running when the next julia call starts, that call says so and waits, and Escape during that wait stops Julia outright. ctJuliaProcesses lists the Julia processes ctsem has running, including any left by R sessions that have ended, and ctJuliaKill stops them.

If JuliaConnectoR or Julia itself is missing, this offers to install it rather than failing – the same thing ctJuliaInstall does, which is the function to reach for when setting the backend up deliberately, or from a script.

Examples

if (FALSE) { # \dontrun{
ctJuliaSetup()                         # prepare the engine, asking first
ctJuliaSetup(threads = 8, force = TRUE) # restart the session wider
} # }