Skip to content

Commit d76ee78

Browse files
committed
initial commit
0 parents  commit d76ee78

File tree

3,584 files changed

+722297
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,584 files changed

+722297
-0
lines changed

AttributePNet.py

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import datetime
2+
3+
class Place (object):
4+
'''!
5+
Class to represent a place in a Petri Net
6+
Tokens are represented by Integer values
7+
input and output arcs are represented as sets of possible transitions
8+
date attribute refers to a timestamp - дата первого перехода в позицию --- ЗАЧЕМ ТУТ??
9+
isFinal - specify if this place can be final
10+
'''
11+
def __init__(self, name, final, tokens=0):
12+
'''!
13+
Constructor method.
14+
15+
@param name: name of the place
16+
@param final: specify if this place can be final
17+
'''
18+
self.name = str(name)
19+
self.tokens = tokens
20+
self.inArcs = {}
21+
self.outArcs = {}
22+
self.date = datetime.date(datetime.MINYEAR, 1, 1) # ?????
23+
self.isFinal = final
24+
25+
def addToken(self):
26+
self.tokens = self.tokens + 1
27+
28+
def removeToken(self):
29+
self.tokens = self.tokens - 1
30+
31+
def setDate(self, timestamp):
32+
self.date = datetime.date.fromtimestamp(timestamp)
33+
34+
35+
class Transition (object):
36+
'''!
37+
Class to represent a transition ib a Petri Net
38+
'''
39+
40+
def __init__(self, name, fires, maxtime, hidden, weight=1):
41+
'''!
42+
Constructor method.
43+
44+
@param name: name of the transition
45+
@param fires: legal number of firing for the transition
46+
@param maxtime: legal gap before transition firing
47+
@param weight: penalty for transition firing
48+
'''
49+
self.name = str(name)
50+
self.inArcs = {}
51+
self.outArcs = {}
52+
self.firingCounter = fires
53+
self.maxTime = datetime.timedelta(days=maxtime)
54+
self.weight = weight
55+
self.hidden = hidden
56+
57+
58+
class AttributePetriNet (object):
59+
def __init__(self):
60+
self.startPlace = Place("start", False, tokens=1)
61+
self.finishPlace = Place("final", True)
62+
self.places = {
63+
"start": self.startPlace,
64+
"finish": self.finishPlace
65+
}
66+
self.transitions = {}
67+
68+
def addPlace(self, name, final):
69+
newPlace = Place(name, final)
70+
self.places[name] = newPlace
71+
72+
def addTransition (self, name, fires, maxtime, hidden, weight):
73+
newTransition = Transition(name, fires, maxtime, hidden, weight)
74+
self.transitions[name] = newTransition
75+
76+
def addInputArc(self, placeName, transitionName):
77+
'''!
78+
Method that add arcs from place to transition
79+
'''
80+
currentPlace = self.places[placeName]
81+
currentTransition = self.transitions[transitionName]
82+
currentPlace.outArcs[transitionName] = currentTransition
83+
currentTransition.inArcs[placeName] = currentPlace
84+
85+
def addOutputArc(self, transitionName, placeName):
86+
'''!
87+
Method that add arcs from transitions to places
88+
'''
89+
currentPlace = self.places[placeName]
90+
currentTransition = self.transitions[transitionName]
91+
currentPlace.inArcs[transitionName] = currentTransition
92+
currentTransition.outArcs[placeName] = currentPlace

EventsMatcher.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import pandas as pd
2+
3+
4+
class Matcher(object):
5+
def __init__(self):
6+
df = pd.read_csv("events_to_transitions.csv", sep=';')
7+
df = df.loc[:, ~df.columns.str.contains('^Unnamed')]
8+
event_list = df['event'].tolist()
9+
transition_id_list = df['transition_id'].tolist()
10+
self.events_to_transitions = dict(zip(event_list,transition_id_list))
11+
12+
def event_to_transition(self, evname):
13+
return self.events_to_transitions[evname]

Main.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'''!
2+
log preprocessing
3+
|
4+
model initialization
5+
|
6+
for each trace get conformance value
7+
|
8+
filter anomaly traces
9+
|
10+
classify anomaly traces
11+
|
12+
return .csv / .json for further visualization
13+
'''

