Saturday, July 5, 2025

 The previous articles described position and velocity adjustments for drone formation to transform from one phase to another. While those methods allow individual units to transition to the new formation it does not detect conflicts. So the conflict detection strategy must be layered on the position, velocity and heading determination. This is especially true for fixed wing drones that do not have hover and yawing capabilities  

An example for this is now illustrated below: 

import heapq 

from collections import defaultdict, namedtuple 

 

Constraint = namedtuple('Constraint', ['agent', 'position', 'time']) 

 

class AStarPlanner: 

    def __init__(self, grid): 

        self.grid = grid 

        self.rows = len(grid) 

        self.cols = len(grid[0]) 

     

    def neighbors(self, pos): 

        r, c = pos 

        for dr, dc in [(0,1), (1,0), (0,-1), (-1,0), (0,0)]:  # 4 directions + wait 

            nr, nc = r + dr, c + dc 

            if 0 <= nr < self.rows and 0 <= nc < self.cols and self.grid[nr][nc] != 1: 

                yield (nr, nc) 

 

    def heuristic(self, a, b): 

        return abs(a[0] - b[0]) + abs(a[1] - b[1]) 

 

    def plan(self, start, goal, constraints): 

        open_set = [(0 + self.heuristic(start, goal), 0, start, [start])] 

        seen = set() 

        constraint_dict = defaultdict(set) 

        for c in constraints: 

            constraint_dict[(c.position, c.time)].add(c.agent) 

 

        while open_set: 

            f, g, current, path = heapq.heappop(open_set) 

            if (current, g) in seen: 

                continue 

            seen.add((current, g)) 

 

            if current == goal and g >= max(t for _, t in constraint_dict.keys() if _[0] == goal or _[1] == goal or not constraint_dict else 0): 

                return path 

             

            for neighbor in self.neighbors(current): 

                if any(c.agent == 'any' or c.agent == agent for c in constraint_dict.get((neighbor, g+1), set())): 

                    continue 

                heapq.heappush(open_set, (g + 1 + self.heuristic(neighbor, goal), g + 1, neighbor, path + [neighbor])) 

        return None  # No path found 

 

class CBS: 

    def __init__(self, grid, starts, goals): 

        self.grid = grid 

        self.starts = starts 

        self.goals = goals 

        self.num_agents = len(starts) 

 

    def detect_conflict(self, paths): 

        max_t = max(len(p) for p in paths) 

        for t in range(max_t): 

            positions = {} 

            for i, path in enumerate(paths): 

                pos = path[t] if t < len(path) else path[-1] 

                if pos in positions: 

                    return {'time': t, 'a1': positions[pos], 'a2': i, 'pos': pos} 

                positions[pos] = i 

        return None 

 

    def search(self): 

        root = {'paths': [], 'constraints': []} 

        astar = AStarPlanner(self.grid) 

         

        for i in range(self.num_agents): 

            path = astar.plan(self.starts[i], self.goals[i], []) 

            if not path: 

                return None 

            root['paths'].append(path) 

         

        open_set = [root] 

        while open_set: 

            node = open_set.pop(0) 

            conflict = self.detect_conflict(node['paths']) 

            if not conflict: 

                return node['paths'] 

 

            for agent in [conflict['a1'], conflict['a2']]: 

                new_constraints = node['constraints'] + [Constraint(agent, conflict['pos'], conflict['time'])] 

                new_paths = list(node['paths']) 

                path = astar.plan(self.starts[agent], self.goals[agent], new_constraints) 

                if not path: 

                    continue 

                new_paths[agent] = path 

                open_set.append({'constraints': new_constraints, 'paths': new_paths}) 

        return None 

Friday, July 4, 2025

 This is a summary of the book titled “Predictable Winners” written by Ilya Trakhtenberg and Stuart Jackson and published by Stanford University Press in 2025. Launching a product and taking off from the runaway must be planned for says the author otherwise there are risks. “Predictable Winners” demonstrate patterns from a host of real-world case studies which maximize success at every stage and scope from testing prototypes to developing financial plans. It even calls for market research and revenue forecasting. As product owners articulate value propositions, they must manage risks by gauging interests, seeking improvements, and defining audience and market growth. It helps to understanding competition, building business case, and engage in launch planning. Winning companies often produce additional products and services.

In this book, the authors explore the art and science of launching successful innovations. Drawing from real-world examples, the book offers a comprehensive roadmap for navigating the uncertainty of product development—from prototype to launch—by prioritizing risk management, market insight, and strategic execution.

The authors argue that while innovation is often portrayed as a gamble, success can be engineered through disciplined, repeatable processes. Companies that manage risks effectively can push their success rates far beyond the typical 5% seen among new product launches. This begins with embracing the ”fail-fast” mindset—developing minimal prototypes, testing them rapidly, and using feedback to either pivot or proceed with confidence. Innovation, they emphasize, means accepting imperfection and using failure as an opportunity to learn and adapt.

A core theme of the book is deliberate market alignment. Breakthrough products succeed when they tap into underserved needs or enhance existing customer experiences. Case studies like Square (which empowered small businesses with affordable payment systems) and 3M (which leveraged material science expertise to create sticky notes) illustrate how applying unique strengths to familiar domains allows innovators to outpace competitors.

Feedback is another vital pillar. The authors advocate using analogs—similar existing products—as indicators of potential success. They also encourage social listening and direct user testing to gauge demand early. Entrepreneurs, for example, might use farmer’s markets or five-day design sprints to gather low-cost, actionable insights before investing heavily. The idea is simple: match the scale of your investment to your confidence in the product’s viability.

Identifying the right audience and scaling strategically is also key. Innovators must view early adopters not as an end goal but as a gateway to broader markets. Defining one’s serviceable addressable market (SAM) and segmenting potential customers by behavior, values, or financial status helps refine this focus. Intuitive Surgical’s initial success with urologists, for example, set the stage for wider adoption of its robotic surgery systems.

Market research, when done right, becomes a predictive tool. Interviews and surveys should uncover not just surface opinions but the true decision-making criteria of target customers. Observing what similar customers already buy can 44be more revealing than what they claim they might purchase. For example, evaluating streaming habits helped one sports entertainment firm model demand for a new service more accurately.

Understanding the competitive landscape is essential. Using methods like “wargaming” to simulate competitor responses helps anticipate threats before launch. Motorola’s Iridium satellite phone failure serves as a cautionary tale of underestimating market changes during prolonged development cycles. Instead of grand-scale surveys up front, the authors recommend iterative, year-over-year insights to stay nimble.

Another crucial aspect is building a credible business case. Innovators need to align pricing with perceived value and willingness to pay, especially among early adopters who may accept higher prices. Revenue forecasts should be built both bottom-up (from pricing and estimated units sold) and top-down (from projected market share). Stress-testing those forecasts through scenario planning or Monte Carlo simulations ensures realistic expectations.

Finally, the authors underscore the importance of thoughtful launch planning. Many innovations falter not because of design flaws, but due to poor rollout. Launch strategies should be drafted months in advance and continuously refined. They should address adoption barriers—like trust or usability—and map out team roles, deliverables, and market triggers. Uber’s strategy to mitigate user safety concerns, for instance, was a pivotal factor in its growth.

In conclusion, Predictable Winners debunks the myth of innovation as a guessing game. Instead, it presents innovation as an intentional, learnable discipline that rewards preparation, resilience, and empathy for customers. As companies scale, balancing breakthrough efforts with incremental improvements becomes the foundation of long-term success—just as Garmin did when it transitioned from GPS units to fitness trackers. Success isn’t just about launching; it’s about listening, learning, and continuously evolving.

#codingexercise: CodingExercise-07-04-2025.docx

Thursday, July 3, 2025

 #Codingexercise

Given a wire grid of size N * N with N-1 horizontal edges and N-1 vertical edges along the X and Y axis respectively, and a wire burning out every instant as per the given order using three matrices A, B, C such that the wire that burns is

(A[T], B[T] + 1), if C[T] = 0 or

(A[T] + 1, B[T]), if C[T] = 1

