% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/net.fn.utils.R
\name{make_restart_point}
\alias{make_restart_point}
\title{Make a Lightweight Restart Point From a \code{netsim} Object with tergmLite}
\usage{
make_restart_point(sim_obj, time_attrs, sim_num = 1, keep_steps = 1)
}
\arguments{
\item{sim_obj}{a \code{netsim} object from an ended \code{netsim} call.}

\item{time_attrs}{a \code{character} vector containing the names of the attributes
that are expressed in time-steps. These will be offsetted so the last
step in the original simulation become the step 1 (default) in the new
ones. If no such attributes exist, pass \code{c()}.}

\item{sim_num}{the number of the simulation to extract from the \code{netsim}
object (default = 1).}

\item{keep_steps}{The number of simulation steps to keep from the previous
run. By default only keep one but more is possible if some
back-history is wanted.}
}
\value{
a trimed \code{netsim} object with only one simulation that is ready to be
used as a restart point.
}
\description{
Extract the elements required for re-initializing a \code{netsim} simulation from
a completed simulation. This function also resets the Unique IDs and Time
values to reduce the size of the simulation. This function only works for
simulations where \code{control$tergmLite = TRUE}
}
\details{
The restart point created always contains a single simulation and drops the
\code{attr.history}, the \code{raw.records} and \code{stats} from the initial simulation.

The epi trackers, cumulative edgelists, transmission matrix and \code{nwstats} are
truncated to only contain the last \code{keep_steps} entries.

Warning: the \code{time_attrs} argument is mandatory. Almost all simulation worth
restarting have such attributes (e.g. time.of.hiv.infection). If no such
argument exists, passing \code{c()} will allow the function to run while ensuring
that this was done on purpose.

When restarting from the output of this function, it is suggested to express
the time steps in a relative maner in \code{control.net}:

\if{html}{\out{<div class="sourceCode">}}\preformatted{control.net(
  start = restart_point$control$nsteps + 1),
  nsteps = restart_point$control$nsteps + 1 + 104)
)
}\if{html}{\out{</div>}}
}
\examples{
\dontrun{
# With  pre-existing `sim`, `param` and `init` object (see `netsim`)

# List all attributes that store a time step
time_attrs <- c(
  "inf.time",
  "stage.time",
  "aids.time",
  "prep.start.last"
)
# Make a restart point a re-run for 10 more timesteps
x <- make_restart_point(sim, time_attrs, sim_num = 1, keep_steps = 1)
control <- control_msm(
  start = x$control$nsteps + 1,
  nsteps = x$control$nsteps + 1 + 10
)
sim <- netsim(x, param, init, control)
}

}
