% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
\name{simulate.stockflow}
\alias{simulate.stockflow}
\title{Simulate stock-and-flow model}
\usage{
\method{simulate}{stockflow}(object, nsim = 1, seed = NULL, quiet = FALSE, ...)
}
\arguments{
\item{object}{Stock-and-flow model, object of class \code{\link{stockflow}}.}

\item{nsim}{Number of simulations to run (unused; see \code{\link[=ensemble]{ensemble()}} for running multiple simulations).}

\item{seed}{Seed number to ensure reproducibility across runs in case of
random elements. Must be an integer. Defaults to \code{NULL} (no seed).}

\item{quiet}{If \code{TRUE}, suppress informational messages such as progress and status updates. Warnings and errors are always shown. Defaults to \code{FALSE}.}

\item{...}{Optional arguments passed to \code{\link[=sim_settings]{sim_settings()}}; these can be used to override the simulation specifications set in the model object.}
}
\value{
Object of class \code{\link[=simulate.stockflow]{simulate_stockflow}}, a list containing:
\describe{
\item{object}{Stock-and-flow model object of class \code{\link{stockflow}}}
\item{df}{Data frame: simulation results (time, variable, value)}
\item{init}{Named vector: initial stock values}
\item{constants}{Named vector: constant parameters}
\item{script}{Character: generated simulation code (R or Julia)}
\item{duration}{Numeric: simulation time in seconds}
\item{success}{Logical: TRUE if completed without errors}
\item{error_message}{NULL if completed without errors}
}

Use \link[=as.data.frame.simulate_stockflow]{as.data.frame()} to extract results, \link[=plot.simulate_stockflow]{plot()} to visualize.
}
\description{
Simulate a stock-and-flow model with simulation specifications defined by \code{\link[=sim_settings]{sim_settings()}}. If \code{sim_settings(language = "julia")}, the Julia environment will first be set up with \code{\link[=use_julia]{use_julia()}}. If any problems are detected by \code{\link[=summary]{summary()}}, the model cannot be simulated.
}
\examples{
sfm <- stockflow("sir")
sim <- simulate(sfm)
plot(sim)

# Obtain all model variables
sim <- simulate(sim_settings(sfm, only_stocks = FALSE))
plot(sim, show_constants = TRUE)

}
\seealso{
\code{\link[=update]{update()}}, \code{\link[=stockflow]{stockflow()}}, \code{\link[=summary]{summary()}}, \code{\link[=sim_settings]{sim_settings()}}, \code{\link[=use_julia]{use_julia()}}
}
\concept{simulate}
