Skip to content

Commit 4e66612

Browse files
committed
Format
1 parent 29fda66 commit 4e66612

30 files changed

+442
-201
lines changed

docs/make.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ makedocs(;
2121
pages = [
2222
"Home" => "index.md"
2323
"Reference" => Any[
24-
"Dynamics" => "reference/dynamics.md",
25-
"Specifications" => "reference/specifications.md",
26-
"Abstractions" => "reference/abstractions.md",
24+
"Dynamics"=>"reference/dynamics.md",
25+
"Specifications"=>"reference/specifications.md",
26+
"Abstractions"=>"reference/abstractions.md",
2727
]
2828
],
2929
doctest = true,
30-
checkdocs = :exports
30+
checkdocs = :exports,
3131
)
3232

3333
deploydocs(; repo = "github.com/Zinoex/IntervalMDPAbstractions.jl", devbranch = "main")

examples/systems/almost_identity.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ function almost_identity_decoupled(
5151
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
5252

5353
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
54-
upper_bound_spec =
55-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
54+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
55+
upper_bound_spec,
56+
state_abs,
57+
target_model,
58+
)
5659

5760
return mdp, abstract_spec, upper_bound_spec
5861
end
@@ -80,8 +83,11 @@ function almost_identity_direct(
8083
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
8184

8285
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
83-
upper_bound_spec =
84-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
86+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
87+
upper_bound_spec,
88+
state_abs,
89+
target_model,
90+
)
8591

8692
return mdp, abstract_spec, upper_bound_spec
8793
end

examples/systems/bas_4d.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ function building_automation_system_4d_decoupled(
6262
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
6363

6464
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
65-
upper_bound_spec =
66-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
65+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
66+
upper_bound_spec,
67+
state_abs,
68+
target_model,
69+
)
6770

6871
return mdp, abstract_spec, upper_bound_spec
6972
end
@@ -95,8 +98,11 @@ function building_automation_system_4d_direct(
9598
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
9699

97100
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
98-
upper_bound_spec =
99-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
101+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
102+
upper_bound_spec,
103+
state_abs,
104+
target_model,
105+
)
100106

101107
return mdp, abstract_spec, upper_bound_spec
102108
end

examples/systems/big.jl

+16-11
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ function big_decoupled(
4848
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
4949

5050
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
51-
upper_bound_spec =
52-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
51+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
52+
upper_bound_spec,
53+
state_abs,
54+
target_model,
55+
)
5356

5457
return mdp, abstract_spec, upper_bound_spec
5558
end
@@ -77,8 +80,11 @@ function big_direct(
7780
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
7881

7982
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
80-
upper_bound_spec =
81-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
83+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
84+
upper_bound_spec,
85+
state_abs,
86+
target_model,
87+
)
8288

8389
return mdp, abstract_spec, upper_bound_spec
8490
end
@@ -104,11 +110,7 @@ function small_sys(time_horizon)
104110
return sys, spec
105111
end
106112

107-
function small_direct(
108-
time_horizon = 10;
109-
sparse = false,
110-
state_split_per_dim = 2,
111-
)
113+
function small_direct(time_horizon = 10; sparse = false, state_split_per_dim = 2)
112114
sys, spec = small_sys(time_horizon)
113115

114116
X = Hyperrectangle(; low = [-1.0], high = [1.0])
@@ -126,8 +128,11 @@ function small_direct(
126128
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
127129

128130
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
129-
upper_bound_spec =
130-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
131+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
132+
upper_bound_spec,
133+
state_abs,
134+
target_model,
135+
)
131136

132137
return mdp, abstract_spec, upper_bound_spec
133138
end

examples/systems/car_parking.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ function car_parking_decoupled(
5252
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
5353

5454
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
55-
upper_bound_spec =
56-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
55+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
56+
upper_bound_spec,
57+
state_abs,
58+
target_model,
59+
)
5760

5861
return mdp, abstract_spec, upper_bound_spec
5962
end
@@ -89,8 +92,11 @@ function car_parking_direct(
8992
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
9093

9194
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
92-
upper_bound_spec =
93-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
95+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
96+
upper_bound_spec,
97+
state_abs,
98+
target_model,
99+
)
94100

