826826"""
827827 $(TYPEDSIGNATURES)
828828
829- Convert a time-dependent system `sys` to a time-independent system of nonlinear
830- equations that solve for the steady state of the system where `D(x)` is zero for
831- each continuous variable `x`.
829+ Given a time-dependent system `sys` of ODEs, convert it to a time-independent system of
830+ nonlinear equations that solve for the steady-state of the unknowns. This is done by
831+ replacing every derivative `D(x)` of an unknown `x` with zero. Note that this process
832+ does not retain noise equations, brownian terms, jumps or costs associated with `sys`.
833+ All other information such as defaults, guesses, observed and initialization equations
834+ are retained. The independent variable of `sys` becomes a parameter of the returned system.
835+
836+ If `sys` is hierarchical (it contains subsystems) this transformation will be applied
837+ recursively to all subsystems. The output system will be marked as `complete` if and only
838+ if the input system is also `complete`. This also retains the `split` flag passed to
839+ `complete`.
840+
841+ See also: [`complete`](@ref).
832842"""
833843function NonlinearSystem (sys:: System )
834844 if ! is_time_dependent (sys)
@@ -837,6 +847,9 @@ function NonlinearSystem(sys::System)
837847 eqs = equations (sys)
838848 obs = observed (sys)
839849 subrules = Dict ([D (x) => 0.0 for x in unknowns (sys)])
850+ for var in brownians (sys)
851+ subrules[var] = 0.0
852+ end
840853 eqs = map (eqs) do eq
841854 fast_substitute (eq, subrules)
842855 end
@@ -856,30 +869,68 @@ end
856869# #######
857870
858871"""
859- $(METHODLIST)
872+ $(TYPEDSIGNATURES)
873+
874+ Construct a time-independent [`System`](@ref) for optimizing the specified scalar `cost`.
875+ The system will have no equations.
860876
861- Construct a [`System`](@ref) to solve an optimization problem with the given scalar cost.
877+ Unknowns and parameters of the system are inferred from the cost and other values (such as
878+ defaults) passed to it.
879+
880+ All keyword arguments are the same as those of the [`System`](@ref) constructor.
862881"""
863882function OptimizationSystem (cost; kwargs... )
864883 return System (Equation[]; costs = [cost], kwargs... )
865884end
866885
886+ """
887+ $(TYPEDSIGNATURES)
888+
889+ Identical to the corresponding single-argument `OptimizationSystem` constructor, except
890+ the unknowns and parameters are specified by passing arrays of symbolic variables to `dvs`
891+ and `ps` respectively.
892+ """
867893function OptimizationSystem (cost, dvs, ps; kwargs... )
868894 return System (Equation[], nothing , dvs, ps; costs = [cost], kwargs... )
869895end
870896
897+ """
898+ $(TYPEDSIGNATURES)
899+
900+ Construct a time-independent [`System`](@ref) for optimizing the specified multi-objective
901+ `cost`. The cost will be reduced to a scalar using the `consolidate` function. This
902+ defaults to summing the specified cost and that of all subsystems. The system will have no
903+ equations.
904+
905+ Unknowns and parameters of the system are inferred from the cost and other values (such as
906+ defaults) passed to it.
907+
908+ All keyword arguments are the same as those of the [`System`](@ref) constructor.
909+ """
871910function OptimizationSystem (cost:: Array ; kwargs... )
872911 return System (Equation[]; costs = vec (cost), kwargs... )
873912end
874913
914+ """
915+ $(TYPEDSIGNATURES)
916+
917+ Identical to the corresponding single-argument `OptimizationSystem` constructor, except
918+ the unknowns and parameters are specified by passing arrays of symbolic variables to `dvs`
919+ and `ps` respectively.
920+ """
875921function OptimizationSystem (cost:: Array , dvs, ps; kwargs... )
876922 return System (Equation[], nothing , dvs, ps; costs = vec (cost), kwargs... )
877923end
878924
879925"""
880- $(METHODLIST )
926+ $(TYPEDSIGNATURES )
881927
882- Construct a [`System`](@ref) to solve a system of jump equations.
928+ Construct a [`System`](@ref) to solve a system of jump equations. `jumps` is an array of
929+ jumps, expressed using `JumpProcesses.MassActionJump`, `JumpProcesses.ConstantRateJump`
930+ and `JumpProcesses.VariableRateJump`. It can also include standard equations to simulate
931+ jump-diffusion processes. `iv` should be the independent variable of the system.
932+
933+ All keyword arguments are the same as those of the [`System`](@ref) constructor.
883934"""
884935function JumpSystem (jumps, iv; kwargs... )
885936 mask = isa .(jumps, Equation)
@@ -888,17 +939,42 @@ function JumpSystem(jumps, iv; kwargs...)
888939 return System (eqs, iv; jumps, kwargs... )
889940end
890941
942+ """
943+ $(TYPEDSIGNATURES)
944+
945+ Identical to the 2-argument `JumpSystem` constructor, but uses the explicitly provided
946+ `dvs` and `ps` for unknowns and parameters of the system.
947+ """
891948function JumpSystem (jumps, iv, dvs, ps; kwargs... )
892949 mask = isa .(jumps, Equation)
893950 eqs = Vector {Equation} (jumps[mask])
894951 jumps = jumps[.! mask]
895952 return System (eqs, iv, dvs, ps; jumps, kwargs... )
896953end
897954
955+ # explicitly write the docstring to avoid mentioning `parameter_dependencies`.
898956"""
899- $(METHODLIST)
900-
901- Construct a system of equations with associated noise terms.
957+ SDESystem(eqs::Vector{Equation}, noise, iv; is_scalar_noise = false, kwargs...)
958+
959+ Construct a system of equations with associated noise terms. Instead of specifying noise
960+ using [`@brownians`](@ref) variables, it is specified using a noise matrix `noise`. `iv` is
961+ the independent variable of the system.
962+
963+ In the general case, `noise` should be a `N x M` matrix where `N` is the number of
964+ equations (`length(eqs)`) and `M` is the number of independent random variables.
965+ `noise[i, j]` is the diffusion term for equation `i` and random variable `j`. If the noise
966+ is diagonal (`N == M` and `noise[i, j] == 0` for all `i != j`) it can be specified as a
967+ `Vector` of length `N` corresponding to the diagonal of the noise matrix. As a special
968+ case, if all equations have the same noise then all rows of `noise` are identical. This
969+ is known as "scalar noise". In this case, `noise` can be a `Vector` corresponding to the
970+ repeated row and `is_scalar_noise` must be `true`.
971+
972+ Note that systems created in this manner cannot be used hierarchically. This should only
973+ be used to construct flattened systems. To use such a system hierarchically, it must be
974+ converted to use brownian variables using [`noise_to_brownians`](@ref). [`mtkcompile`](@ref)
975+ will automatically perform this conversion.
976+
977+ All keyword arguments are the same as those of the [`System`](@ref) constructor.
902978"""
903979function SDESystem (eqs:: Vector{Equation} , noise, iv; is_scalar_noise = false ,
904980 parameter_dependencies = Equation[], kwargs... )
@@ -912,6 +988,13 @@ function SDESystem(eqs::Vector{Equation}, noise, iv; is_scalar_noise = false,
912988 @set sys. parameter_dependencies = parameter_dependencies
913989end
914990
991+ """
992+ SDESystem(eqs::Vector{Equation}, noise, iv, dvs, ps; is_scalar_noise = false, kwargs...)
993+
994+
995+ Identical to the 3-argument `SDESystem` constructor, but uses the explicitly provided
996+ `dvs` and `ps` for unknowns and parameters of the system.
997+ """
915998function SDESystem (
916999 eqs:: Vector{Equation} , noise, iv, dvs, ps; is_scalar_noise = false ,
9171000 parameter_dependencies = Equation[], kwargs... )
@@ -925,6 +1008,11 @@ function SDESystem(
9251008 @set sys. parameter_dependencies = parameter_dependencies
9261009end
9271010
1011+ """
1012+ $(TYPEDSIGNATURES)
1013+
1014+ Attach the given noise matrix `noise` to the system `sys`.
1015+ """
9281016function SDESystem (sys:: System , noise; kwargs... )
9291017 SDESystem (equations (sys), noise, get_iv (sys); kwargs... )
9301018end
0 commit comments