Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
schedgen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Pour rappel, le service sera inaccessible ce lundi 05/05/25 midi pour raison de mise à jour.
Show more breadcrumbs
veriT
schedgen
Commits
1162d884
Commit
1162d884
authored
3 years ago
by
Hans-Jörg
Browse files
Options
Downloads
Patches
Plain Diff
Add CDF script to contrib
parent
72528284
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
contrib/cdf.py
+115
-0
115 additions, 0 deletions
contrib/cdf.py
with
115 additions
and
0 deletions
contrib/cdf.py
0 → 100755
+
115
−
0
View file @
1162d884
#!/usr/bin/env python3
from
pathlib
import
Path
import
re
import
math
import
matplotlib.pyplot
as
plt
import
matplotlib.ticker
as
mticker
# import tikzplotlib
import
numpy
as
np
import
csv
logics
=
[
"
UF
"
]
base_path
=
Path
(
'
.
'
)
simulation_1_file
=
base_path
/
"
simulation_1.txt
"
simulation_2_file
=
base_path
/
"
simulation_2.txt
"
all_strategies_file
=
base_path
/
"
contrib
"
/
"
example_data.csv
"
data_re
=
r
"
^([^ ]+) +([-0-9\.]+) +([^ ]+)
"
paper_data_dir
=
Path
(
"
.
"
)
# This is in inches
textwidth
=
4.8041
def
parse_gtpt
(
file_name
,
logics
):
result
=
{}
with
open
(
file_name
)
as
f
:
for
line
in
f
:
m
=
re
.
match
(
data_re
,
line
)
if
m
:
r
=
m
.
group
(
3
).
strip
()
b
=
m
.
group
(
1
)
# solved (1 is sat, 0 is unsat)
if
r
==
"
0
"
:
time
=
float
(
m
.
group
(
2
))
else
:
time
=
math
.
inf
# exp_logic = m.group(1).split("/")[0]
exp_logic
=
"
UF
"
if
exp_logic
in
logics
:
result
[
b
]
=
time
return
result
def
num_seq
(
ls
,
v
):
for
i
in
range
(
len
(
ls
)):
if
ls
[
i
]
>
v
:
return
i
+
1
if
__name__
==
"
__main__
"
:
simulation_1
=
parse_gtpt
(
simulation_1_file
,
logics
)
simulation_2
=
parse_gtpt
(
simulation_2_file
,
logics
)
base_times
=
[]
with
open
(
all_strategies_file
,
newline
=
""
)
as
csvfile
:
reader
=
csv
.
DictReader
(
csvfile
,
skipinitialspace
=
True
,
delimiter
=
"
;
"
)
for
row
in
reader
:
strategy
=
row
[
"
strategy
"
].
strip
()
if
strategy
!=
"
base-strategy
"
:
continue
result
=
row
[
"
solved
"
].
strip
().
lower
()
if
result
in
[
"
1
"
,
"
yes
"
,
"
true
"
]:
try
:
time
=
float
(
row
[
"
time
"
].
strip
())
base_times
.
append
(
time
)
except
ValueError
:
pass
base_times
.
sort
()
fig
,
ax
=
plt
.
subplots
()
ax
.
grid
(
True
)
ax
.
grid
(
color
=
'
0.75
'
)
ax
.
set_xlabel
(
r
'
CPU Time
'
,
fontsize
=
10
)
ax
.
set_ylabel
(
r
'
Solved Benchmarks
'
,
fontsize
=
10
)
ax
.
spines
[
'
right
'
].
set_visible
(
False
)
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
ax
.
xaxis
.
set_major_formatter
(
mticker
.
ScalarFormatter
())
ax
.
yaxis
.
set_major_formatter
(
mticker
.
ScalarFormatter
())
# ax.yaxis.get_offset_text().set_visible(False)
ax
.
ticklabel_format
(
style
=
'
plain
'
)
ax
.
set_xlim
([
0
,
6
])
ax
.
set_ylim
([
0
,
40
])
plt
.
xticks
([
0
,
1
,
2
,
3
,
4
,
5
,
6
])
n_sample
=
1.5
*
100
time_max
=
6.0
dist
=
6.0
/
(
n_sample
-
1
)
sampling_6
=
np
.
arange
(
0
,
time_max
+
dist
,
dist
)
times_simulation_1
=
list
(
simulation_1
.
values
())
times_simulation_1
.
sort
()
dist_simulation_1
=
[
num_seq
(
times_simulation_1
,
v
)
for
v
in
sampling_6
]
times_simulation_2
=
list
(
simulation_2
.
values
())
times_simulation_2
.
sort
()
dist_simulation_2
=
[
num_seq
(
times_simulation_2
,
v
)
for
v
in
sampling_6
]
dist_base
=
[
num_seq
(
base_times
,
v
)
for
v
in
sampling_6
]
ax
.
plot
(
sampling_6
,
dist_base
,
'
-
'
,
color
=
"
darkgray
"
,
label
=
"
base strategy
"
)
ax
.
plot
(
sampling_6
,
dist_simulation_1
,
linestyle
=
'
dashed
'
,
color
=
'
k
'
,
label
=
"
slight jitter
"
)
ax
.
plot
(
sampling_6
,
dist_simulation_2
,
'
-
'
,
color
=
'
k
'
,
label
=
"
intese jitter
"
)
ax
.
legend
(
fontsize
=
"
x-small
"
)
fig
.
tight_layout
()
fig
.
set_size_inches
(
w
=
textwidth
*
1.1
,
h
=
textwidth
*
0.1
)
# tikzplotlib.clean_figure()
# tikzplotlib.save("plot.tex", flavor="context")
plt
.
show
()
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