95101
return mdp, abstract_spec, upper_bound_spec
96102
end

examples/systems/gp_dkl.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ function dubins_car_decoupled(time_horizon = 10; sparse = false)
9898
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
9999

100100
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
101-
upper_bound_spec =
102-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
101+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
102+
upper_bound_spec,
103+
state_abs,
104+
target_model,
105+
)
103106

104107
return mdp, abstract_spec, upper_bound_spec
105108
end
@@ -123,8 +126,11 @@ function dubins_car_direct(time_horizon = 10; sparse = true)
123126
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
124127

125128
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
126-
upper_bound_spec =
127-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
129+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
130+
upper_bound_spec,
131+
state_abs,
132+
target_model,
133+
)
128134

129135
return mdp, abstract_spec, upper_bound_spec
130136
end

examples/systems/linear_stochastically_switched.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ function linear_stochastically_switched_direct(
6161
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
6262

6363
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
64-
upper_bound_spec =
65-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
64+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
65+
upper_bound_spec,
66+
state_abs,
67+
target_model,
68+
)
6669

6770
return mdp, abstract_spec, upper_bound_spec
6871
end
@@ -89,8 +92,11 @@ function linear_stochastically_switched_mixture(
8992
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
9093

9194
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
92-
upper_bound_spec =
93-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
95+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
96+
upper_bound_spec,
97+
state_abs,
98+
target_model,
99+
)
94100

95101
return mdp, abstract_spec, upper_bound_spec
96102
end

examples/systems/nndm.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,11 @@ function action_cartpole_decoupled(time_horizon = 10; sparse = false)
321321
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
322322

323323
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
324-
upper_bound_spec =
325-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
324+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
325+
upper_bound_spec,
326+
state_abs,
327+
target_model,
328+
)
326329

327330
return mdp, abstract_spec, upper_bound_spec
328331
end
@@ -349,8 +352,11 @@ function action_cartpole_direct(time_horizon = 10; sparse = false)
349352
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
350353

351354
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
352-
upper_bound_spec =
353-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
355+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
356+
upper_bound_spec,
357+
state_abs,
358+
target_model,
359+
)
354360

355361
return mdp, abstract_spec, upper_bound_spec
356362
end

examples/systems/robot_2d.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ function robot_2d_decoupled(
8686
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
8787

8888
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
89-
upper_bound_spec =
90-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
89+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
90+
upper_bound_spec,
91+
state_abs,
92+
target_model,
93+
)
9194

9295
return mdp, abstract_spec, upper_bound_spec
9396
end
@@ -117,8 +120,11 @@ function robot_2d_direct(
117120
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
118121

119122
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
120-
upper_bound_spec =
121-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
123+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
124+
upper_bound_spec,
125+
state_abs,
126+
target_model,
127+
)
122128

123129
return mdp, abstract_spec, upper_bound_spec
124130
end

examples/systems/van_der_pol.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ function van_der_pol_decoupled(
4747
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
4848

4949
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
50-
upper_bound_spec =
51-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
50+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
51+
upper_bound_spec,
52+
state_abs,
53+
target_model,
54+
)
5255

