Commit 59d71f67 authored by SPARSA ROYCHOWDHURY's avatar SPARSA ROYCHOWDHURY

15/7/2017:

1. Coding is Done.(Aparently)
2. found some bug in the first run.
3. Have to resolve the bug as soon as possible.

Sparsa Roychowdhury
parent f1349727
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :5,ub :2
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :4,ub :0
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :5,ub :1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :1,ub :0
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :1,ub :0
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :10,ub :0
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :1,ub :0
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :7,ub :0
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Invalid stack operation!
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :3,ub :0
The value of openl and openu must be 0 or 1
Invalid stack operation!
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :6,ub :2
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Bounds can't be negative!
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :10,ub :1
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :3,ub :2
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :1,ub :0
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Lower bound can't be greater than upper bound!, lb :4,ub :0
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
The value of openl and openu must be 0 or 1
The value of openl and openu must be 0 or 1
Clock number is not in the limit!
...@@ -3,5 +3,5 @@ FILES=./input/ ...@@ -3,5 +3,5 @@ FILES=./input/
for f in `ls $FILES` for f in `ls $FILES`
do do
echo "Processing $f File.. " echo "Processing $f File.. "
./tree $FILES$f > ./output/$f.txt ./tree $FILES$f > ./output2/$f.txt
done done
...@@ -78,7 +78,7 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -78,7 +78,7 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
char P2 = s2->P, L2 = s2->L; char P2 = s2->P, L2 = s2->L;
short f2 = s2->f; short f2 = s2->f;
short curReset, reset, tempReset; // temp variables to keep reset for a range of points short curReset, reset, tempReset,reset2,curReset2; // 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
...@@ -88,7 +88,7 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -88,7 +88,7 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
// take union of resets for points between s2->L+1(including) and s2->P(including) // take union of resets for points between s2->L+1(including) and s2->P(including)
curReset = 0; curReset = 0;
for(i=L2; i < P2; i++) for(i=L2; i < P2; i++)
curReset |= ( transitions[ del2[i] ].reset ); curReset |= ( transitions[ del2[i] ].reset ); //getting reset points im the non trivial block of state2
tempReset = curReset; // store this value for later use tempReset = curReset; // store this value for later use
...@@ -109,29 +109,40 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -109,29 +109,40 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
stateGCPP *vs = new stateGCPP(); // new TA state stateGCPP *vs = new stateGCPP(); // new TA state
vs->P = count;
vs->del = new char[count]; // allocate memory vs->del = new char[count]; // allocate memory
vs->w = new char[count]; vs->w = new char[count];
vs->L = L; vs->L = L;
vs->r_matrix = vs->allocate_r_matrix(que);
short nf = 0; // initially flag is zero short nf = 0; // initially flag is zero
short dis; // distance variable short dis; // distance variable
j = count - 1; // index of the rightmost point of new state // j = count-1; // index of the rightmost point of new state
// 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(int i=P2 - 1,j = count - 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(int a=P2-1, b = count-1; i>=L2; i--,j--)
{
if(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];
} }
// 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(int 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];
for(int a = 0 ; a < (L-1) ; a ++)
{
if(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] );
} }
...@@ -139,20 +150,33 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -139,20 +150,33 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
//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];
for(int i = 0 ; i < L ;i++)
{
vs->r_matrix[vs->P-1][i] = r_matrix[P][i];
vs->r_matrix[i][vs->P] = r_matrix[i][P];
}
// 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
curReset = tempReset; //get the union of resets for points between s2->L+1 and s2->P curReset2 = curReset = tempReset; //get the union of resets for points between s2->L+1 and s2->P
// current indices j of new state we have to take care // current indices j of new state we have to take care
j = (count - 1) - (P2 - L2); //j = (count - 1) - (P2 - L2);
for(i=P-1; i >= L; i--) { for(int i=P-1,j = (count - 1) - (P2 - L2); i >= L; i--) {
reset = ( transitions[ del[i] ].reset ); // current point reset set reset = ( transitions[ del[i] ].reset ); // current point reset set
if( reset & (~curReset) & (~1) ) { // if current point has more reset then seen earlier if( reset & (~curReset) & (~1) ) { // if current point has more reset then seen earlier
vs->del[j] = del[i]; vs->del[j] = del[i];
vs->w[j] = w[i]; vs->w[j] = w[i];
for(int a = P-1, b = (count -1) - (P2 - L2); a >= L; a--)
{
reset2 = (transitions[del[a]].reset);
if(reset2 &(!curReset2) & ~(1))
{
vs->r_matrix[j][b] = r_matrix[i][a];
curReset2 |= reset2;
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
...@@ -197,8 +221,8 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) { ...@@ -197,8 +221,8 @@ stateGCPP* stateGCPP::reduceShuffle(stateGCPP* s2) {
nf |= a3215; // pop at right(R) is done nf |= a3215; // pop at right(R) is done
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
pairWiseTightestRelation(vs->r_matrix,vs->P);
return vs; return vs;
} }
...@@ -431,6 +455,13 @@ bool stateGCPP::consSatisfied(stateGCPP* vs, short* transitionMap,char dn, char ...@@ -431,6 +455,13 @@ bool stateGCPP::consSatisfied(stateGCPP* vs, short* transitionMap,char dn, char
} }
} }
} }
for(int i = 0 ;i < vs->P; i++)
{
for(int j = 0; j < vs->P; j++)
{
vs->r_matrix[i][j]=store_matrix[i][j]; //restoring computed values to the matrix
}
}
delete_r_matrix(store_matrix,P); //this one added extra delete_r_matrix(store_matrix,P); //this one added extra
return true; return true;
} }
...@@ -514,8 +545,17 @@ bool stateGCPP::stackCheck(stateGCPP* vs,short* transitionMap,char dn, char wn, ...@@ -514,8 +545,17 @@ bool stateGCPP::stackCheck(stateGCPP* vs,short* transitionMap,char dn, char wn,
if(b) if(b)
return false; return false;
else else
{
for(int i = 0 ;i < vs->P; i++)
{
for(int j = 0; j < vs->P; j++)
{
vs->r_matrix[i][j]=store_matrix[i][j]; //restoring computed values to the matrix
}
}
return true; return true;
} }
}
else if(ub == INF) // if distance from L to R is big else if(ub == INF) // if distance from L to R is big
return true; return true;
...@@ -635,6 +675,13 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() { ...@@ -635,6 +675,13 @@ vector<stateGCPP*> stateGCPP::addNextTPDA() {
//assume the relation of fraction part with respect to the new system. //assume the relation of fraction part with respect to the new system.
//first assume it to be \leq //first assume it to be \leq
rs->r_matrix = rs->allocate_r_matrix();// do we need to allocate? or it is sufficent to just point? rs->r_matrix = rs->allocate_r_matrix();// do we need to allocate? or it is sufficent to just point?
for(int i = 0 ;i < vs->P; i++)
{
for(int j = 0; j < vs->P; j++)
{
rs->r_matrix[i][j]=vs->r_matrix[i][j]; //restoring computed values to the matrix
}
}
//I have to allocate because this is changing //I have to allocate because this is changing
//How to propagate values?? //How to propagate values??
//vs->r_matrix; //vs->r_matrix;
...@@ -669,7 +716,8 @@ stateGCPP* stateGCPP::sucState(){ ...@@ -669,7 +716,8 @@ stateGCPP* stateGCPP::sucState(){
} }
} }
int map[count]; // mapping array to map points from current state to new state
map[count-1]= P-1;
stateGCPP* vs = new stateGCPP(); // new template state stateGCPP* vs = new stateGCPP(); // new template state
vs->P = count; //#points vs->P = count; //#points
...@@ -677,6 +725,7 @@ stateGCPP* stateGCPP::sucState(){ ...@@ -677,6 +725,7 @@ stateGCPP* stateGCPP::sucState(){
vs->del = new char[count]; vs->del = new char[count];
vs->w = new char[count]; vs->w = new char[count];
vs->r_matrix = vs->allocate_r_matrix(que);
vs->del[count-1] = del[P-1]; vs->del[count-1] = del[P-1];
vs->w[count-1] = w[P-1]; vs->w[count-1] = w[P-1];
...@@ -692,6 +741,7 @@ stateGCPP* stateGCPP::sucState(){ ...@@ -692,6 +741,7 @@ stateGCPP* stateGCPP::sucState(){
if(reset & (~curReset) & (~1) ) { // found a new necessary point, copy this point to new state if(reset & (~curReset) & (~1) ) { // found a new necessary point, copy this point to new state
vs->del[j] = del[i]; vs->del[j] = del[i];
vs->w[j] = w[i]; vs->w[j] = w[i];
map[j]=i;
if( !big(i+1, lastindex+1) ) //from current needy point to the last found needy point distance small if( !big(i+1, lastindex+1) ) //from current needy point to the last found needy point distance small
nf |= a32[j+1]; // distance (j+1->(j+2)) is small nf |= a32[j+1]; // distance (j+1->(j+2)) is small
curReset |= reset; curReset |= reset;
...@@ -702,6 +752,13 @@ stateGCPP* stateGCPP::sucState(){ ...@@ -702,6 +752,13 @@ stateGCPP* stateGCPP::sucState(){
vs->f = nf; // copy flag information, no stack info is there till now for the template state vs->f = nf; // copy flag information, no stack info is there till now for the template state
//we also have to copy the value of the relation matrix for those points.
for(int i = 0; i < count ;i ++)
{
for(int j =0; j < count ; j++)
vs->r_matrix[i][j] = r_matrix[map[i]][map[j]];
}
pairWiseTightestRelation(vs->r_matrix,vs->P);
return vs; return vs;
} }
...@@ -1228,18 +1285,24 @@ void stateGCPP::delete_w() ...@@ -1228,18 +1285,24 @@ void stateGCPP::delete_w()
relation ** stateGCPP::allocate_r_matrix() relation ** stateGCPP::allocate_r_matrix()
{ {
//allocating space for r matrix without any initialization and the size
// is same as the value of P of the state
r_matrix = new relation*[P]; r_matrix = new relation*[P];
for(int i = 0; i < P; i++) for(int i = 0; i < P; i++)
r_matrix[i] = new relation[P]; r_matrix[i] = new relation[P];
} }
relation ** stateGCPP::allocate_r_matrix(relation r) relation ** stateGCPP::allocate_r_matrix(relation r)
{ {
//allocate space for the matix r-matrix for the state,
// this allocation initialized the array with given relation variable
r_matrix = new relation*[P]; r_matrix = new relation*[P];
for(int i = 0; i < P; i++) for(int i = 0; i < P; i++)
r_matrix[i] = new relation[P]{r}; r_matrix[i] = new relation[P]{r};
} }
relation** stateGCPP::allocate_r_matrix(char P) relation** stateGCPP::allocate_r_matrix(char P)
{ {
//this is another function which allocates memory for the state r-matrix
//but it creates the matrix with given size P.
relation **matrix = new relation*[P]; relation **matrix = new relation*[P];
for(int i =0; i < P;i ++) for(int i =0; i < P;i ++)
matrix[i] = new relation[P]; matrix[i] = new relation[P];
......
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