826
826
"""
827
827
$(TYPEDSIGNATURES)
828
828
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).
832
842
"""
833
843
function NonlinearSystem (sys:: System )
834
844
if ! is_time_dependent (sys)
@@ -837,6 +847,9 @@ function NonlinearSystem(sys::System)
837
847
eqs = equations (sys)
838
848
obs = observed (sys)
839
849
subrules = Dict ([D (x) => 0.0 for x in unknowns (sys)])
850
+ for var in brownians (sys)
851
+ subrules[var] = 0.0
852
+ end
840
853
eqs = map (eqs) do eq
841
854
fast_substitute (eq, subrules)
842
855
end
@@ -856,30 +869,68 @@ end
856
869
# #######
857
870
858
871
"""
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.
860
876
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.
862
881
"""
863
882
function OptimizationSystem (cost; kwargs... )
864
883
return System (Equation[]; costs = [cost], kwargs... )
865
884
end
866
885
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
+ """
867
893
function OptimizationSystem (cost, dvs, ps; kwargs... )
868
894
return System (Equation[], nothing , dvs, ps; costs = [cost], kwargs... )
869
895
end
870
896
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
+ """
871
910
function OptimizationSystem (cost:: Array ; kwargs... )
872
911
return System (Equation[]; costs = vec (cost), kwargs... )
873
912
end
874
913
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
+ """
875
921
function OptimizationSystem (cost:: Array , dvs, ps; kwargs... )
876
922
return System (Equation[], nothing , dvs, ps; costs = vec (cost), kwargs... )
877
923
end
878
924
879
925
"""
880
- $(METHODLIST )
926
+ $(TYPEDSIGNATURES )
881
927
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.
883
934
"""
884
935
function JumpSystem (jumps, iv; kwargs... )
885
936
mask = isa .(jumps, Equation)
@@ -888,17 +939,42 @@ function JumpSystem(jumps, iv; kwargs...)
888
939
return System (eqs, iv; jumps, kwargs... )
889
940
end
890
941
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
+ """
891
948
function JumpSystem (jumps, iv, dvs, ps; kwargs... )
892
949
mask = isa .(jumps, Equation)
893
950
eqs = Vector {Equation} (jumps[mask])
894
951
jumps = jumps[.! mask]
895
952
return System (eqs, iv, dvs, ps; jumps, kwargs... )
896
953
end
897
954
955
+ # explicitly write the docstring to avoid mentioning `parameter_dependencies`.
898
956
"""
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.
902
978
"""
903
979
function SDESystem (eqs:: Vector{Equation} , noise, iv; is_scalar_noise = false ,
904
980
parameter_dependencies = Equation[], kwargs... )
@@ -912,6 +988,13 @@ function SDESystem(eqs::Vector{Equation}, noise, iv; is_scalar_noise = false,
912
988
@set sys. parameter_dependencies = parameter_dependencies
913
989
end
914
990
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
+ """
915
998
function SDESystem (
916
999
eqs:: Vector{Equation} , noise, iv, dvs, ps; is_scalar_noise = false ,
917
1000
parameter_dependencies = Equation[], kwargs... )
@@ -925,6 +1008,11 @@ function SDESystem(
925
1008
@set sys. parameter_dependencies = parameter_dependencies
926
1009
end
927
1010
1011
+ """
1012
+ $(TYPEDSIGNATURES)
1013
+
1014
+ Attach the given noise matrix `noise` to the system `sys`.
1015
+ """
928
1016
function SDESystem (sys:: System , noise; kwargs... )
929
1017
SDESystem (equations (sys), noise, get_iv (sys); kwargs... )
930
1018
end
0 commit comments