Friday, August 15, 2025

 As a collective graph of drones based on distances as edges, there will be optimization problems for the tighter formation while maintaining minimum inter-drone distance. This can be done with the help of a cost function that helps to minimize the error between the current and the optimal position which is not a predesignated one but an iterative transition state that is determined by a steepest gradient descent. This method is illustrated as follows: 

#! /usr/bin/python 
''' 
Steepest gradient descent method: 
f(x) = 1/2 x-transpose A x - b-transpose x + c 
f'(x) = A x - b 
A = [ 3 2 ] b = [ 2 ] c = 0 
      [ 2 6 ]       [ -8 ] 
''' 
def steepest_gradient_descent(A, b, c, x, maxIteration, epsilon): 
i = 0 
residual = b - Ax # residual is what keeps it from being 0 
delta = scalar(transpose(residual, 2, 1), residual) # scalar is dot-product 
delta-0 = delta # initial delta 
while ((i < maxIteration) && (delta > (epsilon^2)*delta-0)): # epsilon is tolerance threshold 
    q = scalar (A, residual) 
    alpha = delta / scalar(transpose(residual, 2, 1), q) 
    x = x + scalar(alpha, residual) 
    if i % 50 == 0: # 50 is arbitrary, sqrt(n) for large n 
        residual = b - scalar(A, x) # recalculate residual to remove 
    else: # accumulated floating point error 
        residual = residual - scalar(alpha, q) 
    delta = scalar(transpose(residual, 2, 1), residual) 
    i = i + 1 
``` 
x = [ 2 ] 
      [ -2 ] 
``` 
def transpose(m, r, c): 
     r = [[0 for i in range(c)] for j in range(r)] 
     for i in range(c): 
         for j in range(r): 
              r [i][j] = m [j][i] 
     return r 

No comments:

Post a Comment