TokenReplay.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import AttributePNet as pNet
2+
3+
4+
class TokenRaplay(object):
5+
def __init__(self, net):
6+
self.net = net
7+
8+
self.consumed = 0
9+
self.produced = 0
10+
self.miss = 0
11+
self.remain = 0
12+
13+
def replay_log(self, tracelog):
14+
current_model_position = self.net.startPlace
15+
current_log_event=tracelog.iloc[0]['event_type']
16+
17+
for row_counter in range(tracelog.shape[0]):

events_to_transitions.csv

+117
Large diffs are not rendered by default.

venv/bin/activate

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# This file must be used with "source bin/activate" *from bash*
2+
# you cannot run it directly
3+
4+
deactivate () {
5+
# reset old environment variables
6+
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7+
PATH="${_OLD_VIRTUAL_PATH:-}"
8+
export PATH
9+
unset _OLD_VIRTUAL_PATH
10+
fi
11+
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12+
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13+
export PYTHONHOME
14+
unset _OLD_VIRTUAL_PYTHONHOME
15+
fi
16+
17+
# This should detect bash and zsh, which have a hash command that must
18+
# be called to get it to forget past commands. Without forgetting
19+
# past commands the $PATH changes we made may not be respected
20+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21+
hash -r
22+
fi
23+
24+
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
25+
PS1="${_OLD_VIRTUAL_PS1:-}"
26+
export PS1
27+
unset _OLD_VIRTUAL_PS1
28+
fi
29+
30+
unset VIRTUAL_ENV
31+
if [ ! "$1" = "nondestructive" ] ; then
32+
# Self destruct!
33+
unset -f deactivate
34+
fi
35+
}
36+
37+
# unset irrelevant variables
38+
deactivate nondestructive
39+
40+
VIRTUAL_ENV="/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv"
41+
export VIRTUAL_ENV
42+
43+
_OLD_VIRTUAL_PATH="$PATH"
44+
PATH="$VIRTUAL_ENV/bin:$PATH"
45+
export PATH
46+
47+
# unset PYTHONHOME if set
48+
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
49+
# could use `if (set -u; : $PYTHONHOME) ;` in bash
50+
if [ -n "${PYTHONHOME:-}" ] ; then
51+
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
52+
unset PYTHONHOME
53+
fi
54+
55+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
56+
_OLD_VIRTUAL_PS1="${PS1:-}"
57+
if [ "x(venv) " != x ] ; then
58+
PS1="(venv) ${PS1:-}"
59+
else
60+
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
61+
# special case for Aspen magic directories
62+
# see http://www.zetadev.com/software/aspen/
63+
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
64+
else
65+
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
66+
fi
67+
fi
68+
export PS1
69+
fi
70+
71+
# This should detect bash and zsh, which have a hash command that must
72+
# be called to get it to forget past commands. Without forgetting
73+
# past commands the $PATH changes we made may not be respected
74+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
75+
hash -r
76+
fi

venv/bin/activate.csh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file must be used with "source bin/activate.csh" *from csh*.
2+
# You cannot run it directly.
3+
# Created by Davide Di Blasi <[email protected]>.
4+
# Ported to Python 3.3 venv by Andrew Svetlov <[email protected]>
5+
6+
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
7+
8+
# Unset irrelevant variables.
9+
deactivate nondestructive
10+
11+
setenv VIRTUAL_ENV "/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv"
12+
13+
set _OLD_VIRTUAL_PATH="$PATH"
14+
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
15+
16+
17+
set _OLD_VIRTUAL_PROMPT="$prompt"
18+
19+
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
20+
if ("venv" != "") then
21+
set env_name = "venv"
22+
else
23+
if (`basename "VIRTUAL_ENV"` == "__") then
24+
# special case for Aspen magic directories
25+
# see http://www.zetadev.com/software/aspen/
26+
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
27+
else
28+
set env_name = `basename "$VIRTUAL_ENV"`
29+
endif
30+
endif
31+
set prompt = "[$env_name] $prompt"
32+
unset env_name
33+
endif
34+
35+
alias pydoc python -m pydoc
36+
37+
rehash

