Esempio n. 1
0
    def getMaximum(self, locations, trace=None):
        """
        Finds the location in the current problem with the greatest value.

        RUNTIME: O(len(locations))
        """

        (bestLoc, bestVal) = (None, 0)

        for loc in locations:
            if bestLoc is None or self.get(loc) > bestVal:
                (bestLoc, bestVal) = (loc, self.get(loc))

        if not trace is None: trace.getMaximum(locations, bestLoc)

        return bestLoc
Esempio n. 2
0
    def getMaximum(self, locations, trace = None):
        """
        Finds the location in the current problem with the greatest value.

        RUNTIME: O(len(locations))
        """
   
        (bestLoc, bestVal) = (None, 0)
    
        for loc in locations:
            if bestLoc is None or self.get(loc) > bestVal:
                (bestLoc, bestVal) = (loc, self.get(loc))
    
        if not trace is None: trace.getMaximum(locations, bestLoc)

        return bestLoc