00001
00019 #include "reo.h"
00020
00024
00025
00029
00030
00043 void reoProfileNodesStart( reo_man * p )
00044 {
00045 int Total, i;
00046 Total = 0;
00047 for ( i = 0; i <= p->nSupp; i++ )
00048 {
00049 p->pPlanes[i].statsCost = p->pPlanes[i].statsNodes;
00050 Total += p->pPlanes[i].statsNodes;
00051 }
00052 assert( Total == p->nNodesCur );
00053 p->nNodesBeg = p->nNodesCur;
00054 }
00055
00075 void reoProfileAplStart( reo_man * p )
00076 {
00077 reo_unit * pER, * pTR;
00078 reo_unit * pUnit;
00079 double Res, Half;
00080 int i;
00081
00082
00083 for ( i = 0; i < p->nSupp; i++ )
00084 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next )
00085 pUnit->Weight = 0.0;
00086
00087
00088
00089
00090 for ( i = 0; i < p->nTops; i++ )
00091 Unit_Regular(p->pTops[i])->Weight += 1.0;
00092
00093
00094
00095 Res = 0.0;
00096 for ( i = 0; i < p->nSupp; i++ )
00097 {
00098 p->pPlanes[i].statsCost = 0.0;
00099 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next )
00100 {
00101 pER = Unit_Regular(pUnit->pE);
00102 pTR = Unit_Regular(pUnit->pT);
00103 Half = 0.5 * pUnit->Weight;
00104 pER->Weight += Half;
00105 pTR->Weight += Half;
00106
00107 p->pPlanes[i].statsCost += pUnit->Weight;
00108 }
00109 Res += p->pPlanes[i].statsCost;
00110 }
00111 p->pPlanes[p->nSupp].statsCost = 0.0;
00112 p->nAplBeg = p->nAplCur = Res;
00113 }
00114
00127 void reoProfileWidthStart( reo_man * p )
00128 {
00129 reo_unit * pUnit;
00130 int * pWidthStart;
00131 int * pWidthStop;
00132 int v;
00133
00134
00135 pWidthStart = ALLOC( int, p->nSupp + 1 );
00136 pWidthStop = ALLOC( int, p->nSupp + 1 );
00137 memset( pWidthStart, 0, sizeof(int) * (p->nSupp + 1) );
00138 memset( pWidthStop, 0, sizeof(int) * (p->nSupp + 1) );
00139
00140
00141 for ( v = 0; v <= p->nSupp; v++ )
00142 for ( pUnit = p->pPlanes[v].pHead; pUnit; pUnit = pUnit->Next )
00143 {
00144 pUnit->TopRef = REO_TOPREF_UNDEF;
00145 pUnit->Sign = 0;
00146 }
00147
00148
00149 for ( v = 0; v < p->nTops; v++ )
00150 {
00151 pUnit = Unit_Regular(p->pTops[v]);
00152 if ( pUnit->TopRef == REO_TOPREF_UNDEF )
00153 {
00154
00155 pUnit->TopRef = 0;
00156 pWidthStart[pUnit->TopRef]++;
00157
00158 if ( pUnit->lev != REO_CONST_LEVEL )
00159 pWidthStop[pUnit->lev+1]++;
00160 }
00161 }
00162
00163 for ( v = 0; v < p->nSupp; v++ )
00164 for ( pUnit = p->pPlanes[v].pHead; pUnit; pUnit = pUnit->Next )
00165 {
00166 if ( pUnit->pE->TopRef == REO_TOPREF_UNDEF )
00167 {
00168
00169 pUnit->pE->TopRef = pUnit->lev + 1;
00170 pWidthStart[pUnit->pE->TopRef]++;
00171
00172 if ( pUnit->pE->lev != REO_CONST_LEVEL )
00173 pWidthStop[pUnit->pE->lev+1]++;
00174 }
00175 if ( pUnit->pT->TopRef == REO_TOPREF_UNDEF )
00176 {
00177
00178 pUnit->pT->TopRef = pUnit->lev + 1;
00179 pWidthStart[pUnit->pT->TopRef]++;
00180
00181 if ( pUnit->pT->lev != REO_CONST_LEVEL )
00182 pWidthStop[pUnit->pT->lev+1]++;
00183 }
00184 }
00185
00186
00187 for ( v = 0; v < p->nSupp; v++ )
00188 reoProfileWidthVerifyLevel( p->pPlanes + v, v );
00189
00190
00191 p->nWidthCur = 0;
00192 for ( v = 0; v <= p->nSupp; v++ )
00193 {
00194 if ( v == 0 )
00195 p->pPlanes[v].statsWidth = pWidthStart[v] - pWidthStop[v];
00196 else
00197 p->pPlanes[v].statsWidth = p->pPlanes[v-1].statsWidth + pWidthStart[v] - pWidthStop[v];
00198 p->pPlanes[v].statsCost = p->pPlanes[v].statsWidth;
00199 p->nWidthCur += p->pPlanes[v].statsWidth;
00200
00201 }
00202 p->nWidthBeg = p->nWidthCur;
00203 free( pWidthStart );
00204 free( pWidthStop );
00205 }
00206
00219 void reoProfileWidthStart2( reo_man * p )
00220 {
00221 reo_unit * pUnit;
00222 int i, v;
00223
00224
00225 for ( i = 0; i <= p->nSupp; i++ )
00226 p->pPlanes[i].statsWidth = 0;
00227
00228
00229 for ( v = 0; v <= p->nSupp; v++ )
00230 for ( pUnit = p->pPlanes[v].pHead; pUnit; pUnit = pUnit->Next )
00231 {
00232 pUnit->TopRef = REO_TOPREF_UNDEF;
00233 pUnit->Sign = 0;
00234 }
00235
00236
00237 for ( i = 0; i < p->nTops; i++ )
00238 Unit_Regular(p->pTops[i])->TopRef = 0;
00239
00240
00241 for ( i = 0; i < p->nSupp; i++ )
00242 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next )
00243 {
00244 if ( pUnit->pE->TopRef > i+1 )
00245 pUnit->pE->TopRef = i+1;
00246 if ( pUnit->pT->TopRef > i+1 )
00247 pUnit->pT->TopRef = i+1;
00248 }
00249
00250
00251 for ( i = 0; i < p->nSupp; i++ )
00252 reoProfileWidthVerifyLevel( p->pPlanes + i, i );
00253
00254
00255 for ( i = 0; i < p->nSupp; i++ )
00256 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next )
00257 for ( v = pUnit->TopRef; v <= pUnit->lev; v++ )
00258 p->pPlanes[v].statsWidth++;
00259
00260
00261 for ( pUnit = p->pPlanes[p->nSupp].pHead; pUnit; pUnit = pUnit->Next )
00262 for ( v = pUnit->TopRef; v <= p->nSupp; v++ )
00263 p->pPlanes[v].statsWidth++;
00264
00265
00266 p->nWidthCur = 0;
00267 for ( i = 0; i <= p->nSupp; i++ )
00268 {
00269 p->pPlanes[i].statsCost = p->pPlanes[i].statsWidth;
00270 p->nWidthCur += p->pPlanes[i].statsWidth;
00271 }
00272 p->nWidthBeg = p->nWidthCur;
00273 }
00274
00286 void reoProfileNodesPrint( reo_man * p )
00287 {
00288 printf( "NODES: Total = %6d. Average = %6.2f.\n", p->nNodesCur, p->nNodesCur / (float)p->nSupp );
00289 }
00290
00302 void reoProfileAplPrint( reo_man * p )
00303 {
00304 printf( "APL: Total = %8.2f. Average =%6.2f.\n", p->nAplCur, p->nAplCur / (float)p->nSupp );
00305 }
00306
00318 void reoProfileWidthPrint( reo_man * p )
00319 {
00320 int WidthMax;
00321 int TotalWidth;
00322 int i;
00323
00324 WidthMax = 0;
00325 TotalWidth = 0;
00326 for ( i = 0; i <= p->nSupp; i++ )
00327 {
00328
00329 if ( WidthMax < p->pPlanes[i].statsWidth )
00330 WidthMax = p->pPlanes[i].statsWidth;
00331 TotalWidth += p->pPlanes[i].statsWidth;
00332 }
00333 assert( p->nWidthCur == TotalWidth );
00334 printf( "WIDTH: " );
00335 printf( "Maximum = %5d. ", WidthMax );
00336 printf( "Total = %7d. ", p->nWidthCur );
00337 printf( "Average = %6.2f.\n", TotalWidth / (float)p->nSupp );
00338 }
00339
00351 void reoProfileWidthVerifyLevel( reo_plane * pPlane, int Level )
00352 {
00353 reo_unit * pUnit;
00354 for ( pUnit = pPlane->pHead; pUnit; pUnit = pUnit->Next )
00355 {
00356 assert( pUnit->TopRef <= Level );
00357 assert( pUnit->pE->TopRef <= Level + 1 );
00358 assert( pUnit->pT->TopRef <= Level + 1 );
00359 }
00360 }
00361
00365