Return the number of plants reached by the sprinkler.

        Returns a large penalty for sprinkler locations outside the map.
764336
def eval_fitness(self, chromosome):
        
        # convert DNA to represented sprinkler coordinates
        sx, sy = self.translator.translate_chromosome(chromosome)

        # check for invalid points
        penalty = 0
        if sx >= self.w:
            penalty += self.w * self.h
        if sy >= self.h:
            penalty += self.w * self.h

        if penalty > 0:
            self.fitness_cache[chromosome.dna] = -penalty
            return -penalty

        # calculate number of crop cells watered by sprinkler
        crops_watered = 0

        # check bounding box around sprinkler for crop cells
        # circle guaranteed to be within square with side length 2*r around sprinkler
        row_start_idx = max(0, sy - self.r)
        row_end_idx = min(sy + self.r + 1, self.h)
        col_start_idx = max(0, sx - self.r)
        col_end_idx = min(sx + self.r + 1, self.w)

        for y, row in enumerate(self.maplist[row_start_idx:row_end_idx], row_start_idx):
            for x, cell in enumerate(row[col_start_idx:col_end_idx], col_start_idx):
                if cell == 'x' and sprinkler_reaches_cell(x, y, sx, sy, self.r):
                    crops_watered += 1

        # reduce score by 1 if sprinkler placed on a crop cell
        if self.maplist[sy][sx] == 'x':
            crops_watered -= 1

        self.fitness_cache[chromosome.dna] = crops_watered
        return crops_watered
13613
public static int endPos(JCTree tree) {
        if (tree.hasTag(BLOCK) && ((JCBlock) tree).endpos != Position.NOPOS)
            return ((JCBlock) tree).endpos;
        else if (tree.hasTag(SYNCHRONIZED))
            return endPos(((JCSynchronized) tree).body);
        else if (tree.hasTag(TRY)) {
            JCTry t = (JCTry) tree;
            return endPos((t.finalizer != null) ? t.finalizer
                          : (t.catchers.nonEmpty() ? t.catchers.last().body : t.body));
        } else
            return tree.pos;
    }
1181009
public function getOtherStoresSettings(): int
    {
	    return (int)$this->_scopeConfig->getValue(self::OTHER_STORES_CONFIG_PATH, ScopeInterface::SCOPE_STORE);
    }
506829
public int getPathCount() {
    int result = 0;
    for(IndexTreePath<E> path = this; path != null; path = path.parentPath) {
      result++;
    }
    return result;
  }
975784
public List<IntVar> getOutgoing(Node n) {
        List<IntVar> l = outgoings.get(n);
        if (l == null) {
            l = Collections.emptyList();
        }
        return l;

    }
599734
def next(self):
        
        # do not acquire lock if NuMap is not finished.
        if self.finished:
            raise StopIteration
        # get per-tee lock
        self.piper.tee_locks[self.i].acquire()
        # get result or exception
        exception = True
        try:
            result = self.piper.tees[self.i].next()
            exception = False
        except StopIteration, result:
            self.finished = True
        except Exception, result:
            pass
        # release per-tee lock either self or next
        if self.s == self.stride or self.finished:
            self.s = 1
            self.piper.tee_locks[(self.i + 1) % len(self.piper.tees)].release()

        else:
            self.s += 1
            self.piper.tee_locks[self.i].release()
        if exception:
            raise result
        else:
            return result
1142034
int getAveMapSlotRefillMsecs() {
    synchronized (mapSlotRefillMsecsQueue) {
      if (mapSlotRefillMsecsQueue.isEmpty()) {
        return -1;
      }

      int totalMapSlotRefillMsecs = 0;
      for (int refillMsecs : mapSlotRefillMsecsQueue) {
        totalMapSlotRefillMsecs += refillMsecs;
      }
      return totalMapSlotRefillMsecs / mapSlotRefillMsecsQueue.size();
    }
  }
131610
final TreeMapEntry<K,V> getFirstEntry() {
        TreeMapEntry<K,V> p = root;
        if (p != null)
            while (p.left != null)
                p = p.left;
        return p;
    }
118029
public int countOccupiedMapSlots() {
    int mapSlotsCount = 0;
    for (Iterator<TaskStatus> it = taskReports.iterator(); it.hasNext();) {
      TaskStatus ts = (TaskStatus) it.next();
      if (ts.getIsMap() && isTaskRunning(ts)) {
        mapSlotsCount += ts.getNumSlots();
      }
    }
    return mapSlotsCount;
  }
285645
public long numBits() {
		if (n == 0) return 0;
		return offsets.size64() * log2BucketSize + lcpLengths.numBits() + lcp2Bucket.numBits() + mph.numBits() + transform.numBits();
	}
1278119
protected int getInternalDayFromLocation(float x, float y) {
        int dayStart = mEdgePadding;
        if (x < dayStart || x > mWidth - mEdgePadding) {
            return -1;
        }
        // Selection is (x - start) / (pixels/day) == (x -s) * day / pixels
        int row = (int) (y - getMonthHeaderSize()) / mRowHeight;
        int column = (int) ((x - dayStart) * mNumDays / (mWidth - dayStart - mEdgePadding));

        int day = column - findDayOffset() + 1;
        day += row * mNumDays;
        return day;
    }
443244
def countNeighbours(self, cell):
        
        count = 0
        y, x = cell
        y = y % self.y_grid
        x = x % self.x_grid
        y1 = (y - 1) % self.y_grid
        y2 = (y + 1) % self.y_grid
        x1 = (x - 1) % self.x_grid
        x2 = (x + 1) % self.x_grid
        cell = y, x

        for neighbour in product([y1, y, y2], [x1, x, x2]):
            if neighbour != cell and self.grid.get(neighbour):
                count += 1
        return count
194558
def get_distance(self, other, lbda=0.5, min_overlap=4):
        
        if self.tree ^ other.tree:
            if len(self.tree & other.tree) < min_overlap:
                return 0
                # raise AttributeError('Can\'t calculate tree distances when tree overlap is less than two leaves')
            else:
                t1, t2 = self._equalise_leaf_sets(other, False)
                tmp_self = KendallColijn(t1)
                tmp_other = KendallColijn(t2)

                return np.sqrt(((tmp_self.get_vector(lbda) - tmp_other.get_vector(lbda)) ** 2).sum())
        else:
            return np.sqrt(((self.get_vector(lbda) - other.get_vector(lbda)) ** 2).sum())
979126
public int getFlow() {
        GridNode nextDown = goDownstreamSP();
        if (nextDown == null) {
            return HMConstants.intNovalue;
        }

        int dcol = nextDown.col - col;
        int drow = nextDown.row - row;

        Direction dir = Direction.getDir(dcol, drow);
        return dir.getFlow();
    }
1249811
def is_outside_bounds(self, val):
    """"""
    return ((self.lower_bound is not None and val < self.lower_bound) or
            (self.upper_bound is not None and val > self.upper_bound))
242764
def potinf(self, x, y, aq=None):
        ''''''
        if aq is None: aq = self.model.aq.find_aquifer_data(x, y)
        rv = np.zeros((self.nparam, aq.naq))
        if aq == self.aq:
            pot = np.zeros(aq.naq)
            pot[:] = self.bessel.potbeslsho(float(x), float(y), self.z1, self.z2, aq.lab, 0,
                                            aq.ilap, aq.naq)
            rv[:] = self.aq.coef[self.layers] * pot
        return rv
369126
private int rasterLayerCount() {
		int rasterLayerCount = 0;
		for (int index = 0; index < mapInfo.getLayers().size(); index++) {
			if (layers.get(index) instanceof RasterLayer) {
				rasterLayerCount++;
			}
		}
		return rasterLayerCount;
	}