📄 crstrtgy.c
字号:
lastAct = NULL; /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the OPS5 lex strategy is used for */ /* determining placement. */ /*=========================================================*/ while (actPtr != NULL) { if (actPtr->salience > salience) { lastAct = actPtr; actPtr = actPtr->next; } else if (actPtr->salience < salience) { return(lastAct); } else { flag = ComparePartialMatches(actPtr,newActivation); if (flag == LESS_THAN) { lastAct = actPtr; actPtr = actPtr->next; } else if (flag == GREATER_THAN) { return(lastAct); } else /* flag == EQUAL */ { if (timetag > actPtr->timetag) { lastAct = actPtr; actPtr = actPtr->next; } else { return(lastAct); } } } } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*******************************************************************//* PlaceMEAActivation: Determines the location in the agenda *//* where a new activation should be placed for the mea *//* strategy. Returns a pointer to the activation after which *//* the new activation should be placed (or NULL if the *//* activation should be placed at the beginning of the agenda). *//*******************************************************************/static ACTIVATION *PlaceMEAActivation(actPtr,newActivation) ACTIVATION *actPtr; ACTIVATION *newActivation; { int salience; unsigned long timetag; ACTIVATION *lastAct; int flag; long int cWhoset, oWhoset; if (newActivation->sortedBasis == NULL) { newActivation->sortedBasis = SortPartialMatch(newActivation->basis); } /*============================================*/ /* Set up initial information for the search. */ /*============================================*/ timetag = newActivation->timetag; salience = newActivation->salience; lastAct = NULL; /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the OPS5 mea strategy is used for */ /* determining placement. */ /*=========================================================*/ while (actPtr != NULL) { if (actPtr->salience > salience) { lastAct = actPtr; actPtr = actPtr->next; } else if (actPtr->salience < salience) { return(lastAct); } else { cWhoset = -1; oWhoset = -1; if (GetMatchingItem(newActivation,0) != NULL) { cWhoset = GetMatchingItem(newActivation,0)->timeTag; } if (GetMatchingItem(actPtr,0) != NULL) { oWhoset = GetMatchingItem(actPtr,0)->timeTag; } if (oWhoset < cWhoset) { if (cWhoset > 0) flag = GREATER_THAN; else flag = LESS_THAN; } else if (oWhoset > cWhoset) { if (oWhoset > 0) flag = LESS_THAN; else flag = GREATER_THAN; } else { flag = ComparePartialMatches(actPtr,newActivation); } if (flag == LESS_THAN) { lastAct = actPtr; actPtr = actPtr->next; } else if (flag == GREATER_THAN) { return(lastAct); } else /* flag == EQUAL */ { if (timetag > actPtr->timetag) { lastAct = actPtr; actPtr = actPtr->next; } else { return(lastAct); } } } } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*********************************************************************//* PlaceComplexityActivation: Determines the location in the agenda *//* where a new activation should be placed for the complexity *//* strategy. Returns a pointer to the activation after which the *//* new activation should be placed (or NULL if the activation *//* should be placed at the beginning of the agenda). *//*********************************************************************/static ACTIVATION *PlaceComplexityActivation(actPtr,newActivation) ACTIVATION *actPtr; ACTIVATION *newActivation; { int salience, complexity; unsigned long timetag; ACTIVATION *lastAct; /*========================================*/ /* Set up initial information for search. */ /*========================================*/ timetag = newActivation->timetag; salience = newActivation->salience; complexity = newActivation->theRule->complexity; lastAct = NULL; /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the activation is placed before */ /* activations of equal or lessor complexity. */ /*=========================================================*/ while (actPtr != NULL) { if (actPtr->salience > salience) { lastAct = actPtr; actPtr = actPtr->next; } else if (actPtr->salience < salience) { return(lastAct); } else if (complexity < (int) actPtr->theRule->complexity) { lastAct = actPtr; actPtr = actPtr->next; } else if (complexity > (int) actPtr->theRule->complexity) { return(lastAct); } else if (timetag > actPtr->timetag) { lastAct = actPtr; actPtr = actPtr->next; } else { return(lastAct); } } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*********************************************************************//* PlaceSimplicityActivation: Determines the location in the agenda *//* where a new activation should be placed for the simplicity *//* strategy. Returns a pointer to the activation after which the *//* new activation should be placed (or NULL if the activation *//* should be placed at the beginning of the agenda). *//*********************************************************************/static ACTIVATION *PlaceSimplicityActivation(actPtr,newActivation) ACTIVATION *actPtr; ACTIVATION *newActivation; { int salience, complexity; unsigned long timetag; ACTIVATION *lastAct; /*============================================*/ /* Set up initial information for the search. */ /*============================================*/ timetag = newActivation->timetag; salience = newActivation->salience; complexity = newActivation->theRule->complexity; lastAct = NULL; /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the activation is placed after */ /* activations of equal or greater complexity. */ /*=========================================================*/ while (actPtr != NULL) { if (actPtr->salience > salience) { lastAct = actPtr; actPtr = actPtr->next; } else if (actPtr->salience < salience) { return(lastAct); } else if (complexity > (int) actPtr->theRule->complexity) { lastAct = actPtr; actPtr = actPtr->next; } else if (complexity < (int) actPtr->theRule->complexity) { return(lastAct); } else if (timetag > actPtr->timetag) { lastAct = actPtr; actPtr = actPtr->next; } else { return(lastAct); } } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*******************************************************************//* PlaceRandomActivation: Determines the location in the agenda *//* where a new activation should be placed for the random *//* strategy. Returns a pointer to the activation after which *//* the new activation should be placed (or NULL if the *//* activation should be placed at the beginning of the agenda). *//*******************************************************************/static ACTIVATION *PlaceRandomActivation(actPtr,newActivation) ACTIVATION *actPtr; ACTIVATION *newActivation; { int salience, randomID; unsigned long timetag; ACTIVATION *lastAct; /*============================================*/ /* Set up initial information for the search. */ /*============================================*/ timetag = newActivation->timetag; salience = newActivation->salience; randomID = newActivation->randomID; lastAct = NULL; /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the placement of the activation is */ /* determined through the generation of a random number. */ /*=========================================================*/ while (actPtr != NULL) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -