Commit e4eea6fc authored by SPARSA ROYCHOWDHURY's avatar SPARSA ROYCHOWDHURY

12/7/2017:

1. Some change done in the reduce shuffle function
2. Completely Indented code.
parent 8a8fb4bc
......@@ -2,7 +2,7 @@
using namespace std;
class transition{
public:
public:
short source; // source state
short target; // target state
......
......@@ -17,7 +17,7 @@ extern bool **open1, **open2; // temporary variables for storing some edge weigh
// state for timed automata
class stateZone{
public:
public:
char P; // number of points in this state
char f; // 7-th bit is 1 iff push at L is done, rightmost 7 bits used for L or L = f & 127
......@@ -53,7 +53,7 @@ class stateZone{
// partial run of the timed system as a sequence of pairs: (1) transition and (2) tsm value
class runZone{
public :
public :
short P; // #points
char *del; // transitions
short **w; // weight matrix
......@@ -68,7 +68,7 @@ class runZone{
// info to keep track parents of current state or who are the states generated current state
class trackZone{
public :
public :
char type; //***** type of operation : atomic : 0, addNextTPDA : 1, shuffle or combine : 2
int left; // *****shuffle left state index in the main vector
int right; // ****shuffle right state index in the main vector
......
......@@ -1012,18 +1012,18 @@ bool isEmptyGCPP() {
}
}
// vs1 = (allStates[8]).first;
// vs1->print();
// vs2 = vs1->sucState();
//
// vs2->print();
// vs = vs1->shuffle(vs2);
// vs->print();
//v = (allStates[2].first)->addNextTPDA();
// cout << v.size() << endl;
// for(i=0;i < v.size(); i++)
// v[i]->print();
// vs1 = (allStates[8]).first;
// vs1->print();
// vs2 = vs1->sucState();
//
// vs2->print();
// vs = vs1->shuffle(vs2);
// vs->print();
//v = (allStates[2].first)->addNextTPDA();
// cout << v.size() << endl;
// for(i=0;i < v.size(); i++)
// v[i]->print();
//cout << "\"" << (allStates[1].first)->shuffleCheck((allStates[6].first)) << "\"";
......
......@@ -251,38 +251,86 @@ stateZone* stateZone::reduceShuffle(stateZone* s2) {
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
int lb,ub,openl,openu;
// current indices j of new state we have to take care
j = (count - 1) - (P2 - L2);//this is the start of hanging points of state 2
for(i=P-1; i >= L; i--) { //iterating on the points of the first state
reset = ( transitions[ del[i] ].reset ); // current point reset set
if( reset & (~curReset) & (~1) ) { // if current point has more reset then seen earlier
//for(i=P-1; i >= L; i--) { //iterating on the points of the first state
// current point reset set
for(int k = L2 -1; k < count ; k++) //iterating through the points of second state to find any clock constraint check
{
for(int x=1; x <= X; x++) { // iterate for every clocks
if( isChecked(x, k) ) { // if there is a constraint for clock x in the transition k of second state
lb = transitions[k].lbs[x];
ub = transitions[k].ubs[x];
openl = (transitions[k].openl) & a32[x]; // lower bound for clock x is open or not
openu = (transitions[k].openu) & a32[x];
for(i=P-1; i >= L; i--) { // find reset point for clock x in the first state
reset = ( transitions[ del[i] ].reset );
if( reset & (~curReset) & (~1) && isReset(x, del[i]) ) { // if current point has more reset then seen earlier
//if the current
vs->del[j] = del[i]; //copy the transition number
/* //vs->w[j] = w[i];
//if( ) { // if clock x is reset at point i+1
// 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 : second check is for cheking accuracy from L2 to L2+1 of right state, L2 is not choosen
// if( !big(i+1, P) && ( i == (P-1) || (f2 & a32[L2]) ) ) {
// dis = dist(i+1, P) + mod( w2[L2] - w[P-1], M);
// if( dis < M ) // if total distance from i+1-th point to s2->L+1 is accurate
// nf |= a32[j+1];
// }
// }
// tighten the lower and upper bounds
if( (-lb) < WT1[P][i] ) {
WT1[P][i] = -lb;
open1[P][i] = (openl & a32[x]);
}
// else {
// if( !big(i+1, lastindex+1) )
// nf |= a32[j+1];
// } */
else if( (-lb) == WT1[i][P] )
open1[P][i] |= (openl & a32[x]);
if(ub != INF) {
if(ub < WT1[i][P]) {
WT1[i][P] = ub;
open1[i][P] = (openu & a32[x]);
}
else if( ub == WT1[i][P] )
open1[i][P] |= (openu & a32[x]);
}
i = -1;
}
curReset |= reset;
j--;
lastindex = i;
}
}
}
}
/* //vs->w[j] = w[i];
// one accuracy we yet have to compute which starts from L-th point of first state
// 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 : second check is for cheking accuracy from L2 to L2+1 of right state, L2 is not choosen
// if( !big(i+1, P) && ( i == (P-1) || (f2 & a32[L2]) ) ) {
// dis = dist(i+1, P) + mod( w2[L2] - w[P-1], M);
// if( dis < M ) // if total distance from i+1-th point to s2->L+1 is accurate
// nf |= a32[j+1];
// }
// }
// else {
// if( !big(i+1, lastindex+1) )
// nf |= a32[j+1];
// } */
vs->P = count; // #points in new state
return vs;
}
// one accuracy we yet have to compute which starts from L-th point of first state
// if( lastindex == P ) { // if we have not taken any point from L+1 to P of 1st 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
......@@ -305,10 +353,8 @@ stateZone* stateZone::reduceShuffle(stateZone* s2) {
// nf |= a3215; // pop at right(R) is done
//
// vs->f = nf; // add the flag variable also
vs->P = count; // #points in new state
return vs;
}
// check if shuffle of this state with s2 is possible
......@@ -347,8 +393,8 @@ stateZone* stateZone::shuffle(stateZone *s2){ // shuffle with state s2
/*
// add transition 'dn' to current state and then forget some points if possible, return the new state
stateGCPP* stateGCPP::reduce(char dn){
// add transition 'dn' to current state and then forget some points if possible, return the new state
stateGCPP* stateGCPP::reduce(char dn){
short reset; // variable for reset bit vector
short nf = 0; // flag variable for new state
......@@ -447,9 +493,9 @@ stateGCPP* stateGCPP::reduce(char dn){
vs->f = nf; // add partial flag variable to new state
return vs; // return the partially new state, **** last tsm missing with partial nf as given
}
}
*/
*/
......@@ -666,7 +712,7 @@ stateZone* stateZone::addNextTPDA(char dn) {
// not applied by ilias
/*// Return template successor state whose descendent states will be right states for shuffle operation with this state
stateGCPP* stateZone::sucState(){
stateGCPP* stateZone::sucState(){
short curReset, reset; // temp vars for keeping reset bit vector
char count; // will contain #points in the new state
......@@ -718,7 +764,7 @@ stateGCPP* stateZone::sucState(){
vs->f = nf; // copy flag information, no stack info is there till now for the template state
return vs;
}
}
* */
......@@ -795,9 +841,9 @@ bool stateZone::isFinal(){
/*
// return the partial run corresponding the tree automata state 'vs', ignore the hanging points
// copy only transitions between L(left) and R(right)
runCGPP* getRun(stateGCPP* vs) {
// return the partial run corresponding the tree automata state 'vs', ignore the hanging points
// copy only transitions between L(left) and R(right)
runCGPP* getRun(stateGCPP* vs) {
runCGPP *pr = new runCGPP(); // new partial run stored in variable pr
......@@ -817,11 +863,11 @@ runCGPP* getRun(stateGCPP* vs) {
}
return pr; // return the new run
}
}
// GIVEN the current partial run, append the transition 'dn' with tsm value 'wn'
runCGPP* runCGPP::addNext(char dn, char wn) {
// GIVEN the current partial run, append the transition 'dn' with tsm value 'wn'
runCGPP* runCGPP::addNext(char dn, char wn) {
runCGPP *pr = new runCGPP(); // new partial run stored in variable pr
......@@ -841,11 +887,11 @@ runCGPP* runCGPP::addNext(char dn, char wn) {
pr->w[P] = wn;
return pr; // return the new run
}
}
// shuffle two partial runs and return the new partial run
runCGPP* runCGPP::shuffle(runCGPP *s2) {
// shuffle two partial runs and return the new partial run
runCGPP* runCGPP::shuffle(runCGPP *s2) {
runCGPP *pr = new runCGPP(); // new partial run stored in variable pr
......@@ -872,9 +918,9 @@ runCGPP* runCGPP::shuffle(runCGPP *s2) {
}
return pr; // return the new run
}
}
*/
*/
// this will return a state with only 0-th transition with tsm value 0
stateZone* getZeroStateZone() {
......@@ -945,7 +991,8 @@ string stateZone::getKeyRight() {
//char j = 0; // used for distance counter no distance in zone
char i = (f&127)-2; // counter for points from right to left starting from L-1 point
for(; i >= 0; i--, j++) {
for(; i >= 0; i--) //j++)
{
s += del[i];
//s += w[i]; not needed in zone cause for zone it is not a time stamp
......@@ -960,8 +1007,8 @@ string stateZone::getKeyRight() {
}
/*
// print a run as witness of the given TPDA if the language is non-empty
void runCGPP::print() {
// print a run as witness of the given TPDA if the language is non-empty
void runCGPP::print() {
short int lt = 0, ct=0; // lt : last timestamps, ct : current time stamps
cout << endl << "A run of the automation as a witness for the language to be non-empty.\nThe run given as a sequence of pairs (Transition, Time stamp) : " << endl;
......@@ -979,8 +1026,8 @@ void runCGPP::print() {
}
cout << endl << endl;
}
*/
}
*/
// return a backtracking state with the info given in the parameters
trackZone* getTrackZone(char t, int l, int r) {
......@@ -994,10 +1041,10 @@ trackZone* getTrackZone(char t, int l, int r) {
}
/*
// get the run of the timed system
// if sm == "", this means. we are backtracking from the state reside in i-th index of main vector 'allStates'
// if sm != "", then sm string is the key for shuffle operation of the state reside in i-th index of allStates
runCGPP* printRun(int i) {
// get the run of the timed system
// if sm == "", this means. we are backtracking from the state reside in i-th index of main vector 'allStates'
// if sm != "", then sm string is the key for shuffle operation of the state reside in i-th index of allStates
runCGPP* printRun(int i) {
stateGCPP* vs; // tree automata state variable
trackCGPP *bp; // back tracking state
......@@ -1035,8 +1082,8 @@ runCGPP* printRun(int i) {
return rs;
}
}
*/
}
*/
// return true iff language recognized by the TPDA is empty
......@@ -1169,11 +1216,11 @@ bool isEmptyZone() {
}
// vs = allStatesZone[0].first;
// vs = allStatesZone[0].first;
//N = 0'
//mapZone.clear();
//}
/*
//mapZone.clear();
//}
/*
vs = allStatesZone[0].first;
rs = vs->addNextTPDA(1);
rs->print();
......@@ -1199,7 +1246,7 @@ bool isEmptyZone() {
rs = vs->addNextTPDA(9);
rs->print();
*/
*/
return true;
}
......
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