venv/bin/activate.fish

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
2+
# you cannot run it directly
3+
4+
function deactivate -d "Exit virtualenv and return to normal shell environment"
5+
# reset old environment variables
6+
if test -n "$_OLD_VIRTUAL_PATH"
7+
set -gx PATH $_OLD_VIRTUAL_PATH
8+
set -e _OLD_VIRTUAL_PATH
9+
end
10+
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11+
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12+
set -e _OLD_VIRTUAL_PYTHONHOME
13+
end
14+
15+
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16+
functions -e fish_prompt
17+
set -e _OLD_FISH_PROMPT_OVERRIDE
18+
functions -c _old_fish_prompt fish_prompt
19+
functions -e _old_fish_prompt
20+
end
21+
22+
set -e VIRTUAL_ENV
23+
if test "$argv[1]" != "nondestructive"
24+
# Self destruct!
25+
functions -e deactivate
26+
end
27+
end
28+
29+
# unset irrelevant variables
30+
deactivate nondestructive
31+
32+
set -gx VIRTUAL_ENV "/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv"
33+
34+
set -gx _OLD_VIRTUAL_PATH $PATH
35+
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
36+
37+
# unset PYTHONHOME if set
38+
if set -q PYTHONHOME
39+
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
40+
set -e PYTHONHOME
41+
end
42+
43+
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
44+
# fish uses a function instead of an env var to generate the prompt.
45+
46+
# save the current fish_prompt function as the function _old_fish_prompt
47+
functions -c fish_prompt _old_fish_prompt
48+
49+
# with the original prompt function renamed, we can override with our own.
50+
function fish_prompt
51+
# Save the return status of the last command
52+
set -l old_status $status
53+
54+
# Prompt override?
55+
if test -n "(venv) "
56+
printf "%s%s" "(venv) " (set_color normal)
57+
else
58+
# ...Otherwise, prepend env
59+
set -l _checkbase (basename "$VIRTUAL_ENV")
60+
if test $_checkbase = "__"
61+
# special case for Aspen magic directories
62+
# see http://www.zetadev.com/software/aspen/
63+
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
64+
else
65+
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
66+
end
67+
end
68+
69+
# Restore the return status of the previous command.
70+
echo "exit $old_status" | .
71+
_old_fish_prompt
72+
end
73+
74+
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
75+
end

venv/bin/easy_install

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv/bin/python
2+
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==40.8.0','console_scripts','easy_install'
3+
__requires__ = 'setuptools==40.8.0'
4+
import re
5+
import sys
6+
from pkg_resources import load_entry_point
7+
8+
if __name__ == '__main__':
9+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10+
sys.exit(
11+
load_entry_point('setuptools==40.8.0', 'console_scripts', 'easy_install')()
12+
)

venv/bin/easy_install-3.7

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv/bin/python
2+
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==40.8.0','console_scripts','easy_install-3.7'
3+
__requires__ = 'setuptools==40.8.0'
4+
import re
5+
import sys
6+
from pkg_resources import load_entry_point
7+
8+
if __name__ == '__main__':
9+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10+
sys.exit(
11+
load_entry_point('setuptools==40.8.0', 'console_scripts', 'easy_install-3.7')()
12+
)

venv/bin/f2py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv/bin/python
2+
# -*- coding: utf-8 -*-
3+
import re
4+
import sys
5+
6+
from numpy.f2py.f2py2e import main
7+
8+
if __name__ == '__main__':
9+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10+
sys.exit(main())

venv/bin/f2py3

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv/bin/python
2+
# -*- coding: utf-8 -*-
3+
import re
4+
import sys
5+
6+
from numpy.f2py.f2py2e import main
7+
8+
if __name__ == '__main__':
9+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10+
sys.exit(main())

venv/bin/f2py3.7

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/Users/alexandrakolosova/Documents/HSE/Diploma/app/AttributePNet/venv/bin/python
2+
# -*- coding: utf-8 -*-
3+
import re
4+
import sys
5+
6+
from numpy.f2py.f2py2e import main
7+
8+
if __name__ == '__main__':
9+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
10+
sys.exit(main())

0 commit comments

Comments
 (0)