Depth-first exploration
497467
public static Optional<QueryNode> getDepthFirstNextNode(IntermediateQuery query, QueryNode currentNode) {
        return getDepthFirstNextNode(query, currentNode, false);
    }
513945
def spacetodepth(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'})

    return "space_to_depth", new_attrs, inputs
1184859
function explore(o1, o2){
      if (typeof o2 === 'undefined') { // ignore undefined values
        grunt.verbose.writeln('Base value');
        return o1;
      }
      else if (o2 === null) { // null values overwrite the base value
        grunt.verbose.writeln('Null');
        return null;
      }
      else if (Array.isArray(o2)){ // Array overwrite base value
        grunt.verbose.writeln('Array');
        return o2;
      }
      else if (typeof o2 === 'object' && o1 != null){ // Object is completed
        var res = {}, keys = Object.keys(o1), keys2 = Object.keys(o2);
        for (var i = 0; i < keys.length; i++){
          var key = keys[i];
          grunt.verbose.write(key + ': ');
          res[key] = explore(o1[key], o2[key]);
        }

        // loop target config for keys that do not exist in base config
        for (var j = 0; j < keys2.length; j++){
          var key = keys2[j];
          if (typeof o1[key] === 'undefined'){
            grunt.verbose.write(key + ': ');
            res[key] = explore(null, o2[key]);
          }
        }
        return res;
      }
      else {
        // primitive values overwrite base value
        // also applied to objects when base key is undefined
        grunt.verbose.writeln(o2);
        return o2;
      }
    }
705582
private Map<ElementDescriptor<?>, Object> getDepthStateMap(int depth, boolean create)
	{
		if (mState == null)
		{
			mState = new ArrayList<Map<ElementDescriptor<?>, Object>>(Math.max(16, depth + 8));
		}

		// fill array list with null values up to the current depth
		while (depth > mState.size())
		{
			mState.add(null);
		}

		Map<ElementDescriptor<?>, Object> map = mState.get(depth - 1 /* depth is at least 1 */);

		if (!create || map != null)
		{
			return map;
		}

		// map is null and we shall create it
		map = new HashMap<ElementDescriptor<?>, Object>(8);
		mState.set(depth - 1, map);
		return map;
	}
406904
def begin(self):
        """"""
        self.out_f.write('\n')
        for depth, name in enumerate(self.names):
            self.out_f.write(
                '{0}namespace {1}\n{0}{{\n'.format(self.prefix(depth), name)
            )
444449
def forward(inputs_i, Q, G, A, b, h, U_Q, U_S, R, verbose=False):
    
    nineq, nz, neq, _ = get_sizes(G, A)

    # find initial values
    d = torch.ones(nineq).type_as(Q)
    nb = -b if b is not None else None
    factor_kkt(U_S, R, d)
    x, s, z, y = solve_kkt(
        U_Q, d, G, A, U_S,
        inputs_i, torch.zeros(nineq).type_as(Q), -h, nb)
    # x1, s1, z1, y1 = factor_solve_kkt(Q, torch.eye(nineq).type_as(Q), G, A, inputs_i,
    # torch.zeros(nineq).type_as(Q), -h, nb)

    if torch.min(s) < 0:
        s -= torch.min(s) - 1
    if torch.min(z) < 0:
        z -= torch.min(z) - 1

    prev_resid = None
    for i in range(20):
        # affine scaling direction
        rx = (torch.mv(A.t(), y) if neq > 0 else 0.) + \
            torch.mv(G.t(), z) + torch.mv(Q, x) + inputs_i
        rs = z
        rz = torch.mv(G, x) + s - h
        ry = torch.mv(A, x) - b if neq > 0 else torch.Tensor([0.])
        mu = torch.dot(s, z) / nineq
        pri_resid = torch.norm(ry) + torch.norm(rz)
        dual_resid = torch.norm(rx)
        resid = pri_resid + dual_resid + nineq * mu
        d = z / s
        if verbose:
            print(("primal_res = {0:.5g}, dual_res = {1:.5g}, " +
                   "gap = {2:.5g}, kappa(d) = {3:.5g}").format(
                pri_resid, dual_resid, mu, min(d) / max(d)))
        # if (pri_resid < 5e-4 and dual_resid < 5e-4 and mu < 4e-4):
        improved = (prev_resid is None) or (resid < prev_resid + 1e-6)
        if not improved or resid < 1e-6:
            return x, y, z
        prev_resid = resid

        factor_kkt(U_S, R, d)
        dx_aff, ds_aff, dz_aff, dy_aff = solve_kkt(U_Q, d, G, A, U_S,
                                                   rx, rs, rz, ry)
        # D = torch.diag((z/s).cpu()).type_as(Q)
        # dx_aff1, ds_aff1, dz_aff1, dy_aff1 = factor_solve_kkt(Q, D, G, A, rx, rs, rz, ry)

        # compute centering directions
        alpha = min(min(get_step(z, dz_aff), get_step(s, ds_aff)), 1.0)
        sig = (torch.dot(s + alpha * ds_aff, z +
                         alpha * dz_aff) / (torch.dot(s, z)))**3
        dx_cor, ds_cor, dz_cor, dy_cor = solve_kkt(
            U_Q, d, G, A, U_S, torch.zeros(nz).type_as(Q),
            (-mu * sig * torch.ones(nineq).type_as(Q) + ds_aff * dz_aff) / s,
            torch.zeros(nineq).type_as(Q), torch.zeros(neq).type_as(Q))
        # dx_cor, ds_cor, dz_cor, dy_cor = factor_solve_kkt(Q, D, G, A,
        #     torch.zeros(nz).type_as(Q),
        #     (-mu*sig*torch.ones(nineq).type_as(Q) + ds_aff*dz_aff)/s,
        #     torch.zeros(nineq).type_as(Q), torch.zeros(neq).type_as(Q))

        dx = dx_aff + dx_cor
        ds = ds_aff + ds_cor
        dz = dz_aff + dz_cor
        dy = dy_aff + dy_cor if neq > 0 else None
        alpha = min(1.0, 0.999 * min(get_step(s, ds), get_step(z, dz)))
        dx_norm = torch.norm(dx)
        dz_norm = torch.norm(dz)
        if np.isnan(dx_norm) or dx_norm > 1e5 or dz_norm > 1e5:
            # Overflow, return early
            return x, y, z

        x += alpha * dx
        s += alpha * ds
        z += alpha * dz
        y = y + alpha * dy if neq > 0 else None

    return x, y, z
569812
private int compareToLastRow(int depth)
        {
            for (int i = 0 ; i <= depth ; i++)
            {
                int p = currentRow[i], l = lastRow[i], r = clusteringComponents[i].size();
                if ((p == l) | (r == 1))
                    continue;
                return p - l;
            }
            return 0;
        }
262195
def step(self, exploration):
        
        old_s = self._current_ob
        if self.rng.rand() <= exploration:
            act = self.rng.choice(range(self.num_actions))
        else:
            history = self.recent_state()
            history.append(old_s)
            history = np.stack(history, axis=-1)  # state_shape + (Hist,)

            # assume batched network
            history = np.expand_dims(history, axis=0)
            q_values = self.predictor(history)[0][0]  # this is the bottleneck
            act = np.argmax(q_values)

        self._current_ob, reward, isOver, info = self.player.step(act)
        self._current_game_score.feed(reward)
        self._current_episode.append(Experience(old_s, act, reward, isOver))

        if isOver:
            flush_experience = True
            if 'ale.lives' in info:  # if running Atari, do something special
                if info['ale.lives'] != 0:
                    # only record score and flush experience
                    # when a whole game is over (not when an episode is over)
                    flush_experience = False
            self.player.reset()

            if flush_experience:
                self.total_scores.append(self._current_game_score.sum)
                self._current_game_score.reset()

                # Ensure that the whole episode of experience is continuous in the replay buffer
                with self.memory.writer_lock:
                    for exp in self._current_episode:
                        self.memory.append(exp)
                self._current_episode.clear()
1005808
def derive_depth(self, depth):
        
        cls = type(self)
        # We use ordinals to avoid thunk materialization.
        return cls(
            self[0],
            self[1],
            self[2],
            self[3],
            self[4],
            depth
        )
140504
function (depth) {
        this.set('depth', depth);

        depth++;
        this.get('inputs').forEach(function (input) {
          input.set('depth', depth);
        });
      }
450684
def depth_first_spanning_tree(start_node)
      raise ArgumentError unless vertices.include?(start_node)
      tree = DirectedAdjacencyGraph.new
      visited = Set.new
      build_dfst(tree, start_node, visited)
      tree
    end
1001134
private void depthFirstSearch(final Range<C> query, final Node node, final List<Range<C>> result, final Set<Node> visited) {
        if (node == null || visited.contains(node) || query.isEmpty()) {
            return;
        }
        if (node.left() != null && Ranges.isLessThan(query, node.center())) {
            depthFirstSearch(query, node.left(), result, visited);
        }
        else if (node.right() != null && Ranges.isGreaterThan(query, node.center())) {
            depthFirstSearch(query, node.right(), result, visited);
        }
        if (Ranges.isGreaterThan(query, node.center())) {
            for (Range<C> range : node.overlapByUpperEndpoint()) {
                if (Ranges.intersect(range, query)) {
                    result.add(range);
                }
                if (Ranges.isGreaterThan(query, range.upperEndpoint())) {
                    break;
                }
            }
        }
        else if (Ranges.isLessThan(query, node.center())) {
            for (Range<C> range : node.overlapByLowerEndpoint()) {
                if (Ranges.intersect(range, query)) {
                    result.add(range);
                }
                if (Ranges.isLessThan(query, range.lowerEndpoint())) {
                    break;
                }
            }
        }
        else {
            result.addAll(node.overlapByLowerEndpoint());
        }
        visited.add(node);
    }
711901
function (array, c, depth) {
        var start = array.length - (array.length / Math.pow(2, depth));
        for (var i = start, len = array.length; i < len; i += 1) {
            array[i] += c;
        }
    }
45448
function init() {
  shift++;
  samples = new SamplePoints();
  samples.setBounds( new Rectangle( 25, 25 ).size( space.size.x - 25, space.size.y - 25 ), true );
  samples.poissonSampler( 6 ); // target 6px radius
}
307962
private static <M extends Model> void findDepth(Hierarchy<Cluster<M>> hier, Cluster<M> cluster, int[] size) {
    if(hier.numChildren(cluster) > 0) {
      for(It<Cluster<M>> iter = hier.iterChildren(cluster); iter.valid(); iter.advance()) {
        findDepth(hier, iter.get(), size);
      }
      size[0] += 1; // Depth
    }
    else {
      size[1] += 1; // Leaves
    }
  }
978701
def run_brute(self):
        
        global collidable_objects
        if self.collision_depth == self.SHALLOW_DEPTH:
            for obj in collidable_objects:
                collision = self.query_collision(obj)
                if collision is not None:
                    #Execute the reactions for both of the colliding objects.
                    obj.collision_response(collision)
                    collision.collision_response(obj)
        elif self.collision_depth == self.DEEP_DEPTH:
            for obj in collidable_objects:
                collisions = self.query_all_collisions(obj)
                for collision in collisions:
                    #Execute the reactions for both of the colliding objects.
                    obj.collision_response(collision)
                    collision.collision_response(obj)
428703
function traverseTwoPhase(inst, fn, arg) {
  var path = [];
  while (inst) {
    path.push(inst);
    inst = inst._hostParent;
  }
  var i;
  for (i = path.length; i-- > 0;) {
    fn(path[i], 'captured', arg);
  }
  for (i = 0; i < path.length; i++) {
    fn(path[i], 'bubbled', arg);
  }
}