?? rulecom.c
字號:
PrintLongInteger(theEnv,WDISPLAY,(long int) priorPatterns); EnvPrintRouter(theEnv,WDISPLAY,"\n"); if (theJoin->rightMemory->beta[0]->children != NULL) { EnvPrintRouter(theEnv,WDISPLAY,"*\n"); } else { EnvPrintRouter(theEnv,WDISPLAY," None\n"); } return(priorPatterns); } if (theJoin->lastLevel != NULL) { priorPatterns = ListAlphaMatches(theEnv,theJoin->lastLevel,priorPatterns); } if (theJoin->joinFromTheRight) { return ListAlphaMatches(theEnv,theJoin->rightSideEntryStructure,priorPatterns); } listOfHashNodes = ((struct patternNodeHeader *) theJoin->rightSideEntryStructure)->firstHash; priorPatterns++; if (GetHaltExecution(theEnv) == TRUE) { return(priorPatterns); } EnvPrintRouter(theEnv,WDISPLAY,"Matches for Pattern "); PrintLongInteger(theEnv,WDISPLAY,(long int) priorPatterns); EnvPrintRouter(theEnv,WDISPLAY,"\n"); for (flag = 1; listOfHashNodes != NULL; listOfHashNodes = listOfHashNodes->nextHash) { listOfMatches = listOfHashNodes->alphaMemory; while (listOfMatches != NULL) { if (GetHaltExecution(theEnv) == TRUE) { return(priorPatterns); } flag = 0; PrintPartialMatch(theEnv,WDISPLAY,listOfMatches); EnvPrintRouter(theEnv,WDISPLAY,"\n"); listOfMatches = listOfMatches->nextInMemory; } } if (flag) EnvPrintRouter(theEnv,WDISPLAY," None\n"); return(priorPatterns); } /********************//* ListBetaMatches: *//********************/static int ListBetaMatches( void *theEnv, struct joinNode *theJoin, int blockStart) { int patternsFound = 0, startPatterns; if (GetHaltExecution(theEnv) == TRUE) { return(0); } if (theJoin == NULL) { return(patternsFound); } if (theJoin->lastLevel != NULL) { patternsFound += ListBetaMatches(theEnv,theJoin->lastLevel,blockStart); } if (theJoin->depth > 2) { PrintMatchesMemory(theEnv,theJoin, theJoin->leftMemory, blockStart, blockStart + patternsFound - 1); } startPatterns = patternsFound; if (theJoin->joinFromTheRight) { patternsFound += ListBetaMatches(theEnv,theJoin->rightSideEntryStructure,blockStart+patternsFound); } if ((theJoin->joinFromTheRight) && (((struct joinNode *) (theJoin->rightSideEntryStructure))->depth > 1)) { PrintMatchesMemory(theEnv,theJoin, theJoin->rightMemory, blockStart + startPatterns, blockStart + patternsFound - 1); } if (theJoin->joinFromTheRight) { return(patternsFound); } else { return(patternsFound + 1); } } /****************************//* PrintMatchesMemory: *//****************************/static void PrintMatchesMemory( void *theEnv, struct joinNode *theJoin, struct betaMemory *theMemory, int startCE, int endCE) { struct partialMatch *listOfMatches; unsigned long b; int matchesDisplayed; if (GetHaltExecution(theEnv) == TRUE) { return; } matchesDisplayed = 0; EnvPrintRouter(theEnv,WDISPLAY,"Partial matches for CEs "); PrintLongInteger(theEnv,WDISPLAY,(long int) startCE); EnvPrintRouter(theEnv,WDISPLAY," - "); PrintLongInteger(theEnv,WDISPLAY,(long int) endCE); EnvPrintRouter(theEnv,WDISPLAY,"\n"); for (b = 0; b < theMemory->size; b++) { listOfMatches = theMemory->beta[b]; while (listOfMatches != NULL) { if (GetHaltExecution(theEnv) == TRUE) { return; } matchesDisplayed++; PrintPartialMatch(theEnv,WDISPLAY,listOfMatches); EnvPrintRouter(theEnv,WDISPLAY,"\n"); listOfMatches = listOfMatches->nextInMemory; } } if (matchesDisplayed == 0) { EnvPrintRouter(theEnv,WDISPLAY," None\n"); } } /*******************************************//* JoinActivityCommand: H/L access routine *//* for the join-activity command. *//*******************************************/globle long long JoinActivityCommand( void *theEnv) { char *ruleName; void *rulePtr; ruleName = GetConstructName(theEnv,"join-activity","rule name"); if (ruleName == NULL) return(0); rulePtr = EnvFindDefrule(theEnv,ruleName); if (rulePtr == NULL) { CantFindItemErrorMessage(theEnv,"defrule",ruleName); return(0); } return EnvJoinActivity(theEnv,rulePtr,0); }/*************************************//* EnvJoinActivity: C access routine *//* for the join-activity command. *//*************************************/globle long long EnvJoinActivity( void *theEnv, void *theRule, int verbosity) { struct defrule *rulePtr, *tmpPtr; struct joinNode *lastJoin; long long totalActivity = 0; /*=================================================*/ /* Loop through each of the disjuncts for the rule */ /*=================================================*/ for (rulePtr = (struct defrule *) theRule, tmpPtr = rulePtr; rulePtr != NULL; rulePtr = rulePtr->disjunct) { /*======================================*/ /* Determine the last join in the rule. */ /*======================================*/ lastJoin = rulePtr->lastJoin; /*=======================================*/ /* List the beta memory partial matches. */ /*=======================================*/ ListBetaJoinActivity(theEnv,lastJoin,1,&totalActivity,verbosity); } return(totalActivity); }/*************************//* ListBetaJoinActivity: *//*************************/static int ListBetaJoinActivity( void *theEnv, struct joinNode *theJoin, int blockStart, long long *activity, int verbosity) { int priorLeftPatterns = 0, priorRightPatterns = 0; if (theJoin == NULL) { return(priorLeftPatterns + priorRightPatterns); } if (theJoin->lastLevel != NULL) { priorLeftPatterns = ListBetaJoinActivity(theEnv,theJoin->lastLevel,blockStart,activity,verbosity); } if (theJoin->joinFromTheRight) { priorRightPatterns = ListBetaJoinActivity(theEnv,theJoin->rightSideEntryStructure,blockStart+priorLeftPatterns,activity,verbosity); } if (theJoin->depth == 1) { if (theJoin->joinFromTheRight) { return(priorLeftPatterns + priorRightPatterns); } else { return(priorLeftPatterns + priorRightPatterns + 1); } } if ((priorLeftPatterns > 1) || (theJoin->joinFromTheRight)) { /* EnvPrintRouter(theEnv,WDISPLAY,"Join Activity for CEs "); */ if (priorLeftPatterns > 1) { /* PrintLongInteger(theEnv,WDISPLAY,(long int) blockStart); EnvPrintRouter(theEnv,WDISPLAY," - "); PrintLongInteger(theEnv,WDISPLAY,(long int) priorLeftPatterns); */ } else if (theJoin->joinFromTheRight) { /* PrintLongInteger(theEnv,WDISPLAY,(long int) blockStart + priorLeftPatterns); EnvPrintRouter(theEnv,WDISPLAY," - "); PrintLongInteger(theEnv,WDISPLAY,(long int) blockStart + priorLeftPatterns + (priorRightPatterns - 1)); */ } *activity += theJoin->memoryCompares + theJoin->memoryAdds + theJoin->memoryDeletes; /* EnvPrintRouter(theEnv,WDISPLAY,": C "); PrintLongInteger(theEnv,WDISPLAY,theJoin->memoryCompares); EnvPrintRouter(theEnv,WDISPLAY,"/ A "); PrintLongInteger(theEnv,WDISPLAY,theJoin->memoryAdds); EnvPrintRouter(theEnv,WDISPLAY,"/ D "); PrintLongInteger(theEnv,WDISPLAY,theJoin->memoryDeletes); EnvPrintRouter(theEnv,WDISPLAY,"\n"); */ } if (theJoin->joinFromTheRight) { return(priorLeftPatterns + priorRightPatterns); } else { return(priorLeftPatterns + priorRightPatterns + 1); } }/*******************************************//* MatchesCountCommand: H/L access routine *//* for the matches-count command. *//*******************************************/globle void MatchesCountCommand( void *theEnv) { char *ruleName; void *rulePtr; ruleName = GetConstructName(theEnv,"matches-count","rule name"); if (ruleName == NULL) return; rulePtr = EnvFindDefrule(theEnv,ruleName); if (rulePtr == NULL) { CantFindItemErrorMessage(theEnv,"defrule",ruleName); return; } EnvMatchesCount(theEnv,rulePtr); }/*************************************//* EnvMatchesCount: C access routine *//* for the matches-count command. *//*************************************/globle intBool EnvMatchesCount( void *theEnv, void *theRule) { struct defrule *rulePtr, *tmpPtr; struct betaMemory *theMemory, **theStorage; struct partialMatch *listOfMatches; struct alphaMemoryHash *listOfHashNodes, **theAlphaStorage; struct joinNode *theJoin, *lastJoin; unsigned long b; int i, depth; ACTIVATION *agendaPtr; long count; /*=================================================*/ /* Loop through each of the disjuncts for the rule */ /*=================================================*/ for (rulePtr = (struct defrule *) theRule, tmpPtr = rulePtr; rulePtr != NULL; rulePtr = rulePtr->disjunct) { /*======================================*/ /* Determine the last join in the rule. */ /*======================================*/ lastJoin = rulePtr->lastJoin; /*===================================*/ /* Determine the number of patterns. */ /*===================================*/ depth = GetPatternNumberFromJoin(lastJoin); /*=========================================*/ /* Store the alpha memory partial matches. */ /*=========================================*/ theAlphaStorage = (struct alphaMemoryHash **) genalloc(theEnv,(unsigned) (depth * sizeof(struct alphaMemoryHash *))); theJoin = lastJoin;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -