Skip to contents

WorkPrecisionSet(prob, abstols, reltols, setups) runs WorkPrecision() for each setup (a list with the algorithm alg and optionally its own abstols, reltols, dts, a name, tags, auto_tags, prob_choice and solver options), with the options in ... (appxsol, error_estimate, numruns, seconds, timeout, names, print_names and solver options). With error_estimates, a vector of error names, the errors needed by all of them are computed in the same runs; available_errors(set) lists them.

Usage

WorkPrecisionSet(
  prob,
  abstols,
  reltols,
  setups,
  test_dt = NULL,
  ...,
  p = NULL,
  abstol = NULL,
  reltol = NULL
)

available_errors(wp_set)

# S3 method for class 'WorkPrecisionSet'
plot(
  x,
  y = "times",
  xvar = x$error_estimate,
  view = "benchmark",
  col = NULL,
  tags = NULL,
  include_tags = NULL,
  exclude_tags = NULL,
  reference_tags = NULL,
  reference_style = list(lty = 2, lwd = 1, alpha = 0.5),
  legend_pos = "topright",
  ...
)

Arguments

prob

The problem (a list of problems with prob_choice), or for the fields form the list of WorkPrecisions.

abstols, reltols

Tolerances.

setups

List of setups.

test_dt

Time step of the Brownian grid of reference solutions.

...

Options, see Details.

p

The solver option p, named in the signature so that it does not partially match prob.

abstol, reltol

Ignored: each run uses its own tolerances.

wp_set

A WorkPrecisionSet.

x

A WorkPrecisionSet.

y, xvar

Keys of the vertical and horizontal axes.

view

"benchmark" or "dt_convergence".

col

Colors of the entries.

tags, include_tags, exclude_tags, reference_tags

Tag selection.

reference_style

Line type, width and transparency of references.

legend_pos

Position of the legend.

Value

A WorkPrecisionSet: a list with wps, N, abstols, reltols, prob, setups, names, error_estimate, numruns and active_error_estimates; available_errors() returns error names.

Details

For an SDE or RODE problem the errors are means over numruns_error runs (against the analytic solution, or against a reference solved with appxsol_setup on a Brownian grid of step test_dt), and the times are the means of numruns runs. For an EnsembleProblem() the errors are weak errors of trajectories paths (with ensemblealg): against expected_value (weak_final or weak_l2) or against the ensemble solved with appxsol_setup.

WorkPrecisionSet(wps, N, abstols, reltols, prob, setups, names, error_estimate, numruns, active_error_estimates) builds one from its fields.

length(set) is the number of entries and set[[i]] the ith WorkPrecision. plot(set) draws the time (y) against the error (xvar, the error estimate by default) of every entry on log scales; xvar and y may also name tolerances ("abstols", "reltols"), "times", "dts", an error or a field of the solver statistics. The options tags, include_tags and exclude_tags select entries, reference_tags draws the entries with those tags as thin dashed references, and view = "dt_convergence" draws the errors against the time steps with fitted orders.

Examples

fn <- ODEFunction(function(u, p, t) -u, analytic = function(u0, p, t) u0 * exp(-t))
prob <- ODEProblem(fn, 1, c(0, 1))
setups <- list(list(alg = Euler(), dts = c(1 / 8, 1 / 16)),
  list(alg = RK4(), dts = c(1 / 4, 1 / 8)))
set <- WorkPrecisionSet(prob, c(1e-3, 1e-4), c(1e-3, 1e-4), setups, numruns = 1,
  error_estimates = c("final", "l2"))
available_errors(set)
#> [1] "final" "l2"   
set[[2]]$errors$l2
#> [1] 9.743296e-06 1.079371e-06