⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agenda.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
     {      /*====================================================*/      /* If the activation is the only remaining activation */      /* in the group, then the group needs to be removed.  */      /*====================================================*/            if (theActivation == theGroup->last)        {         if (theGroup->prev == NULL)           { theRuleModule->groupings = theGroup->next; }         else           { theGroup->prev->next = theGroup->next; }                    if (theGroup->next != NULL)           { theGroup->next->prev = theGroup->prev; }                    rtn_struct(theEnv,salienceGroup,theGroup);        }              /*======================================================*/      /* Otherwise this is the first activation in the group, */      /* but there are other activations which follow.        */      /*======================================================*/            else        { theGroup->first = theActivation->next; }     }   else     {      /*====================================================*/      /* Otherwise if the activation isn't the first in the */      /* group, then check to see if it's the last.         */      /*====================================================*/            if (theActivation == theGroup->last)        { theGroup->last = theActivation->prev; }              /*==================================================*/      /* Otherwise the activation is in the middle of the */      /* group and no first/last updates are needed.      */      /*==================================================*/            else        { return; }     }  }/**************************************************************//* AgendaClearFunction: Agenda clear routine for use with the *//*   clear command. Resets the current time tag to zero.      *//**************************************************************/static void AgendaClearFunction(  void *theEnv)  {   AgendaData(theEnv)->CurrentTimetag = 0;  }/*************************************************//* RemoveAllActivations: Removes all activations *//*   from the agenda of the current module.      *//*************************************************/globle void RemoveAllActivations(  void *theEnv)  {   struct activation *tempPtr, *theActivation;   struct salienceGroup *theGroup, *tempGroup;   theActivation = GetDefruleModuleItem(theEnv,NULL)->agenda;   while (theActivation != NULL)     {      tempPtr = theActivation->next;      RemoveActivation(theEnv,theActivation,TRUE,TRUE);      theActivation = tempPtr;     }   theGroup = GetDefruleModuleItem(theEnv,NULL)->groupings;   while (theGroup != NULL)     {      tempGroup = theGroup->next;      rtn_struct(theEnv,salienceGroup,theGroup);      theGroup = tempGroup;     } }/*********************************************************//* EnvGetAgendaChanged: Returns the value of the boolean *//*   flag which indicates whether any changes have been  *//*   made to the agenda.                                 *//*********************************************************/globle int EnvGetAgendaChanged(  void *theEnv)  {   return(AgendaData(theEnv)->AgendaChanged);  }/*****************************************************************//* EnvSetAgendaChanged: Sets the value of the boolean flag which *//*   indicates whether any changes have been made to the agenda. *//*****************************************************************/globle void EnvSetAgendaChanged(  void *theEnv,  int value)  {   AgendaData(theEnv)->AgendaChanged = value;  }/**********************************************************//* EnvReorderAgenda: Completely reorders the agenda based *//*   on the current conflict resolution strategy.         *//**********************************************************/globle void EnvReorderAgenda(  void *theEnv,  void *vTheModule)  {   struct activation *theActivation, *tempPtr;   struct defmodule *theModule = (struct defmodule *) vTheModule;   int allModules = FALSE;   struct defruleModule *theModuleItem;   struct salienceGroup *theGroup, *tempGroup;   /*=============================================*/   /* If the module specified is a NULL pointer,  */   /* then every module has its agenda reordered. */   /*=============================================*/   if (theModule == NULL)     {      allModules = TRUE;      theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);     }   /*========================*/   /* Reorder the agenda(s). */   /*========================*/   for (;        theModule != NULL;        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))     {      /*=================================*/      /* Get the list of activations and */      /* remove them from the agenda.    */      /*=================================*/      theModuleItem = GetDefruleModuleItem(theEnv,theModule);      theActivation = theModuleItem->agenda;      theModuleItem->agenda = NULL;      theGroup = theModuleItem->groupings;      while (theGroup != NULL)        {         tempGroup = theGroup->next;         rtn_struct(theEnv,salienceGroup,theGroup);         theGroup = tempGroup;        }      theModuleItem->groupings = NULL;              /*=========================================*/      /* Reorder the activations by placing them */      /* back on the agenda one by one.          */      /*=========================================*/      while (theActivation != NULL)        {         tempPtr = theActivation->next;         theActivation->next = NULL;         theActivation->prev = NULL;         theGroup = ReuseOrCreateSalienceGroup(theEnv,theModuleItem,theActivation->salience);         PlaceActivation(theEnv,&(theModuleItem->agenda),theActivation,theGroup);         theActivation = tempPtr;        }      /*===============================================*/      /* Return if only one agenda is being reordered. */      /*===============================================*/      if (! allModules) return;     }  }/****************************************************//* GetNumberOfActivations: Returns the value of the *//*   total number of activations on all agendas.    *//****************************************************/globle unsigned long GetNumberOfActivations(  void *theEnv)  {     return(AgendaData(theEnv)->NumberOfActivations);   }/******************************************************//* RefreshCommand: H/L Command for refreshing a rule. *//*   Syntax: (refresh <defrule-name>)                 *//******************************************************/globle void RefreshCommand(  void *theEnv)  {   char *ruleName;   void *rulePtr;   /*===========================*/   /* Get the name of the rule. */   /*===========================*/   ruleName = GetConstructName(theEnv,"refresh","rule name");   if (ruleName == NULL) return;   /*===============================*/   /* Determine if the rule exists. */   /*===============================*/   rulePtr = EnvFindDefrule(theEnv,ruleName);   if (rulePtr == NULL)     {      CantFindItemErrorMessage(theEnv,"defrule",ruleName);      return;     }   /*===================*/   /* Refresh the rule. */   /*===================*/   EnvRefresh(theEnv,rulePtr);  }/************************************************************//* EnvRefresh: Refreshes a defrule. Activations of the rule *//*   that have already been fired are added to the agenda.  *//************************************************************/globle intBool EnvRefresh(  void *theEnv,  void *theRule)  {   struct defrule *rulePtr;   struct partialMatch *listOfMatches;   unsigned long b;      /*====================================*/   /* Refresh each disjunct of the rule. */   /*====================================*/   for (rulePtr = (struct defrule *) theRule;        rulePtr != NULL;        rulePtr = rulePtr->disjunct)     {      /*================================*/      /* Check each partial match that  */      /* satisfies the LHS of the rule. */      /*================================*/      for (b = 0; b < rulePtr->lastJoin->leftMemory->size; b++)        {         for (listOfMatches = rulePtr->lastJoin->leftMemory->beta[b];              listOfMatches != NULL;              listOfMatches = listOfMatches->nextInMemory)           {            /*=======================================================*/            /* If the partial match is associated with an activation */            /* (which it should always be), then place a new         */            /* activation on the agenda if this partial matchdoesn't */            /* have an activation associated with it.                */            /*=======================================================*/            if (((struct joinNode *) listOfMatches->owner)->ruleToActivate != NULL)              {               if (listOfMatches->marker == NULL)                 { AddActivation(theEnv,rulePtr,listOfMatches); }              }           }        }     }   return(TRUE);  }/**********************************************//* RefreshAgendaCommand: H/L access routine   *//*   for the refresh-agenda command.          *//**********************************************/globle void RefreshAgendaCommand(  void *theEnv)  {   int numArgs, error;   struct defmodule *theModule;   /*==============================================*/   /* This function can have at most one argument. */   /*==============================================*/   if ((numArgs = EnvArgCountCheck(theEnv,"refresh-agenda",NO_MORE_THAN,1)) == -1) return;   /*===============================================================*/   /* If a module name is specified, then the agenda of that module */   /* is refreshed. Otherwise, the agenda of the current module is  */   /* refreshed.                                                    */   /*===============================================================*/   if (numArgs == 1)     {      theModule = GetModuleName(theEnv,"refresh-agenda",1,&error);      if (error) return;     }   else     { theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); }   /*===============================================*/   /* Refresh the agenda of the appropriate module. */   /*===============================================*/   EnvRefreshAgenda(theEnv,theModule);  }/**************************************//* EnvRefreshAgenda: C access routine *//*   for the refresh-agenda command.  *//**************************************/globle void EnvRefreshAgenda(  void *theEnv,  void *vTheModule)  {   struct activation *theActivation;   struct defmodule *theModule = (struct defmodule *) vTheModule;   intBool oldValue;   int allModules = FALSE;      /*==========================*/   /* Save the current module. */   /*==========================*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -