@@ -796,42 +796,36 @@ function discretize_interval_matrix(𝑆::InitialValueProblem, δ::Float64,
796796 end
797797
798798 U = inputset (𝑆)
799- U0 = next_set (U, 1 )
800799 n = size (A, 1 )
801- linear_maps = Vector {LinearMap{N}} (undef, order > 2 ? 3 : 2 )
800+
801+ # `ΣM` sums up the interval matrices that are multiplied with the inputs:
802+ # Σᵢ (Mᵢ * V) = (Σᵢ Mᵢ) * V
802803
803804 A² = A * A
804805 Iδ = IntervalMatrix (Diagonal (fill (IntervalMatrices. Interval (δ), n)))
805806 IδW = Iδ + 1 / 2 * δ^ 2 * A + 1 / 6 * δ^ 3 * A²
806- linear_maps[1 ] = LinearMap (IδW, U0)
807-
808- E = _expm_remainder (A, δ, order; n= n)
809- linear_maps[2 ] = LinearMap (E* δ, U0)
807+ ΣM = IδW
810808
811- zero_interval = IntervalMatrices. Interval (zero (N), zero (N))
812809 if order > 2
813810 # i = 2
814811 αᵢ₊₁ = 6 # factorial of (i+1)
815812 Aⁱ = A²
816813 δⁱ⁺¹ = δ^ 3
817- M_sum = IntervalMatrix (fill (zero_interval, size (A)))
818814 @inbounds for i in 3 : order
819815 αᵢ₊₁ *= i+ 1
820816 δⁱ⁺¹ *= δ
821817 Aⁱ *= A
822- M_sum += (δⁱ⁺¹/ αᵢ₊₁) * Aⁱ
818+ ΣM += (δⁱ⁺¹/ αᵢ₊₁) * Aⁱ
823819 end
824- linear_maps[3 ] = LinearMap (M_sum, U0)
825820 end
826821
827- Ω0, Ud = _discretize_interval_matrix_inhomog (U, Ω0_homog, linear_maps, set_ops)
822+ E = _expm_remainder (A, δ, order; n= n)
823+ ΣM += E * δ
824+
825+ Ω0, Ud = _discretize_interval_matrix_inhomog (Ω0_homog, U, ΣM, set_ops)
828826
829827 # create identity interval matrix
830- one_interval = IntervalMatrices. Interval (one (N), one (N))
831- B = IntervalMatrix (fill (zero_interval, (n, n)))
832- @inbounds for i in 1 : n
833- B[i, i] = one_interval
834- end
828+ B = IntervalMatrix (Diagonal (fill (IntervalMatrices. Interval (one (N)), n)))
835829
836830 return IVP (CLCDS (ϕ, B, stateset (𝑆. s), Ud), Ω0)
837831end
@@ -852,31 +846,25 @@ function _discretize_interval_matrix_homog(X0, ϕ, F, set_ops::Val{:zonotope})
852846end
853847
854848# version using lazy sets and operations
855- function _discretize_interval_matrix_inhomog (U, Ω0_homog, linear_maps, set_ops:: Val{:lazy} )
856- Ω0_inhomog = MinkowskiSumArray (linear_maps)
857- Ω0 = MinkowskiSumArray (vcat ([Ω0_homog], linear_maps))
858-
859- if U isa ConstantInput
860- Ud = ConstantInput (Ω0_inhomog)
861- elseif U isa VaryingInput
862- throw (ArgumentError (" varying inputs with interval matrices are not " *
863- " supported yet" ))
864- else
865- throw (ArgumentError (" input of type $(typeof (U)) is not allowed" ))
866- end
849+ function _discretize_interval_matrix_inhomog (Ω0_homog, U, M, set_ops:: Val{:lazy} )
850+ U0 = next_set (U, 1 )
851+ Ω0_inhomog = M * U0
852+ Ω0 = MinkowskiSum (Ω0_homog, Ω0_inhomog)
853+ Ud = _discretize_interval_matrix_inhomog_wrap_inputs (U, Ω0_inhomog)
867854 return Ω0, Ud
868855end
869856
870857# version using concrete operations with zonotopes
871- function _discretize_interval_matrix_inhomog (U, Ω0_homog, linear_maps ,
858+ function _discretize_interval_matrix_inhomog (Ω0_homog, U, M ,
872859 set_ops:: Val{:zonotope} )
873- Ω0_inhomog = overapproximate (linear_maps[1 ], Zonotope)
874- @inbounds for i in 2 : length (linear_maps)
875- Z = overapproximate (linear_maps[i], Zonotope)
876- Ω0_inhomog = minkowski_sum (Z, Ω0_inhomog)
877- end
860+ U0 = next_set (U, 1 )
861+ Ω0_inhomog = overapproximate (M * U0, Zonotope)
878862 Ω0 = minkowski_sum (Ω0_homog, Ω0_inhomog)
863+ Ud = _discretize_interval_matrix_inhomog_wrap_inputs (U, Ω0_inhomog)
864+ return Ω0, Ud
865+ end
879866
867+ function _discretize_interval_matrix_inhomog_wrap_inputs (U, Ω0_inhomog)
880868 if U isa ConstantInput
881869 Ud = ConstantInput (Ω0_inhomog)
882870 elseif U isa VaryingInput
@@ -885,7 +873,7 @@ function _discretize_interval_matrix_inhomog(U, Ω0_homog, linear_maps,
885873 else
886874 throw (ArgumentError (" input of type $(typeof (U)) is not allowed" ))
887875 end
888- return Ω0, Ud
876+ return Ud
889877end
890878
891879# fallback implementation for conversion (if applicable) or overapproximation
0 commit comments