Commit 67a3c636 authored by SPARSA ROYCHOWDHURY's avatar SPARSA ROYCHOWDHURY

25/10/17:

1. Solved a serious Bug in reduce2 
2. But still have to find the special case bug.
Sparsa Roychowdhury
parent 431808ab
No preview for this file type
...@@ -62,7 +62,9 @@ public: ...@@ -62,7 +62,9 @@ public:
~CircuitFinder() ~CircuitFinder()
{ {
for(int i = 0;i < N; i++) for(int i = 0;i < N; i++)
{
delete[] relmatrix[i]; delete[] relmatrix[i];
}
delete[] relmatrix; delete[] relmatrix;
} }
bool run(); //start the run bool run(); //start the run
......
3 2 1 0 0
1
3
1 2 0 0 1
1
0
2 3 0 1 0
1 1 1 1 1
0
digraph finite_state_machine {
node [shape = point ]; qi0;
node [shape = doublecircle];3;
node [shape=circle];
qi0 -> 0;
0 -> 1 [ label = "{tn:0,x1:=0}" ];
1 -> 2 [ label = "{tn:1,x1:=0}" ];
2 -> 3 [ label = "{tn:2,1<x1<1}" ];
}
\ No newline at end of file
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
0 0
2 3 0 1 0 2 3 0 1 0
1 1 0 2 0 1 1 0 2 1
0 0
4 3 2 0 0
1
4
1 2 0 0 1
1
0
2 3 0 1 0
1 0 0 1 1
0
3 4 0 2 0
1 1 1 -1 1
2 0 0 1 1
0
digraph finite_state_machine {
node [shape = point ]; qi0;
node [shape = doublecircle];4;
node [shape=circle];
qi0 -> 0;
0 -> 1 [ label = "{tn:0,x1:=0,x2:=0}" ];
1 -> 2 [ label = "{tn:1,x1:=0}" ];
2 -> 3 [ label = "{tn:2,0<=x1<1}" ];
3 -> 4 [ label = "{tn:3,1<x1<inf,0<=x2<1}" ];
}
\ No newline at end of file
...@@ -52,7 +52,7 @@ inline unsigned int p2(unsigned int x) { ...@@ -52,7 +52,7 @@ inline unsigned int p2(unsigned int x) {
// string to integer conversion // string to integer conversion
int str_to_int(string s) { int str_to_int(string s) {
int sum = 0; int sum = 0;
for(int i=0; i < s.size(); i++) { for(unsigned int i=0; i < s.size(); i++) {
sum = sum*10 + s[i]-'0'; sum = sum*10 + s[i]-'0';
} }
return sum; return sum;
...@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) { ...@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
////**********//// ////**********////
setGlobal(argv[1]); // set all the global variables setGlobal(argv[1]); // set all the global variables
bool b,b1; bool b;
if(argc >= 3) { // If there is any arguments for special kind of TPDA if(argc >= 3) { // If there is any arguments for special kind of TPDA
......
CC := g++ CC := g++
CFLAG := -lm -fopenmp -Wall -std=c++14 CFLAG := -lm -fopenmp -std=c++14
SRC := ./src SRC := ./src
OBJ := ./obj OBJ := ./obj
INC := ./include INC := ./include
...@@ -30,7 +30,7 @@ $(OBJ)/pds.o : $(SRC)/pds.cpp ...@@ -30,7 +30,7 @@ $(OBJ)/pds.o : $(SRC)/pds.cpp
$(CC) $(GDB) -I $(INC) -c $(SRC)/pds.cpp -o $(OBJ)/pds.o $(CFLAG) $(CC) $(GDB) -I $(INC) -c $(SRC)/pds.cpp -o $(OBJ)/pds.o $(CFLAG)
drawsystem : $(OBJ)/drawsystem.o $(OBJ)/treeBitOperations.o drawsystem : $(OBJ)/drawsystem.o $(OBJ)/treeBitOperations.o
$(CC $(GDB) $(OBJ)/drawsystem.o $(OBJ)/treeBitOperations.o -o drawsystem $(CFLAG) $(CC) $(GDB) $(OBJ)/drawsystem.o $(OBJ)/treeBitOperations.o -o drawsystem $(CFLAG)
$(OBJ)/drawsystem.o : $(SRC)/drawsystem.cpp $(OBJ)/drawsystem.o : $(SRC)/drawsystem.cpp
$(CC) $(GDB) -I $(INC) -c $(SRC)/drawsystem.cpp -o $(OBJ)/drawsystem.o $(CFLAG) $(CC) $(GDB) -I $(INC) -c $(SRC)/drawsystem.cpp -o $(OBJ)/drawsystem.o $(CFLAG)
......
...@@ -45,7 +45,7 @@ bool** pushDone; ...@@ -45,7 +45,7 @@ bool** pushDone;
// make a dfs from a reset transition to find some checked transition for clock x // make a dfs from a reset transition to find some checked transition for clock x
void getChecker(short int acttran, bool *visit, short int i, char x, bool *flag) { void getChecker(short int acttran, bool *visit, short int i, char x, bool *flag) {
short int s = transitions[i].target; short int s = transitions[i].target;
for(int j=0; j < nexttrans[s].size(); j++) { for(unsigned int j=0; j < nexttrans[s].size(); j++) {
short int t = nexttrans[s][j]; short int t = nexttrans[s][j];
if( isChecked(x, t) && !(*flag) && acttran == t) { if( isChecked(x, t) && !(*flag) && acttran == t) {
...@@ -72,7 +72,7 @@ void getChecker(short int acttran, bool *visit, short int i, char x, bool *flag) ...@@ -72,7 +72,7 @@ void getChecker(short int acttran, bool *visit, short int i, char x, bool *flag)
void getresecktrans() { void getresecktrans() {
bool *visit = new bool[T+1]; bool *visit = new bool[T+1];
int i,j; unsigned int i,j;
resecktrans.resize(X+1); resecktrans.resize(X+1);
bool flag = false; bool flag = false;
...@@ -101,7 +101,7 @@ void getresecktrans() { ...@@ -101,7 +101,7 @@ void getresecktrans() {
// if d1 and d2 are valid pair of reset-check for only clock x1(used for one clock + one stack special tpda) // if d1 and d2 are valid pair of reset-check for only clock x1(used for one clock + one stack special tpda)
bool isPossibleReset(char d1, char d2){ bool isPossibleReset(char d1, char d2){
for(char i=0; i < possibleresets[d2].size(); i++) { for(unsigned int i=0; i < possibleresets[d2].size(); i++) {
if(d1 == (possibleresets[d2][i]) ) if(d1 == (possibleresets[d2][i]) )
return true; return true;
} }
...@@ -171,7 +171,7 @@ void inputSystem() { ...@@ -171,7 +171,7 @@ void inputSystem() {
transitions[0].openl =0; transitions[0].openl =0;
transitions[0].openu = 0; transitions[0].openu = 0;
// Reset all clocks at 0-th transition // Reset all clocks at 0-th transition
transitions[0].reset = ( b32[X] & (~1) ); transitions[0].reset = ( b32[int(X)] & (~1) );
resettrans.resize(X+1); // used for earlier code resettrans.resize(X+1); // used for earlier code
checktrans.resize(X+1); // used for earlier checktrans.resize(X+1); // used for earlier
...@@ -407,10 +407,10 @@ void inputSystem() { ...@@ -407,10 +407,10 @@ void inputSystem() {
//******* forget this //******* forget this
pushDone = new bool*[T+1]; pushDone = new bool*[T+1];
for(char t=0; t <= T; t++){ for(unsigned int t=0; t <= T; t++){
pushDone[t] = new bool[M]; pushDone[t] = new bool[M];
for(char w=0; w < M; w++) { for(char w=0; w < M; w++) {
pushDone[t][w] = false; pushDone[t][int(w)] = false;
} }
} }
...@@ -532,7 +532,7 @@ void print_system() { ...@@ -532,7 +532,7 @@ void print_system() {
// is clock x has been reset at transition d // is clock x has been reset at transition d
bool isReset(char x, short int d) { bool isReset(char x, short int d) {
if( (transitions[d].reset) & a32[x]) if( (transitions[d].reset) & a32[ int(x)])
return true; return true;
return false; return false;
} }
...@@ -540,7 +540,7 @@ bool isReset(char x, short int d) { ...@@ -540,7 +540,7 @@ bool isReset(char x, short int d) {
// is clock x has been checked at transition delta // is clock x has been checked at transition delta
bool isChecked(char x, short int d) { bool isChecked(char x, short int d) {
if( (transitions[d].guard) & a32[x]) if( (transitions[d].guard) & a32[ int(x)])
return true; return true;
return false; return false;
} }
......
...@@ -190,11 +190,11 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -190,11 +190,11 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
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
map[j] = map_p2[i]; map[j] = map_p2[i];
// for(char a=P2-1, b = count-1; a>=L2; a--,b--) // for(char a=P2-1, b = count-1; a>=L2; a--,b--)
// { // {
// if(vs->r_matrix[j][b] > s2->r_matrix[i][a]) // if(vs->r_matrix[j][b] > s2->r_matrix[i][a])
// vs->r_matrix[j][b] = s2->r_matrix[i][a]; // vs->r_matrix[j][b] = s2->r_matrix[i][a];
// } // }
// 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];
...@@ -205,11 +205,11 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -205,11 +205,11 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
vs->del[j] = del[j]; vs->del[j] = del[j];
vs->w[j] = w[j]; vs->w[j] = w[j];
map[j] = map_p1[j]; map[j] = map_p1[j];
// for(int a = 0 ; a < (L-1) ; a ++) // for(int a = 0 ; a < (L-1) ; a ++)
// { // {
// if(vs->r_matrix[j][a] > r_matrix[j][a]) // if(vs->r_matrix[j][a] > r_matrix[j][a])
// vs->r_matrix[j][a] = r_matrix[j][a]; // vs->r_matrix[j][a] = r_matrix[j][a];
// } // }
// 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] );
} }
...@@ -218,11 +218,11 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -218,11 +218,11 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
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];
map[L-1] = map_p1[L-1]; map[L-1] = map_p1[L-1];
// for(int i = 0 ; i < L ;i++) // for(int i = 0 ; i < L ;i++)
// { // {
// vs->r_matrix[vs->P-1][i] = r_matrix[P-1][i]; // vs->r_matrix[vs->P-1][i] = r_matrix[P-1][i];
// vs->r_matrix[i][vs->P-1] = r_matrix[i][P-1]; // vs->r_matrix[i][vs->P-1] = r_matrix[i][P-1];
// } // }
// 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
...@@ -236,17 +236,17 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -236,17 +236,17 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
vs->del[j] = del[i]; vs->del[j] = del[i];
vs->w[j] = w[i]; vs->w[j] = w[i];
map[j] = map_p1[j]; map[j] = map_p1[j];
// char b = (count -1) - (P2 - L2); // char b = (count -1) - (P2 - L2);
// for(char a = P-1; a >= L; a--) // for(char a = P-1; a >= L; a--)
// { // {
// reset2 = (transitions[del[a]].reset); // reset2 = (transitions[del[a]].reset);
// if(reset2 &(!curReset2) & ~(1)) // if(reset2 &(!curReset2) & ~(1))
// { // {
// vs->r_matrix[j][b] = r_matrix[i][a]; // vs->r_matrix[j][b] = r_matrix[i][a];
// curReset2 |= reset2; // curReset2 |= reset2;
// b--; // b--;
// } // }
// } // }
if( lastindex == P ) { // if (i+1) is the first point we are considering after starting the loop if( lastindex == P ) { // if (i+1) is the first point we are considering after starting the loop
// In if : first check is for accuracy check from L to P of left state // In if : first check is for accuracy check from L to P of left state
// In if : second check is for cheking accuracy from L2 to L2+1 of right state, L2 is not choosen // In if : second check is for cheking accuracy from L2 to L2+1 of right state, L2 is not choosen
...@@ -293,8 +293,8 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -293,8 +293,8 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
vs->f = nf; // add the flag variable also vs->f = nf; // add the flag variable also
//vs->P = count; // #points in new state //vs->P = count; // #points in new state
//cout << int(count) << "the cound " << endl; //cout << int(count) << "the cound " << endl;
// for(char i = 0 ; i < count ; i++) // for(char i = 0 ; i < count ; i++)
// cout << int(map[i]) << endl; // cout << int(map[i]) << endl;
for(char i = 0; i < count ; i ++) for(char i = 0; i < count ; i ++)
for(char j = 0 ; j < count ; j++) for(char j = 0 ; j < count ; j++)
...@@ -584,82 +584,82 @@ stateGCPP* stateGCPP::reduce1(){ ...@@ -584,82 +584,82 @@ stateGCPP* stateGCPP::reduce1(){
// return true if constraint on new transition dn with tsm wn is satisfied while adding current transiton 'dn' to the right // return true if constraint on new transition dn with tsm wn is satisfied while adding current transiton 'dn' to the right
bool stateGCPP::consSatisfied(stateGCPP* vs,char dn, char wn, short *clockDis, bool *clockAcc) { bool stateGCPP::consSatisfied(stateGCPP* vs,char dn, char wn, short *clockDis, bool *clockAcc) {
short dis; short dis;
// int openl,openu; // int openl,openu;
// openl = transitions[dn].openl; // openl = transitions[dn].openl;
// openu = transitions[dn].openu; // openu = transitions[dn].openu;
// relation **store_matrix = allocate_r_matrix(vs->P); // relation **store_matrix = allocate_r_matrix(vs->P);
// //cout <<"Hi I am called" << endl; // //cout <<"Hi I am called" << endl;
// // cout << dn << wn << endl; // // cout << dn << wn << endl;
// for(char i = 0 ;i < vs->P; i++) // for(char i = 0 ;i < vs->P; i++)
// { // {
// for(char j = 0; j < vs->P; j++) // for(char j = 0; j < vs->P; j++)
// { // {
// store_matrix[i][j] = vs->r_matrix[i][j]; //storing values of the relation matrix to detect any cycle with single les symbol in it. // store_matrix[i][j] = vs->r_matrix[i][j]; //storing values of the relation matrix to detect any cycle with single les symbol in it.
// //cout << store_matrix[i][j] << endl; // //cout << store_matrix[i][j] << endl;
// } // }
// } // }
// bool flag1; // bool flag1;
// cout << int(dn) << endl; // cout << int(dn) << endl;
// cout << int(wn) << endl; // cout << int(wn) << endl;
// cout << endl; // cout << endl;
//#pragma openmp parallel for //#pragma openmp parallel for
for(char x=1; x <= X; x++) { for(char x=1; x <= X; x++) {
if( isChecked(x, dn) ) { // if there is a check for clock x if( isChecked(x, dn) ) { // if there is a check for clock x
if( clockAcc[x] ) { // if distance from last reset of clock x to point P is accurate if( clockAcc[x] ) { // if distance from last reset of clock x to point P is accurate
dis = clockDis[x] + mod( wn - w[P-1], M ) ; dis = clockDis[x] + mod( wn - w[P-1], M ) ;
// if( (vs->P) > 1 && ( (vs->f) & a32[vs->P - 1] ) ) { // if( (vs->P) > 1 && ( (vs->f) & a32[vs->P - 1] ) ) {
// /*********************#***************/ // /*********************#***************/
// dis_l = vs->w[vs->P - 1] + mod(wn - w[P-1], M); //distance with the last point // dis_l = vs->w[vs->P - 1] + mod(wn - w[P-1], M); //distance with the last point
// } // }
//char t = vs->reset_point(dn,x); //? //char t = vs->reset_point(dn,x); //?
if( dis < (transitions[dn].lbs[x] ) || dis > (transitions[dn].ubs[x] ) ) if( dis < (transitions[dn].lbs[x] ) || dis > (transitions[dn].ubs[x] ) )
{//if the distance doesnot belong to the interval {//if the distance doesnot belong to the interval
//delete_r_matrix(store_matrix,vs->P); // this one added extra //delete_r_matrix(store_matrix,vs->P); // this one added extra
return false; return false;
} }
// if( dis == transitions[dn].lbs[x]) //checking if the distance is equal to the upper value and the constraint is open. // if( dis == transitions[dn].lbs[x]) //checking if the distance is equal to the upper value and the constraint is open.
// { // {
// //
// if((openl & a32[x])) //this condition is open // if((openl & a32[x])) //this condition is open
// { // {
// //
// if(store_matrix[t][vs->P-1]> les) // if(store_matrix[t][vs->P-1]> les)
// store_matrix[t][vs->P-1] = les; // store_matrix[t][vs->P-1] = les;
// } // }
// else //this condition is closed // else //this condition is closed
// { // {
// if(store_matrix[t][vs->P-1] > leq) // if(store_matrix[t][vs->P-1] > leq)
// store_matrix[t][vs->P-1] = leq; // store_matrix[t][vs->P-1] = leq;
// } // }
// //
// } // }
// if(dis == transitions[dn].ubs[x]) // if(dis == transitions[dn].ubs[x])
// { // {
// if((openu & a32[x])) // this condition is open // if((openu & a32[x])) // this condition is open
// { // {
// if(store_matrix[vs->P-1][t]> les) // if(store_matrix[vs->P-1][t]> les)
// store_matrix[vs->P-1][t] = les; // store_matrix[vs->P-1][t] = les;
// //flag1 = true; // //flag1 = true;
// } // }
// else // this condition is closed. // else // this condition is closed.
// { // {
// if(store_matrix[vs->P-1][t] > leq) // if(store_matrix[vs->P-1][t] > leq)
// store_matrix[vs->P-1][t] = leq; // store_matrix[vs->P-1][t] = leq;
// } // }
// //
// } // }
// if(dis_l == 0) // if(dis_l == 0)
// { // {
// store_matrix[vs->P-2][vs->P-1] = leq; // store_matrix[vs->P-2][vs->P-1] = leq;
// } // }
// if(flag1) // if(flag1)
// cout << endl; // cout << endl;
// print_r_matrix(store_matrix,vs->P); // print_r_matrix(store_matrix,vs->P);
// pairWiseTightestRelation(store_matrix,vs->P); // pairWiseTightestRelation(store_matrix,vs->P);
// if(flag1) // if(flag1)
// print_r_matrix(store_matrix,vs->P); // print_r_matrix(store_matrix,vs->P);
else if(dis == (transitions[dn].lbs[x] ) || dis == (transitions[dn].ubs[x] )) else if(dis == (transitions[dn].lbs[x] ) || dis == (transitions[dn].ubs[x] ))
{ {
CircuitFinder cf(vs->r_matrix,vs->P); CircuitFinder cf(vs->r_matrix,vs->P);
...@@ -681,15 +681,15 @@ bool stateGCPP::consSatisfied(stateGCPP* vs,char dn, char wn, short *clockDis, b ...@@ -681,15 +681,15 @@ bool stateGCPP::consSatisfied(stateGCPP* vs,char dn, char wn, short *clockDis, b
} }
} }
} }
//#pragma openmp parallel for //#pragma openmp parallel for
// for(int i = 0 ;i < vs->P; i++) // for(int i = 0 ;i < vs->P; i++)
// { // {
// for(int j = 0; j < vs->P; j++) // for(int j = 0; j < vs->P; j++)
// { // {
// vs->r_matrix[i][j]=store_matrix[i][j]; //restoring computed values to the matrix // vs->r_matrix[i][j]=store_matrix[i][j]; //restoring computed values to the matrix
// } // }
// } // }
// delete_r_matrix(store_matrix,vs->P); //this one added extra // delete_r_matrix(store_matrix,vs->P); //this one added extra
return true; return true;
} }
...@@ -716,21 +716,21 @@ bool stateGCPP::stackCheck(stateGCPP* vs,char dn, char wn, short dlr, bool aclr) ...@@ -716,21 +716,21 @@ bool stateGCPP::stackCheck(stateGCPP* vs,char dn, char wn, short dlr, bool aclr)
//cout << int(dn) << endl; //cout << int(dn) << endl;
int ub = transitions[dn].ubs[0];// the stacks upper bound int ub = transitions[dn].ubs[0];// the stacks upper bound
//int lb = transitions[dn].lbs[0]; //int lb = transitions[dn].lbs[0];
// int openl,openu; //added extra // int openl,openu; //added extra
// openl = transitions[dn].openl; // openl = transitions[dn].openl;
// openu = transitions[dn].openu; // openu = transitions[dn].openu;
// relation **store_matrix = allocate_r_matrix(vs->P); // relation **store_matrix = allocate_r_matrix(vs->P);
////#pragma openmp parallel for ////#pragma openmp parallel for
// for(int i = 0 ;i < vs->P; i++) // for(int i = 0 ;i < vs->P; i++)
// { // {
// for(int j = 0; j < vs->P; j++) // for(int j = 0; j < vs->P; j++)
// { // {
// store_matrix[i][j] = vs->r_matrix[i][j]; //storing values of the relation matrix to detect any cycle with single les symbol in it. // store_matrix[i][j] = vs->r_matrix[i][j]; //storing values of the relation matrix to detect any cycle with single les symbol in it.
// } // }
// } // }
if(aclr) { // if distance from L to R is small if(aclr) { // if distance from L to R is small
// if(dn == 4) // if(dn == 4)
// cout << "true aclr" << endl; // cout << "true aclr" << endl;
short dis = dlr + mod( wn - w[P-1], M ); // mark short dis = dlr + mod( wn - w[P-1], M ); // mark
char t = vs->L-1; //the source of push must be L. char t = vs->L-1; //the source of push must be L.
if( ( dis < transitions[dn].lbs[0] ) || dis > ub ) if( ( dis < transitions[dn].lbs[0] ) || dis > ub )
...@@ -739,38 +739,38 @@ bool stateGCPP::stackCheck(stateGCPP* vs,char dn, char wn, short dlr, bool aclr) ...@@ -739,38 +739,38 @@ bool stateGCPP::stackCheck(stateGCPP* vs,char dn, char wn, short dlr, bool aclr)
return false; return false;
} }
//added extra //added extra
// if(dis == transitions[dn].lbs[0]) // if the lower bound of the interval is open // if(dis == transitions[dn].lbs[0]) // if the lower bound of the interval is open
// { // {
// if(openl & 1) // if(openl & 1)
// { // {
// if(store_matrix[t][vs->P-1]> les) // if(store_matrix[t][vs->P-1]> les)
// store_matrix[t][vs->P-1] = les; // store_matrix[t][vs->P-1] = les;
// } // }
// else // else
// { // {
// if(store_matrix[t][vs->P-1] > leq) // if(store_matrix[t][vs->P-1] > leq)
// store_matrix[t][vs->P-1] = leq; // store_matrix[t][vs->P-1] = leq;
// } // }
// //Here have to check the relationship of the fractional parts of the source and target // //Here have to check the relationship of the fractional parts of the source and target
// // Here the relation must be {tsm(i)} < {tsm(j)} // // Here the relation must be {tsm(i)} < {tsm(j)}
// // hence (i,j) \in R_< // // hence (i,j) \in R_<
// } // }
// if (dis == transitions[dn].ubs[0]) // if the upper bound of the interval is open // if (dis == transitions[dn].ubs[0]) // if the upper bound of the interval is open
// { // {
// if(openu & 1) // if(openu & 1)
// { // {
// if(store_matrix[vs->P-1][t]> les) // if(store_matrix[vs->P-1][t]> les)
// store_matrix[vs->P-1][t] = les; // store_matrix[vs->P-1][t] = les;
// } // }
// else // else
// { // {
// if(store_matrix[vs->P-1][t] > leq) // if(store_matrix[vs->P-1][t] > leq)
// store_matrix[vs->P-1][t] = leq; // store_matrix[vs->P-1][t] = leq;
// } // }
// //here we have to check the relationship of the fractional parts of the source and target // //here we have to check the relationship of the fractional parts of the source and target
// //Here the relation must be {tsm(j) } < {tsm(i)} // //Here the relation must be {tsm(j) } < {tsm(i)}
// // Hence (j,i) \in R_< // // Hence (j,i) \in R_<
// } // }
//pairWiseTightestRelation(store_matrix,vs->P); //pairWiseTightestRelation(store_matrix,vs->P);
else if( dis == transitions[dn].lbs[0] || dis == ub) else if( dis == transitions[dn].lbs[0] || dis == ub)
{ {
...@@ -789,14 +789,14 @@ bool stateGCPP::stackCheck(stateGCPP* vs,char dn, char wn, short dlr, bool aclr) ...@@ -789,14 +789,14 @@ bool stateGCPP::stackCheck(stateGCPP* vs,char dn, char wn, short dlr, bool aclr)
} }
//#pragma openmp parallel for //#pragma openmp parallel for
// for(int i = 0 ;i < vs->P; i++) // for(int i = 0 ;i < vs->P; i++)
// { // {
// for(int j = 0; j < vs->P; j++) // for(int j = 0; j < vs->P; j++)
// { // {
// vs->r_matrix[i][j]=store_matrix[i][j]; //restoring computed values to the matrix // vs->r_matrix[i][j]=store_matrix[i][j]; //restoring computed values to the matrix
// } // }
// } // }
} }
...@@ -837,7 +837,7 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() { ...@@ -837,7 +837,7 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() {
char q = transitions[ del[P-1] ].target; // target state of last transition char q = transitions[ del[P-1] ].target; // target state of last transition
// iterate through all the upcoming transitions // iterate through all the upcoming transitions
//#pragma openmp parallel for //#pragma openmp parallel for
for(char i=0; i < nexttrans[q].size(); i++) { for(char i=0; i < nexttrans[q].size(); i++) {
dn = nexttrans[q][i]; // i-th upcoming transition dn = nexttrans[q][i]; // i-th upcoming transition
...@@ -882,7 +882,7 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() { ...@@ -882,7 +882,7 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() {
// iterate through all possible TSM value for tranistion 'dn' and check for constraints on clocks and stack // iterate through all possible TSM value for tranistion 'dn' and check for constraints on clocks and stack
//relation rel[2] = {leq,les}; //relation rel[2] = {leq,les};
//#pragma openmp parallel for //#pragma openmp parallel for
for(char wn=0; wn < M; wn++) { for(char wn=0; wn < M; wn++) {
stateGCPP* vs = reduce2(dn,wn,clockDis,clockAcc,dlr,aclr); stateGCPP* vs = reduce2(dn,wn,clockDis,clockAcc,dlr,aclr);
...@@ -901,8 +901,8 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() { ...@@ -901,8 +901,8 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() {
//else if(!relationSatisfied(dn,wn)) //else if(!relationSatisfied(dn,wn))
//else if (( !openGuardConsSat())) //else if (( !openGuardConsSat()))
else { // if clock and stack both constraints are satisfied else { // if clock and stack both constraints are satisfied
// stateGCPP* vs = vs1->reduce(dn); // stateGCPP* vs = vs1->reduce(dn);
// delete vs1; // delete vs1;
//cout << int(dn) << endl; //cout << int(dn) << endl;
stateGCPP* rs = new stateGCPP(); stateGCPP* rs = new stateGCPP();
...@@ -1209,9 +1209,9 @@ stateGCPP* getZeroState() { ...@@ -1209,9 +1209,9 @@ stateGCPP* getZeroState() {
vs->P = 1; vs->P = 1;
vs->f = 0; // no push pop info yet, no accuracy info yet vs->f = 0; // no push pop info yet, no accuracy info yet
vs->allocate_r_matrix(que); vs->allocate_r_matrix(que);
// for(int i =0 ; i < vs->P;i++) // with 'na'. // for(int i =0 ; i < vs->P;i++) // with 'na'.
// for(int j = 0; j < vs->P; j++) // for(int j = 0; j < vs->P; j++)
// vs->r_matrix[i][j] = que; // vs->r_matrix[i][j] = que;
vs->del = new char[1]; // memory allocation vs->del = new char[1]; // memory allocation
vs->w = new char[1]; vs->w = new char[1];
...@@ -1644,41 +1644,64 @@ void pairWiseTightestRelation (relation **graph,int V) //this function does the ...@@ -1644,41 +1644,64 @@ void pairWiseTightestRelation (relation **graph,int V) //this function does the
/* Initialize the solution matrix same as input graph matrix. Or /* Initialize the solution matrix same as input graph matrix. Or
we can say the initial values of shortest distances are based we can say the initial values of shortest distances are based
on shortest paths considering no intermediate vertex. */ on shortest paths considering no intermediate vertex. */
for (int i = 0; i < V; i++) // for (int i = 0; i < V; i++)
for (int j = 0; j < V; j++) // for (int j = 0; j < V; j++)
dist[i][j] = graph[i][j]; // copying value to the local variable // dist[i][j] = graph[i][j]; // copying value to the local variable
//
/* Add all vertices one by one to the set of intermediate vertices. /* Add all vertices one by one to the set of intermediate vertices.
---> Before start of a iteration, we have shortest distances between all ---> Before start of a iteration, we have shortest distances between all
pairs of vertices such that the shortest distances consider only the pairs of vertices such that the shortest distances consider only the
vertices in set {0, 1, 2, .. k-1} as intermediate vertices. vertices in set {0, 1, 2, .. k-1} as intermediate vertices.
----> After the end of a iteration, vertex no. k is added to the set of ----> After the end of a iteration, vertex no. k is added to the set of
intermediate vertices and the set becomes {0, 1, 2, .. k} */ intermediate vertices and the set becomes {0, 1, 2, .. k} */
for (int k = 0; k < V; k++) for(int k=0; k < V; k++) {
{ for(int i=0; i < V; i++) {
// Pick all vertices as source one by one for(int j=0; j < V; j++){
for (int i = 0; i < V; i++) if(k & 1) { // if k is odd, transfer weights from dist to graph
{ if( ( addition[dist[i][k]][dist[k][j]] ) < dist[i][j] ) { // if using node k, we update distance from i to j
// Pick all vertices as destination for the graph[i][j] = addition[dist[i][k]][dist[k][j]];
// above picked source //open1[i][j] = open2[i][k] || open2[k][j] ;
for (int j = 0; j < V; j++) }
{
// If vertex k is on the shortest path from else if( ( addition[dist[i][k]][dist[k][j]] ) == dist[i][j]) { // if any distance is open, then the new distance is also open
// i to j, then update the value of dist[i][j] graph[i][j] = dist[i][j];
relation m = addition[dist[i][k]][dist[k][j]]; //open1[i][j] = open2[i][k] || open2[k][j] || open2[i][j] ;
if (m < dist[i][j])
dist[i][j] = m;
} }
else {
graph[i][j] = dist[i][j];
//open1[i][j] = open2[i][j] ;
} }
} }
else{ // if k is even , transfer weights from graph to dist
if( ( addition[graph[i][k]][graph[k][j]] ) < graph[i][j] ) {
dist[i][j] = addition[graph[i][k]][graph[k][j]];
//open2[i][j] = open1[i][k] || open1[k][j] ;
}
else if( ( addition[graph[i][k]][graph[k][j]] ) == graph[i][j]) {
dist[i][j] = graph[i][j];
//open2[i][j] = open1[i][k] || open1[k][j] || open1[i][j] ;
}
else{
dist[i][j] = graph[i][j];
//open2[i][j] = open1[i][j] ;
}
}
}
}
}
// Print the shortest distance matrix // Print the shortest distance matrix
//printSolution(dist,V); //printSolution(dist,V);
//printSolution(graph,V); //printSolution(graph,V);
if(!((V-1) & 1)){
for(int i = 0 ; i < V; i++) for(int i = 0 ; i < V; i++)
for(int j = 0; j < V ; j++) for(int j = 0; j < V ; j++)
graph[i][j] = dist[i][j]; // change the original matrix graph[i][j] = dist[i][j]; // change the original matrix
//printSolution(graph,V); //printSolution(graph,V);
}
for(int i = 0; i < V ; i++) // delete the space allocated for the sub matrix for(int i = 0; i < V ; i++) // delete the space allocated for the sub matrix
delete[] dist[i]; delete[] dist[i];
delete[] dist; delete[] dist;
...@@ -1721,8 +1744,8 @@ stateGCPP* stateGCPP::reduce2(char dn,char wn,short* clockDis,bool* clockAcc,sho ...@@ -1721,8 +1744,8 @@ stateGCPP* stateGCPP::reduce2(char dn,char wn,short* clockDis,bool* clockAcc,sho
popflag = isPop(dn); popflag = isPop(dn);
relation ** store_matrix = allocate_r_matrix(P+1); relation ** store_matrix = allocate_r_matrix(P+1);
for(char i = 0; i < P-1; i++) for(char i = 0; i < P; i++)
for(char j =0 ; j < P-1; j++) for(char j =0 ; j < P; j++)
store_matrix[i][j] = r_matrix[i][j]; store_matrix[i][j] = r_matrix[i][j];
for(char x = 1; x<=X;x++) for(char x = 1; x<=X;x++)
...@@ -1811,10 +1834,10 @@ stateGCPP* stateGCPP::reduce2(char dn,char wn,short* clockDis,bool* clockAcc,sho ...@@ -1811,10 +1834,10 @@ stateGCPP* stateGCPP::reduce2(char dn,char wn,short* clockDis,bool* clockAcc,sho
// Hence (j,i) \in R_< // Hence (j,i) \in R_<
} }
} }
// if(dn==4){ // if(dn==4){
// cout << "_______________________" << endl; // cout << "_______________________" << endl;
// print_r_matrix(store_matrix,P+1); // print_r_matrix(store_matrix,P+1);
// } // }
cout << "dn=" <<int(dn) << " wn=" << int(wn) << endl; cout << "dn=" <<int(dn) << " wn=" << int(wn) << endl;
for(char i =0; i < P; i++) for(char i =0; i < P; i++)
...@@ -1828,11 +1851,11 @@ stateGCPP* stateGCPP::reduce2(char dn,char wn,short* clockDis,bool* clockAcc,sho ...@@ -1828,11 +1851,11 @@ stateGCPP* stateGCPP::reduce2(char dn,char wn,short* clockDis,bool* clockAcc,sho
cout << "after tightning" << endl; cout << "after tightning" << endl;
print_r_matrix(store_matrix,P+1); print_r_matrix(store_matrix,P+1);
// if(dn==4){ // if(dn==4){
// //
// print_r_matrix(store_matrix,P+1); // print_r_matrix(store_matrix,P+1);
// cout << "_______________________" << endl; // cout << "_______________________" << endl;
// } // }
short curReset = transitions[dn].reset; // set of clocks reset at transition 'dn' short curReset = transitions[dn].reset; // set of clocks reset at transition 'dn'
for( char i=P-1; i >= L; i-- ) { for( char i=P-1; i >= L; i-- ) {
......
...@@ -57,7 +57,7 @@ string inttobinary(int x) { ...@@ -57,7 +57,7 @@ string inttobinary(int x) {
// initialization of the integer arrays a,b and c defined above // initialization of the integer arrays a,b and c defined above
void setBits() { void setBits() {
char i; unsigned int i;
unsigned int x32=1,y32=1; unsigned int x32=1,y32=1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment