Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pta2maude
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
real-time maude
pta2maude
Commits
5ebe532b
Commit
5ebe532b
authored
1 year ago
by
Jaime Arias
Browse files
Options
Downloads
Patches
Plain Diff
add discrete variables
parent
9353a440
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pta2maude/src/Parser.py
+23
-3
23 additions, 3 deletions
pta2maude/src/Parser.py
pta2maude/tests/examples/fischer-intrpr.maude
+1
-1
1 addition, 1 deletion
pta2maude/tests/examples/fischer-intrpr.maude
with
24 additions
and
4 deletions
pta2maude/src/Parser.py
+
23
−
3
View file @
5ebe532b
...
...
@@ -853,6 +853,27 @@ class InterpreterParser(Parser):
return
params_constraints
def
_get_discrete_constraints
(
self
,
model
)
->
list
[
str
]:
"""
Get the initial constraints of discrete variables
Parameters
----------
model : Model
Imitator model
Returns
-------
list[str]
"""
vars
=
model
.
discrete_vars
var_constraints
=
[]
for
c
in
model
.
initial_constraints
:
v1
,
_
,
v2
=
self
.
_normalize_constraints
(
c
).
split
(
"
"
)
if
v1
in
vars
:
var_constraints
.
append
(
f
"
{
v1
}
:
{
v2
}
"
)
return
var_constraints
def
_normalize_constraints
(
self
,
constraint
:
str
)
->
str
:
"""
Normalize the string represention of a constraint. For instance, adding
...
...
@@ -871,7 +892,7 @@ class InterpreterParser(Parser):
new_constr
=
"
true
"
if
constraint
==
"
True
"
else
constraint
# add space around binary operators
c_with_spaces
=
re
.
sub
(
r
"
((?!\.|\/)
\W
+)
"
,
r
"
\1
"
,
new_constr
)
c_with_spaces
=
re
.
sub
(
r
"
((?!\.|\/)
[^\w-]
+)
"
,
r
"
\1
"
,
new_constr
)
# remove more than one space
no_spaces
=
re
.
sub
(
"
+
"
,
"
"
,
c_with_spaces
)
...
...
@@ -962,8 +983,7 @@ class InterpreterParser(Parser):
params_str
=
f
"
(
{
'
,
'
.
join
(
params
)
}
)
"
if
len
(
params
)
else
"
empty
"
# variables
# TODO: add variables to the imitator parser (antlr)
variables
=
[]
variables
=
self
.
_get_discrete_constraints
(
model
)
vars_str
=
f
"
(
{
'
,
'
.
join
(
variables
)
}
)
"
if
len
(
variables
)
else
"
empty
"
# constraints
...
...
This diff is collapsed.
Click to expand it.
pta2maude/tests/examples/fischer-intrpr.maude
+
1
−
1
View file @
5ebe532b
...
...
@@ -45,7 +45,7 @@ mod MODEL is
locs: (proc1 @ idle1, proc2 @ idle2, observer @ obswaiting)
clocks: (x1 : 0, x2 : 0)
parameters: (delta : rr(var(delta)), gamma : rr(var(gamma)))
dvariables: turn : -1
dvariables:
(
turn : -1
)
constraint: rr(var(delta)) >= 0 and rr(var(gamma)) >= 0
n: 1 >
.
...
...
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