Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mtp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SPARSA ROYCHOWDHURY
mtp
Commits
3b55dd85
Commit
3b55dd85
authored
Jul 05, 2017
by
SPARSA ROYCHOWDHURY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5/7/2017
Trying to implement the reduceShuffle function for Zone method
parent
94fcef90
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
21 deletions
+86
-21
include/tpdaZone.h
include/tpdaZone.h
+1
-0
nbproject/private/private.xml
nbproject/private/private.xml
+2
-0
src/tpdaZone.cpp
src/tpdaZone.cpp
+83
-21
No files found.
include/tpdaZone.h
View file @
3b55dd85
...
@@ -35,6 +35,7 @@ class stateZone{
...
@@ -35,6 +35,7 @@ class stateZone{
// return shuffle of this state with s2
// return shuffle of this state with s2
stateZone
*
shuffle
(
stateZone
*
s2
);
stateZone
*
shuffle
(
stateZone
*
s2
);
stateZone
*
reduceShuffle
(
stateZone
*
s2
);
// Return the first successor state whoose childrens will be right state for shuffle with current state
// Return the first successor state whoose childrens will be right state for shuffle with current state
stateZone
*
sucState
();
stateZone
*
sucState
();
...
...
nbproject/private/private.xml
View file @
3b55dd85
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
<open-files
xmlns=
"http://www.netbeans.org/ns/projectui-open-files/2"
>
<open-files
xmlns=
"http://www.netbeans.org/ns/projectui-open-files/2"
>
<group>
<group>
<file>
file:/home/sparsa/Programming/mtp/src/tpdaZone.cpp
</file>
<file>
file:/home/sparsa/Programming/mtp/src/tpdaZone.cpp
</file>
<file>
file:/home/sparsa/Programming/mtp/src/tpdaCGPP.cpp
</file>
<file>
file:/home/sparsa/Programming/mtp/include/tpdaZone.h
</file>
</group>
</group>
</open-files>
</open-files>
</project-private>
</project-private>
src/tpdaZone.cpp
View file @
3b55dd85
...
@@ -119,9 +119,10 @@ bool identity(stateZone *vs) {
...
@@ -119,9 +119,10 @@ bool identity(stateZone *vs) {
stateZone
*
stateZone
::
reduceShuffle
(
stateZone
*
s2
)
{
stateZone
*
stateZone
::
reduceShuffle
(
stateZone
*
s2
)
{
char
*
del2
=
s2
->
del
,
*
w2
=
s2
->
w
;
char
*
del2
=
s2
->
del
,
*
w2
=
s2
->
w
;
char
P2
=
s2
->
P
,
L2
=
s2
->
L
;
char
P2
=
s2
->
P
;
short
f2
=
s2
->
f
;
short
f2
=
s2
->
f
;
short
L
=
f
&
127
;
short
L2
=
f2
&
127
;
short
curReset
,
reset
,
tempReset
;
// temp variables to keep reset for a range of points
short
curReset
,
reset
,
tempReset
;
// temp variables to keep reset for a range of points
char
count
=
0
;
// used for storing #points in new state
char
count
=
0
;
// used for storing #points in new state
char
i
,
j
;
// loopers
char
i
,
j
;
// loopers
...
@@ -151,11 +152,11 @@ stateZone* stateZone::reduceShuffle(stateZone* s2) {
...
@@ -151,11 +152,11 @@ stateZone* stateZone::reduceShuffle(stateZone* s2) {
// (s2->P - s2-> L) comes from : all points s2->L+1 to s2->P are there in new state
// (s2->P - s2-> L) comes from : all points s2->L+1 to s2->P are there in new state
count
+=
L
+
(
P2
-
L2
);
// #points in new state
count
+=
L
+
(
P2
-
L2
);
// #points in new state
state
GCPP
*
vs
=
new
stateGCPP
();
// new TA state
state
Zone
*
vs
=
new
stateZone
();
// new TA state
vs
->
del
=
new
char
[
count
];
// allocate memory
vs
->
del
=
new
char
[
count
];
// allocate memory
vs
->
w
=
new
char
[
count
];
vs
->
w
=
new
char
[
count
*
(
count
-
1
)];
//this will hold the matrix without the diagonal element
vs
->
L
=
L
;
vs
->
f
=
f
;
//f contains the push complete command flag bit along with the value of L
short
nf
=
0
;
// initially flag is zero
short
nf
=
0
;
// initially flag is zero
short
dis
;
// distance variable
short
dis
;
// distance variable
...
@@ -164,26 +165,87 @@ stateZone* stateZone::reduceShuffle(stateZone* s2) {
...
@@ -164,26 +165,87 @@ stateZone* stateZone::reduceShuffle(stateZone* s2) {
// Here we are copying points from s2->L+1 to s2->P of 2nd state to new state
// Here we are copying points from s2->L+1 to s2->P of 2nd state to new state
for
(
i
=
P2
-
1
;
i
>=
L2
;
i
--
,
j
--
)
{
for
(
i
=
P2
-
1
;
i
>=
L2
;
i
--
,
j
--
)
{
vs
->
del
[
j
]
=
del2
[
i
];
// copy (i+1)-th transition to (j+1) transition of new state
vs
->
del
[
j
]
=
del2
[
i
];
// copy (i+1)-th transition to (j+1) transition of new state
vs
->
w
[
j
]
=
w2
[
i
];
// copy (i+1)-th tsm to (j+1) tsm of new state
//
vs->w[j] = w2[i]; // copy (i+1)-th tsm to (j+1) tsm of new state
//for zone the W contains the details of matrix which we need to copy and check for negetive cycle
// if distance (i+1)->(i+2) of 2nd state is accurate, then distance (j+1)->(j+2) of new state is accurate
// if distance (i+1)->(i+2) of 2nd state is accurate, then distance (j+1)->(j+2) of new state is accurate
if
(
f2
&
a32
[
i
+
1
]
)
//
if( f2 & a32[i+1] )
nf
|=
a32
[
j
+
1
];
//
nf |= a32[j+1];
}
}
// Here we are copying points from 1 to L-1 of 1st state to new state
// Here we are copying points from 1 to L-1 of 1st state to new state
for
(
j
=
0
;
j
<
(
L
-
1
);
j
++
)
{
for
(
j
=
0
;
j
<
(
L
-
1
);
j
++
)
{
vs
->
del
[
j
]
=
del
[
j
];
vs
->
del
[
j
]
=
del
[
j
];
vs
->
w
[
j
]
=
w
[
j
];
//
vs->w[j] = w[j];
// same reasons as above
// if distance (j+1)->(j+2) of 1st state is accurate, then distance (j+1)->(j+2) of new state is accurate
// if distance (j+1)->(j+2) of 1st state is accurate, then distance (j+1)->(j+2) of new state is accurate
nf
|=
(
f
&
a32
[
j
+
1
]
);
//nf |= ( f & a32[j+1] ); // here f means some thing different
}
}
//copy the point L, doing it separately because of the flag variable which is not applicable for L-th point
//copy the point L, doing it separately because of the flag variable which is not applicable for L-th point
vs
->
del
[
L
-
1
]
=
del
[
L
-
1
];
vs
->
del
[
L
-
1
]
=
del
[
L
-
1
];
vs
->
w
[
L
-
1
]
=
w
[
L
-
1
];
//vs->w[L-1] = w[L-1]; w doesnot contains time stamps any more it contains the matrix
//Here goes the logic of creating the matrix altogether with given values.
// copy weights of first state to WT1
for
(
i
=
0
;
i
<
P
;
i
++
)
{
for
(
j
=
0
;
j
<
P
;
j
++
)
{
if
(
i
==
j
)
{
//same transition points
WT1
[
i
][
i
]
=
0
;
open1
[
i
][
i
]
=
false
;
}
else
if
(
i
<
j
)
{
WT1
[
i
][
j
]
=
w
[
index
(
i
,
j
,
P
)]
&
(
~
a32
[
15
]);
// 15-TH bit is used for open or not
if
(
w
[
index
(
i
,
j
,
P
)]
&
a32
[
15
]
)
// as 15th bit is used for open and close interval
open1
[
i
][
j
]
=
true
;
else
open1
[
i
][
j
]
=
false
;
}
else
{
///when i > j i.e the edges coming from j to i it must be negetive.
WT1
[
i
][
j
]
=
-
(
w
[
index
(
i
,
j
,
P
)]
&
(
~
a32
[
15
])
);
// 15-TH bit is used for open or not
if
(
w
[
index
(
i
,
j
,
P
)]
&
a32
[
15
]
)
open1
[
i
][
j
]
=
true
;
else
open1
[
i
][
j
]
=
false
;
}
}
}
//copy weights of second state to WT1
// copy weights of current state to WT1
for
(
i
=
P
;
i
<
count
;
i
++
)
{
for
(
j
=
P
;
j
<
count
;
j
++
)
{
if
(
i
==
j
)
{
//same transition points
WT1
[
i
][
i
]
=
0
;
open1
[
i
][
i
]
=
false
;
}
else
if
(
i
<
j
)
{
WT1
[
i
][
j
]
=
w
[
index
((
i
-
P
),
(
j
-
P
),
P2
)]
&
(
~
a32
[
15
]);
// 15-TH bit is used for open or not
if
(
w
[
index
((
i
-
P
),
(
j
-
P
),
P2
)]
&
a32
[
15
]
)
// as 15th bit is used for open and close interval
open1
[
i
][
j
]
=
true
;
else
open1
[
i
][
j
]
=
false
;
}
else
{
///when i > j i.e the edges coming from j to i it must be negetive.
WT1
[
i
][
j
]
=
-
(
w
[
index
((
i
-
P
),
(
j
-
P
),
P2
)]
&
(
~
a32
[
15
])
);
// 15-TH bit is used for open or not
if
(
w
[
index
((
i
-
P
),
(
j
-
P
),
P2
)]
&
a32
[
15
]
)
open1
[
i
][
j
]
=
true
;
else
open1
[
i
][
j
]
=
false
;
}
}
}
//both the matrices is copied to the variable,
//here P = L2 Now we have to check the check points and their
//recent reset points
//now there are some hangng edges which are
// Now we watch out for points from L+1 to P of 1st state
// Now we watch out for points from L+1 to P of 1st state
char
lastindex
=
P
;
// last index of the point we have taken so far, although P might not be included
char
lastindex
=
P
;
// last index of the point we have taken so far, although P might not be included
...
@@ -272,7 +334,7 @@ bool stateZone::shuffleCheck(stateZone *s2) {
...
@@ -272,7 +334,7 @@ bool stateZone::shuffleCheck(stateZone *s2) {
// shuffle of this state with state s2 and return the new state
// shuffle of this state with state s2 and return the new state
state
GCPP
*
stateGCPP
::
shuffle
(
stateGCPP
*
s2
){
// shuffle with state s2
state
Zone
*
stateZone
::
shuffle
(
stateZone
*
s2
){
// shuffle with state s2
if
(
!
shuffleCheck
(
s2
)
)
if
(
!
shuffleCheck
(
s2
)
)
return
NULL
;
return
NULL
;
...
@@ -501,7 +563,7 @@ stateZone* stateZone::addNextTPDA(char dn) {
...
@@ -501,7 +563,7 @@ stateZone* stateZone::addNextTPDA(char dn) {
WT
=
WT1
;
WT
=
WT1
;
open
=
open1
;
open
=
open1
;
}
}
else
{
// if P is
odd, the shortest path stored in WT1 and open1
else
{
// if P is
even, the shortest path stored in WT2 and open2
WT
=
WT2
;
WT
=
WT2
;
open
=
open2
;
open
=
open2
;
}
}
...
@@ -815,13 +877,13 @@ runCGPP* runCGPP::shuffle(runCGPP *s2) {
...
@@ -815,13 +877,13 @@ runCGPP* runCGPP::shuffle(runCGPP *s2) {
// this will return a state with only 0-th transition with tsm value 0
// this will return a state with only 0-th transition with tsm value 0
stateZone
*
getZeroStateZone
()
{
stateZone
*
getZeroStateZone
()
{
stateZone
*
vs
=
new
stateZone
();
stateZone
*
vs
=
new
stateZone
();
//initialize a stateZone object
vs
->
P
=
1
;
vs
->
P
=
1
;
//the first point
vs
->
f
=
1
;
// no push pop info yet and L = 1
vs
->
f
=
1
;
// no push pop info yet and L = 1
cause the last bit of the flag denotes the push complete information
vs
->
del
=
new
char
[
1
];
// memory allocation
vs
->
del
=
new
char
[
1
];
// memory allocation
for the transitions
vs
->
w
=
NULL
;
vs
->
w
=
NULL
;
//the 2-dimentional array projected in to one dimentional arry initially empty
vs
->
del
[
0
]
=
0
;
// 0th transition has tsm value 0
vs
->
del
[
0
]
=
0
;
// 0th transition has tsm value 0
...
@@ -1009,7 +1071,7 @@ bool isEmptyZone() {
...
@@ -1009,7 +1071,7 @@ bool isEmptyZone() {
stateZone
*
rs
,
*
vs
,
*
vs1
,
*
vs2
;
// some state variables required for track
stateZone
*
rs
,
*
vs
,
*
vs1
,
*
vs2
;
// some state variables required for track
trackZone
*
xrs
;
// back propaga
r
ion state variable
trackZone
*
xrs
;
// back propaga
t
ion state variable
runZone
*
prs
;
// variable for partial run of the TPDA
runZone
*
prs
;
// variable for partial run of the TPDA
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment