def work(self, belief): """Primary response function of HDC policy """ global_summary = SummaryMapping.globalSummary(belief, domainUtil=self.domainUtil) array_slot_summary = SummaryMapping.arraySlotSummary(belief, self.domainUtil) logger.debug(str(global_summary)) logger.debug('HDC policy: getGlobal') done, output = self._getGlobal(belief, global_summary) if not done: logger.debug('HDC policy: getConfirmSelect') done, output = self._getConfirmSelect(belief, array_slot_summary) if not done: logger.debug('HDC policy: getInform') inform_summary = [] for num_accepted in range(1, MAX_NUM_ACCEPTED+1): temp = SummaryMapping.actionSpecificInformSummary(belief, num_accepted, self.domainUtil) inform_summary.append(temp) done, output = self._getInform(belief, global_summary, inform_summary) if not done: logger.debug('HDC policy: getRequest') done, output = self._getRequest(belief, array_slot_summary) if not done: logger.warning("HDCPolicy couldn't find action: execute reqmore().") output = 'reqmore()' if output == 'badact()' or output == 'null()': logger.warning('HDCPolicy chose bad or null action') output = 'null()' if self.use_confreq: #TODO - known problem here if use_confreq is True (ie being used) FIXME output = DMUtils.add_venue_count(output, belief) return output
def getInform(self, belief): """ """ act = "null()" done = False global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) inform_summary = [] for num_accepted in range(1, MAX_NUM_ACCEPTED + 1): inform_summary.append(SummaryMapping.actionSpecificInformSummary(belief, num_accepted, self.domainUtil)) count80 = global_summary["GLOBAL_COUNT80"] offer_happened = global_summary["GLOBAL_OFFERHAPPENED"] if count80 >= MAX_NUM_ACCEPTED: count80 = MAX_NUM_ACCEPTED - 1 arr = inform_summary[count80] first = arr[0] # True if there is no matching entities second = arr[1] # True if there is one matching entities # third = arr[2] # True if there is two~four matching entities discr = arr[4] # True if we can discriminate more requested_slots = DMUtils.getRequestedSlots(belief) # if (first or second or not discr or count80 >= len(Settings.ontology['system_requestable'])) and len(requested_slots)==0: act = DMUtils.getInformAction(count80, belief, self.domainUtil) if act != "null()": done = True return [done, act]
def getInform(self, belief): ''' ''' act = "null()" done = False global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) inform_summary = [] for num_accepted in range(1, MAX_NUM_ACCEPTED + 1): inform_summary.append( SummaryMapping.actionSpecificInformSummary( belief, num_accepted, self.domainUtil)) count80 = global_summary['GLOBAL_COUNT80'] offer_happened = global_summary['GLOBAL_OFFERHAPPENED'] if count80 >= MAX_NUM_ACCEPTED: count80 = MAX_NUM_ACCEPTED - 1 arr = inform_summary[count80] first = arr[0] # True if there is no matching entities second = arr[1] # True if there is one matching entities #third = arr[2] # True if there is two~four matching entities discr = arr[4] # True if we can discriminate more requested_slots = DMUtils.getRequestedSlots(belief) #if (first or second or not discr or count80 >= len(Settings.ontology['system_requestable'])) and len(requested_slots)==0: act = DMUtils.getInformAction(count80, belief, self.domainUtil) if act != "null()": done = True return [done, act]
def getRestart(self, belief): """ """ global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = "null()" if global_summary["GLOBAL_RESTART"] > 0.5: act = DMUtils.getGlobalAction(belief, "RESTART", self.domainUtil) if act != "null()": done = True return done, act
def getReqMore(self, belief): """ """ global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = "null()" # if global_summary['GLOBAL_ACK'] > 0.5 or global_summary['GLOBAL_THANKYOU']>0.5: act = DMUtils.getGlobalAction(belief, "REQMORE", self.domainUtil) if act != "null()": done = True return done, act
def getBye(self, belief): """ """ global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = "null()" if global_summary["GLOBAL_FINISHED"] > 0.5: act = DMUtils.getGlobalAction(belief, "BYE", self.domainUtil) if act != "null()": done = True return done, act
def getInformRequested(self, belief): """ """ global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = "null()" if global_summary["GLOBAL_BYNAME"] > 0.5: act = DMUtils.getGlobalAction(belief, "INFORM_REQUESTED", self.domainUtil) if act != "null()": done = True return done, act
def getInformAlternatives(self, belief): """ """ global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = "null()" if global_summary["GLOBAL_BYALTERNATIVES"] > 0.5: act = DMUtils.getGlobalAction(belief, "INFORM_ALTERNATIVES", self.domainUtil) if act != "null()": done = True return done, act
def getRestart(self, belief): ''' ''' global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = 'null()' if global_summary['GLOBAL_RESTART'] > 0.5: act = DMUtils.getGlobalAction(belief, 'RESTART', self.domainUtil) if act != 'null()': done = True return done, act
def getReqMore(self, belief): ''' ''' global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = 'null()' #if global_summary['GLOBAL_ACK'] > 0.5 or global_summary['GLOBAL_THANKYOU']>0.5: act = DMUtils.getGlobalAction(belief, 'REQMORE', self.domainUtil) if act != 'null()': done = True return done, act
def getBye(self, belief): ''' ''' global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = 'null()' if global_summary['GLOBAL_FINISHED'] > 0.5: act = DMUtils.getGlobalAction(belief, 'BYE', self.domainUtil) if act != 'null()': done = True return done, act
def getInformRequested(self, belief): ''' ''' global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = 'null()' if global_summary['GLOBAL_BYNAME'] > 0.5: act = DMUtils.getGlobalAction(belief, 'INFORM_REQUESTED', self.domainUtil) if act != 'null()': done = True return done, act
def getInformAlternatives(self, belief): ''' ''' global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = 'null()' if global_summary['GLOBAL_BYALTERNATIVES'] > 0.5: act = DMUtils.getGlobalAction(belief, 'INFORM_ALTERNATIVES', self.domainUtil) if act != 'null()': done = True return done, act
def getInformByName(self, belief): """ """ global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = "null()" if ( global_summary["GLOBAL_BYCONSTRAINTS"] > 0.5 # or global_summary['GLOBAL_BYNAME'] >0 or global_summary['GLOBAL_BYALTERNATIVES'] > 0.5 ) and global_summary["GLOBAL_COUNT80"] > 3: act = DMUtils.getGlobalAction(belief, "INFORM_BYNAME", self.domainUtil) if act != "null()": done = True return done, act
def getInformByName(self, belief): ''' ''' global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) done = False act = 'null()' if (global_summary['GLOBAL_BYCONSTRAINTS'] > 0.5 #or global_summary['GLOBAL_BYNAME'] >0 or global_summary['GLOBAL_BYALTERNATIVES'] > 0.5 ) and\ global_summary['GLOBAL_COUNT80'] > 3: act = DMUtils.getGlobalAction(belief, 'INFORM_BYNAME', self.domainUtil) if act != 'null()': done = True return done, act
def work(self, belief): """Primary response function of HDC policy """ global_summary = SummaryMapping.globalSummary( belief, domainUtil=self.domainUtil) array_slot_summary = SummaryMapping.arraySlotSummary( belief, self.domainUtil) logger.debug(str(global_summary)) logger.debug('HDC policy: getGlobal') done, output = self._getGlobal(belief, global_summary) if not done: logger.debug('HDC policy: getConfirmSelect') done, output = self._getConfirmSelect(belief, array_slot_summary) if not done: logger.debug('HDC policy: getInform') inform_summary = [] for num_accepted in range(1, MAX_NUM_ACCEPTED + 1): temp = SummaryMapping.actionSpecificInformSummary( belief, num_accepted, self.domainUtil) inform_summary.append(temp) done, output = self._getInform(belief, global_summary, inform_summary) if not done: logger.debug('HDC policy: getRequest') done, output = self._getRequest(belief, array_slot_summary) if not done: logger.warning( "HDCPolicy couldn't find action: execute reqmore().") output = 'reqmore()' if output == 'badact()' or output == 'null()': logger.warning('HDCPolicy chose bad or null action') output = 'null()' if self.use_confreq: #TODO - known problem here if use_confreq is True (ie being used) FIXME output = DMUtils.add_venue_count(output, belief) return output