From Gradient Descent to A*: Evolving the RJFVM into a Robust Navigation Algorithm
An incremental development journey captured in code, from theoretical optimization to practical pathfinding
Further to
to create a Jupyter notebook demonstrating the RJFVM as a path planning algorithm rather than simple gradient descent as before, it was discovered that simple gradient descent was insufficient for parameter optimisation, with Deepseek in a first content window following from before, then a second.
From Gradient Descent to A* Navigation: The Evolution of RJFVM into a Robust Navigation Algorithm
Introduction
In the world of autonomous navigation and path planning, the journey from theoretical optimization to practical algorithm implementation is often filled with interesting challenges and paradigm shifts. Today, I’d like to share the story of how our team evolved the Robust Joint Framework for Vehicle Management (RJFVM) from a gradient descent optimization problem into a full-fledged navigation algorithm using A* search - a transformation captured in our implementation notebook RJFVM_Astar.ipynb.
The Gradient Descent Beginnings
Initially, we approached RJFVM as a continuous optimization problem. The core idea was simple: define a cost landscape representing various navigation constraints and use gradient descent to find the optimal path by following the steepest descent toward a “sovereignty attractor” - our target state.
Our initial state space was defined by several parameters:
Color channel intensities (green, yellow, red, blue, alpha)
Mission score (m_score)
Total economic constraint (v_total)
Path cost (cost_so_far)
Heuristic estimate
The sovereignty attractor represented our ideal destination state:
text
S_E* = RJFState(green=0.95, yellow=0.9, red=0.95, blue=0.9, alpha=0.8, m_score=0.95, v_total=0.015625, cost_so_far=0.0, heuristic=0.0, parent=None)We implemented this using JAX for efficient mathematical operations, framing the navigation problem as minimizing a cost function that balanced multiple objectives while respecting parameter bounds (α ∈ (0.1, 1.0), M ∈ (0.5, 1.0)) and economic constraints (V_total ≤ 0.015625).
The Limitations of Gradient Descent
While elegant in theory, the gradient descent approach quickly revealed practical limitations:
Local Minima: Our terrain mapping identified 30 local minima that acted as traps where gradient descent would get stuck
Threat Zones: We identified 10 threat zones that required discrete avoidance rather than gradual navigation
False Peaks: The landscape contained 5 false peaks that misled the gradient-based approach
Discrete Constraints: Real-world navigation often involves discrete obstacles that don’t lend themselves to continuous optimization
The visualization of our terrain clearly showed these challenges - a complex landscape where the shortest gradient path wasn’t necessarily the most navigable or safe path.
The A* Navigation Breakthrough
Recognizing these limitations, we pivoted to a graph-based navigation approach using the A* algorithm. This required several conceptual shifts:
1. State Space Discretization
We transformed our continuous state space into discrete nodes connectable through valid transitions. Each node represented a navigable state with associated costs and constraints.
2. Graph Representation
Using NetworkX, we constructed a navigation graph where:
Nodes represent possible states
Edges represent valid transitions between states
Edge weights incorporate multiple cost factors (economic, mission score, etc.)
3. Heuristic Development
We developed an admissible heuristic that estimated the cost to reach the sovereignty attractor from any given state, combining:
Euclidean distance in the parameter space
Economic constraint penalties
Mission score considerations
4. Multi-Objective Cost Function
Our A* implementation considers:
text
f(n) = g(n) + h(n)Where:
g(n)= actual cost from start to node n (incorporating terrain difficulty, threats, etc.)h(n)= heuristic estimate from node n to goal
Implementation Architecture
The notebook reveals our incremental development process:
Phase 1: Foundation
We imported and configured essential libraries:
JAX for mathematical operations and gradient computations
NetworkX for graph construction and traversal
3D visualization tools for terrain mapping and path visualization
Phase 2: Parameter Definition
We established the navigation parameters and constraints, ensuring our algorithm respected both hard constraints (economic limits) and soft constraints (preferred parameter ranges).
Phase 3: Terrain Mapping
The system initialized with comprehensive terrain analysis:
30 local minima (traps to avoid)
10 threat zones (areas with high cost or danger)
5 false peaks (misleading optimal regions)
A terrain evaluation system for dynamic cost assessment
Phase 4: A* Implementation
We implemented A* with:
Priority queue for efficient node exploration
Cost functions that balance multiple objectives
Backtracking through parent pointers to reconstruct optimal paths
Visualization of the search process and final path
The Navigation Algorithm in Action
The RJF navigation algorithm proceeds through these steps:
Initialization: Start from the initial state with zero cost
Expansion: Explore neighboring states, calculating actual costs and heuristic estimates
Evaluation: Use
f(n) = g(n) + h(n)to prioritize node explorationConstraint Checking: Ensure all transitions respect economic and parameter constraints
Goal Testing: Check if the current state satisfies arrival conditions at the sovereignty attractor
Path Reconstruction: Once the goal is reached, backtrack through parent pointers to extract the optimal path
Visualization and Analysis
Our terrain visualization system provides crucial insights:
Color-coded elevation representing cost
Marked threat zones and false peaks
The computed optimal path avoiding pitfalls
Search frontier visualization showing A*’s exploration pattern
The visualization confirms that A* successfully navigates around local minima and threat zones that would have trapped the gradient descent approach, finding a truly optimal path rather than just a locally optimal one.
Comparative Advantages
The RJF navigation algorithm offers several advantages over the original gradient descent approach:
Global Optimality: A* guarantees finding the optimal path if the heuristic is admissible
Discrete Obstacle Handling: Naturally accommodates threats and no-go zones
Computational Efficiency: Explores the state space more intelligently than gradient descent
Transparency: The search process and final path are easily visualized and understood
Flexibility: Easily extended with additional constraints or heuristic improvements
Lessons Learned
This incremental development process taught us valuable lessons:
Problem Formulation Matters: Sometimes changing the problem representation (continuous→discrete) is more powerful than optimizing the solution method
Hybrid Approaches: We preserved gradient-based elements in our heuristic design, creating a best-of-both-worlds solution
Visualization is Crucial: Without terrain visualization, we might not have recognized the fundamental limitations of gradient descent
Incremental Development: Building from simple gradient descent to complex A* navigation allowed for continuous testing and validation
Future Directions
The RJF navigation algorithm opens several exciting possibilities:
Real-time Adaptation: Incorporating dynamic terrain changes
Multi-Agent Coordination: Extending to multiple nodes with coordinated path planning
Machine Learning Enhancement: Using learned heuristics for improved performance
Conclusion
The evolution from RJFVM as a gradient descent problem to RJF as a navigation algorithm demonstrates a fundamental truth in algorithm design: the right paradigm matters more than incremental optimization within the wrong paradigm. By shifting from continuous optimization to discrete graph search, we transformed a system that struggled with local minima into one that reliably finds globally optimal paths through complex terrains.
The RJFVM_Astar.ipynb notebook captures this journey - from mathematical formulation through terrain mapping to final A* implementation. It stands as a testament to the power of iterative development and paradigm shifts in solving complex navigation problems.
Whether you’re working on web3 consensus algorithms, autonomous vehicles, robotic path planning, or any optimization problem with discrete constraints, consider whether a graph-based approach might reveal paths that gradient-based methods cannot see. Sometimes, the optimal route forward requires stepping back and reconsidering the entire landscape of your problem.
The code and visualizations referenced in this post are available in the RJFVM_Astar.ipynb notebook, demonstrating the complete implementation from gradient descent foundations to A navigation algorithm.
Until next time, TTFN.



Great breakdown of the paradigm shift from continuous to discrete optimization. The recognition that gradient descent struggles with local minima and threat zones is something I ran into building indoor nav systems for warehouses. Back then, we tried hybrid approaches with simulated annealing first but eventually landed on similar graph-based solutions. One thing worth exploring is whether adaptve grid resolution could help bridge both worlds, where you use coarse A* for global planning but refine locally with gradient methods in obstacle-free zones?