5356
return mdp, abstract_spec, upper_bound_spec
5457
end
@@ -68,8 +71,11 @@ function van_der_pol_direct(time_horizon = 10; state_split = (50, 50), input_spl
6871
mdp, abstract_spec = abstraction(prob, state_abs, input_abs, target_model)
6972

7073
upper_bound_spec = Specification(system_property(spec), !satisfaction_mode(spec))
71-
upper_bound_spec =
72-
IntervalMDPAbstractions.convert_specification(upper_bound_spec, state_abs, target_model)
74+
upper_bound_spec = IntervalMDPAbstractions.convert_specification(
75+
upper_bound_spec,
76+
state_abs,
77+
target_model,
78+
)
7379

7480
return mdp, abstract_spec, upper_bound_spec
7581
end

src/abstractions/abstraction.jl

+26-12
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,28 @@ end
145145

146146
function initprob(::SparseIMDPTarget, nregions, ninputs)
147147
nchoices = nregions * ninputs
148-
prob_lower = AtomicSparseMatrixCOO{Float64, Int32}(undef, nregions + 1, nchoices)
149-
prob_upper = AtomicSparseMatrixCOO{Float64, Int32}(undef, nregions + 1, nchoices)
148+
prob_lower = AtomicSparseMatrixCOO{Float64,Int32}(undef, nregions + 1, nchoices)
149+
prob_upper = AtomicSparseMatrixCOO{Float64,Int32}(undef, nregions + 1, nchoices)
150150

151151
return prob_lower, prob_upper
152152
end
153153

154154
function postprocessprob(::SparseIMDPTarget, prob_lower, prob_upper)
155-
prob_lower = sparse(prob_lower.rows, prob_lower.cols, prob_lower.values, prob_lower.m, prob_lower.n)
156-
prob_upper = sparse(prob_upper.rows, prob_upper.cols, prob_upper.values, prob_upper.m, prob_upper.n)
157-
155+
prob_lower = sparse(
156+
prob_lower.rows,
157+
prob_lower.cols,
158+
prob_lower.values,
159+
prob_lower.m,
160+
prob_lower.n,
161+
)
162+
prob_upper = sparse(
163+
prob_upper.rows,
164+
prob_upper.cols,
165+
prob_upper.values,
166+
prob_upper.m,
167+
prob_upper.n,
168+
)
169+
158170
return prob_lower, prob_upper
159171
end
160172

@@ -166,7 +178,7 @@ function convert_property(
166178
prop = system_property(spec)
167179

168180
reach_states = Int32[]
169-
avoid_states = Int32[numregions(state_abstraction) + 1] # Absorbing state
181+
avoid_states = Int32[numregions(state_abstraction)+1] # Absorbing state
170182

171183
for (i, source_region) in enumerate(regions(state_abstraction))
172184
if ispessimistic(spec) && source_region reach(prop)
@@ -187,7 +199,7 @@ function convert_property(
187199
prop = system_property(spec)
188200

189201
reach_states = Int32[]
190-
avoid_states = Int32[numregions(state_abstraction) + 1] # Absorbing state
202+
avoid_states = Int32[numregions(state_abstraction)+1] # Absorbing state
191203

192204
for (i, source_region) in enumerate(regions(state_abstraction))
193205
if ispessimistic(spec) && !iszeromeasure(avoid(prop), source_region)
@@ -211,7 +223,7 @@ function convert_property(
211223
)
212224
prop = system_property(spec)
213225

214-
avoid_states = Int32[numregions(state_abstraction) + 1] # Absorbing state
226+
avoid_states = Int32[numregions(state_abstraction)+1] # Absorbing state
215227

216228
for (i, source_region) in enumerate(regions(state_abstraction))
217229
if ispessimistic(spec) && !iszeromeasure(avoid(prop), source_region)
@@ -313,14 +325,16 @@ function initprob(
313325
state_abstraction::StateUniformGridSplit,
314326
ninputs,
315327
)
316-
prob_lower = AtomicSparseMatrixCOO{Float64, Int32}[]
317-
prob_upper = AtomicSparseMatrixCOO{Float64, Int32}[]
328+
prob_lower = AtomicSparseMatrixCOO{Float64,Int32}[]
329+
prob_upper = AtomicSparseMatrixCOO{Float64,Int32}[]
318330

319331
nchoices = numregions(state_abstraction) * ninputs
320332

321333
for axisregions in splits(state_abstraction)
322-
local_prob_lower = AtomicSparseMatrixCOO{Float64, Int32}(undef, axisregions + 1, nchoices)
323-
local_prob_upper = AtomicSparseMatrixCOO{Float64, Int32}(undef, axisregions + 1, nchoices)
334+
local_prob_lower =
335+
AtomicSparseMatrixCOO{Float64,Int32}(undef, axisregions + 1, nchoices)
336+
local_prob_upper =
337+
AtomicSparseMatrixCOO{Float64,Int32}(undef, axisregions + 1, nchoices)
324338

325339
push!(prob_lower, local_prob_lower)
326340
push!(prob_upper, local_prob_upper)

0 commit comments

Comments
 (0)