Skip to contents

InitializationProblem(sys, t, op) builds the nonlinear problem whose solution is a consistent set of initial values for sys at time t: the initialization system of generate_initializesystem() is simplified (explicit equations become observed) and wrapped in the problem type ModelingToolkit chooses: a LinearProblem() when the equations are affine in the unknowns and there are at least as many equations as unknowns (solved in the least squares sense when overdetermined), an SCCNonlinearProblem() when it is square and structurally nonsingular (with use_scc = FALSE a HomotopyProblem() if it contains homotopy() nodes and a NonlinearProblem() otherwise), and a NonlinearLeastSquaresProblem() for under and overdetermined systems. use_homotopy_continuation = TRUE asks for a HomotopyContinuationProblem() of a square polynomial system instead, which finds every real root and keeps the one closest to the guesses. Underdetermined, overdetermined and singular systems give a warning, or an error with fully_determined = TRUE.

Usage

InitializationProblem(
  sys,
  t = NULL,
  op = list(),
  guesses = list(),
  initialization_eqs = list(),
  fully_determined = NULL,
  warn_initialize_determined = TRUE,
  missing_guess_value = NULL,
  algebraic_only = FALSE,
  time_dependent_init = !is.null(get_iv(sys)),
  jac = TRUE,
  use_scc = TRUE,
  use_homotopy_continuation = FALSE,
  ...
)

Arguments

sys

A complete System.

t

The initial time; NULL for time independent systems.

op

Operating point: initial conditions and parameter values.

guesses

Further guesses.

initialization_eqs

Further initialization equations.

fully_determined

TRUE turns the warnings about systems that are not fully determined into errors.

warn_initialize_determined

FALSE silences those warnings.

missing_guess_value

Fallback for unknowns without a guess; the default is MissingGuessValue$HashedRandom().

algebraic_only

Ignore the initialization equations of the system.

time_dependent_init

Solve for the unknowns too (the default for time dependent systems), or only for solvable parameters.

jac

Generate the symbolic Jacobian.

use_scc

Solve a square system block by block.

use_homotopy_continuation

Solve a square polynomial system by homotopy continuation.

...

Solver options stored with the problem.

Value

A LinearProblem, SCCNonlinearProblem, NonlinearProblem, HomotopyProblem, HomotopyContinuationProblem or NonlinearLeastSquaresProblem whose system is the compiled initialization system.

Details

The same choices apply to the initialization that ODEProblem() and the other problem constructors run: pass use_scc and use_homotopy_continuation to them.

ODEProblem() builds and solves this problem itself; this constructor is for inspecting initialization. Solve the result with solve(), and index the solution with the variables of sys.

Examples

t <- t_nounits; D <- D_nounits
x <- Variable("x", t); y <- Variable("y", t)
sys <- mtkcompile(System(list(D(x) ~ -x + y, 0 ~ x^2 + y^2 - 1), t, name = "dae"))
iprob <- InitializationProblem(sys, 0, list(x ~ 0.6), guesses = list(y ~ 1))
class(iprob)[1]
#> [1] "SCCNonlinearProblem"
sol <- solve(iprob)
sol[y]
#> [1] 0.8