Determine the instant after which the circuit is broken

     public static boolean checkConnections(int[] h, int[] v, int N) {

        boolean[][] visited = new boolean[N][N];

        dfs(h, v, visited,0,0);

        return visited[N-1][N-1];

    }

    public static void dfs(int[]h, int[]v, boolean[][] visited, int i, int j) {

        int N = visited.length;

        if (i < N && j < N && i>= 0 && j >= 0 && !visited[i][j]) {

            visited[i][j] = true;

            if (v[i * (N-1) + j] == 1) {

                dfs(h, v, visited, i, j+1);

            }

            if (h[i * (N-1) + j] == 1) {

                dfs(h, v, visited, i+1, j);

            }

            if (i > 0 && h[(i-1)*(N-1) + j] == 1) {

                dfs(h,v, visited, i-1, j);

            }

            if (j > 0 && h[(i * (N-1) + (j-1))] == 1) {

                dfs(h,v, visited, i, j-1);

            }

        }

    }

    public static int burnout(int N, int[] A, int[] B, int[] C) {

        int[] h = new int[N*N];

        int[] v = new int[N*N];

        for (int i = 0; i < N*N; i++) { h[i] = 1; v[i] = 1; }

        for (int i = 0; i < N; i++) {

            h[(i * (N)) + N - 1] = 0;

            v[(N-1) * (N) + i] = 0;

        }

        System.out.println(printArray(h));

        System.out.println(printArray(v));

        for (int i = 0; i < A.length; i++) {

            if (C[i] == 0) {

                v[A[i] * (N-1) + B[i]] = 0;

            } else {

                h[A[i] * (N-1) + B[i]] = 0;

            }

            if (!checkConnections(h,v, N)) {

                return i+1;

            }

        }

        return -1;

    }

        int[] A = new int[9];

        int[] B = new int[9];

        int[] C = new int[9];

        A[0] = 0; B [0] = 0; C[0] = 0;

        A[1] = 1; B [1] = 1; C[1] = 1;

        A[2] = 1; B [2] = 1; C[2] = 0;

        A[3] = 2; B [3] = 1; C[3] = 0;

        A[4] = 3; B [4] = 2; C[4] = 0;

        A[5] = 2; B [5] = 2; C[5] = 1;

        A[6] = 1; B [6] = 3; C[6] = 1;

        A[7] = 0; B [7] = 1; C[7] = 0;

        A[8] = 0; B [8] = 0; C[8] = 1;

        System.out.println(burnout(9, A, B, C));

1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0

8

Alternatively,

    public static boolean burnWiresAtT(int N, int[] A, int[] B, int[] C, int t) {

        int[] h = new int[N*N];

        int[] v = new int[N*N];

        for (int i = 0; i < N*N; i++) { h[i] = 1; v[i] = 1; }

        for (int i = 0; i < N; i++) {

            h[(i * (N)) + N - 1] = 0;

            v[(N-1) * (N) + i] = 0;

        }

        System.out.println(printArray(h));

        System.out.println(printArray(v));

        for (int i = 0; i < t; i++) {

            if (C[i] == 0) {

                v[A[i] * (N-1) + B[i]] = 0;

            } else {

                h[A[i] * (N-1) + B[i]] = 0;

            }

        }

        return checkConnections(h, v, N);

    }

    public static int binarySearch(int N, int[] A, int[] B, int[] C, int start, int end) {

        if (start == end) {

            if (!burnWiresAtT(N, A, B, C, end)){

                return end;

            }

            return -1;

        } else {

            int mid = (start + end)/2;

            if (burnWiresAtT(N, A, B, C, mid)) {

                return binarySearch(N, A, B, C, mid + 1, end);

            } else {

                return binarySearch(N, A, B, C, start, mid);

            }

        }

    }

1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0

8

# another codingexercise: https://1drv.ms/w/c/d609fb70e39b65c8/Echlm-Nw-wkggNZtJwEAAAABshhrvJLSFN5M5D4gUrCASQ?e=dOCJd9

#another https://1drv.ms/w/c/d609fb70e39b65c8/Echlm-Nw-wkggNZWJwEAAAABSyuJZ0hy_QwL1EyPKtXITw?e=uY5xGy