Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MarkovProcesses.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bentriou Mahmoud
MarkovProcesses.jl
Commits
a90b2eda
Commit
a90b2eda
authored
4 years ago
by
Bentriou Mahmoud
Browse files
Options
Downloads
Patches
Plain Diff
Pretty print for synchronized period automaton trajectories
parent
575ef324
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/plots.jl
+66
-8
66 additions, 8 deletions
core/plots.jl
with
66 additions
and
8 deletions
core/plots.jl
+
66
−
8
View file @
a90b2eda
import
Plots
:
plot
,
plot!
,
scatter!
,
Shape
import
Plots
:
plot
,
plot!
,
scatter!
,
hline!
,
Shape
,
text
import
Plots
:
current
,
palette
,
display
,
png
,
close
"""
...
...
@@ -54,15 +54,73 @@ function plot(σ::AbstractTrajectory, vars::VariableModel...; plot_transitions::
end
function
plot!
(
A
::
LHA
)
if
haskey
(
A
.
constants
,
"x1"
)
&&
haskey
(
A
.
constants
,
"x2"
)
&&
haskey
(
A
.
constants
,
"t1"
)
&&
haskey
(
A
.
constants
,
"t2"
)
x1
,
x2
,
t1
,
t2
=
A
.
constants
[
"x1"
],
A
.
constants
[
"x2"
],
A
.
constants
[
"t1"
],
A
.
constants
[
"t2"
]
plot!
(
Shape
([(
t1
,
x1
),
(
t1
,
x2
),
(
t2
,
x2
),
(
t2
,
x1
),
(
t1
,
x1
)]),
opacity
=
0.5
,
label
=
"Region LHA"
)
if
A
.
name
in
[
"F property"
,
"G property"
]
if
haskey
(
A
.
constants
,
"x1"
)
&&
haskey
(
A
.
constants
,
"x2"
)
&&
haskey
(
A
.
constants
,
"t1"
)
&&
haskey
(
A
.
constants
,
"t2"
)
x1
,
x2
,
t1
,
t2
=
A
.
constants
[
"x1"
],
A
.
constants
[
"x2"
],
A
.
constants
[
"t1"
],
A
.
constants
[
"t2"
]
plot!
(
Shape
([(
t1
,
x1
),
(
t1
,
x2
),
(
t2
,
x2
),
(
t2
,
x1
),
(
t1
,
x1
)]),
opacity
=
0.5
,
label
=
"Region LHA"
)
end
end
if
A
.
name
in
[
"G and F property"
]
if
haskey
(
A
.
constants
,
"x1"
)
&&
haskey
(
A
.
constants
,
"x2"
)
&&
haskey
(
A
.
constants
,
"t1"
)
&&
haskey
(
A
.
constants
,
"t2"
)
x1
,
x2
,
t1
,
t2
=
A
.
constants
[
"x1"
],
A
.
constants
[
"x2"
],
A
.
constants
[
"t1"
],
A
.
constants
[
"t2"
]
plot!
(
Shape
([(
t1
,
x1
),
(
t1
,
x2
),
(
t2
,
x2
),
(
t2
,
x1
),
(
t1
,
x1
)]),
opacity
=
0.5
,
label
=
"Region LHA"
)
end
if
haskey
(
A
.
constants
,
"x3"
)
&&
haskey
(
A
.
constants
,
"x4"
)
&&
haskey
(
A
.
constants
,
"t3"
)
&&
haskey
(
A
.
constants
,
"t4"
)
x3
,
x4
,
t3
,
t4
=
A
.
constants
[
"x3"
],
A
.
constants
[
"x4"
],
A
.
constants
[
"t3"
],
A
.
constants
[
"t4"
]
plot!
(
Shape
([(
t3
,
x3
),
(
t3
,
x4
),
(
t4
,
x4
),
(
t4
,
x3
),
(
t3
,
x3
)]),
opacity
=
0.5
,
label
=
"Region LHA"
)
end
end
if
A
.
name
==
"Period"
hline!
([
A
.
constants
[
:
L
],
A
.
constants
[
:
H
]],
label
=
"L, H"
,
linestyle
=
:
dot
)
end
end
# For tests purposes
function
plot_periodic_trajectory
(
A
::
LHA
,
σ
::
SynchronizedTrajectory
,
sym_obs
::
Symbol
;
verbose
=
false
)
@assert
(
σ
.
m
)
.
dim_state
==
σ
.
m
.
dim_obs_state
# Model should be entirely obserbed
@assert
A
.
name
in
[
"Period"
]
A_new
=
LHA
(
A
,
(
σ
.
m
)
.
_map_obs_var_idx
)
p_sim
=
(
σ
.
m
)
.
p
l_t
=
times
(
σ
)
l_tr
=
transitions
(
σ
)
Sn
=
init_state
(
A_new
,
σ
[
1
],
l_t
[
1
])
Snplus1
=
copy
(
Sn
)
nbr_states
=
length_states
(
σ
)
locations_trajectory
=
Vector
{
Location
}(
undef
,
nbr_states
)
locations_trajectory
[
1
]
=
Sn
.
loc
idx_n
=
[
1
]
values_n
=
[
Sn
[
:
n
]]
if
verbose
println
(
"Init: "
)
end
if
verbose
@show
Sn
end
for
n
in
2
:
nbr_states
next_state!
(
Snplus1
,
A_new
,
σ
[
n
],
l_t
[
n
],
l_tr
[
n
],
Sn
,
σ
[
n
-
1
],
p_sim
;
verbose
=
verbose
)
copyto!
(
Sn
,
Snplus1
)
locations_trajectory
[
n
]
=
Sn
.
loc
if
Sn
[
:
n
]
!=
values_n
[
end
]
push!
(
idx_n
,
n
)
push!
(
values_n
,
Sn
[
:
n
])
end
if
Snplus1
.
loc
in
A_new
.
locations_final
break
end
end
if
haskey
(
A
.
constants
,
"x3"
)
&&
haskey
(
A
.
constants
,
"x4"
)
&&
haskey
(
A
.
constants
,
"t3"
)
&&
haskey
(
A
.
constants
,
"t4"
)
x3
,
x4
,
t3
,
t4
=
A
.
constants
[
"x3"
],
A
.
constants
[
"x4"
],
A
.
constants
[
"t3"
],
A
.
constants
[
"t4"
]
plot!
(
Shape
([(
t3
,
x3
),
(
t3
,
x4
),
(
t4
,
x4
),
(
t4
,
x3
),
(
t3
,
x3
)]),
opacity
=
0.5
,
label
=
"Region LHA"
)
p
=
plot
(
title
=
"Oscillatory trajectory of
$
(σ.m.name) model"
,
background_color_legend
=:
transparent
,
dpi
=
480
,
legend
=
:
outertopright
)
#legendfontsize, legend
colors_loc
=
Dict
(
:
l0
=>
:
silver
,
:
l0prime
=>
:
silver
,
:
final
=>
:
black
,
:
low
=>
:
skyblue2
,
:
mid
=>
:
orange
,
:
high
=>
:
red
)
loc_to_color
(
loc
::
Symbol
)
=
colors_loc
[
loc
]
for
loc
in
A
.
locations
idx_locations
=
findall
(
x
->
x
==
loc
,
locations_trajectory
)
label_state
=
(
loc
in
[
:
low
,
:
mid
,
:
high
])
?
"State
$
sym_obs (
$
loc loc)"
:
""
scatter!
(
p
,
times
(
σ
)[
idx_locations
],
σ
[
sym_obs
][
idx_locations
],
color
=
colors_loc
[
loc
],
markersize
=
1.0
,
markershape
=
:
cross
,
label
=
label_state
)
end
annot_n
=
[(
times
(
σ
)[
idx_n
[
i
]],
σ
[
sym_obs
][
idx_n
[
i
]]
-
10
,
text
(
"n =
$
(values_n[i])"
,
6
,
:
bottom
))
for
i
=
eachindex
(
idx_n
)]
scatter!
(
p
,
times
(
σ
)[
idx_n
],
σ
[
sym_obs
][
idx_n
],
annotations
=
annot_n
,
markershape
=
:
utriangle
,
markersize
=
3
,
label
=
"n"
)
hline!
(
p
,
[
A
.
constants
[
:
L
],
A
.
constants
[
:
H
]],
label
=
"L, H"
,
color
=
:
grey
;
linestyle
=
:
dot
)
end
export
plot
,
plot!
export
plot
,
plot!
,
plot_periodic_trajectory
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment