Tuesday, July 9, 2024

 These are more use cases targeted for a commercial drone fleet management software that scales elastically and helps drones manage their flight path in real-time.

Case 3. Many businesses outsource their fleet with a fleet provider that maintains a large inventory of hybrid models that are continually updated in their degrees of motion, capabilities and inputs. These businesses expect to have one interface with the fleet provider and another with the fleet management service such that they can choose to organize their fleet dynamically and pass the fleet details to their management service for commands that they can relay to their fleet members. They expect a detailed and comprehensive management dashboard or portal where they can monitor the key performance indicators aka KPI  for the fleet and drill down. They expect these programmability interfaces to be compatible in a way that requires little or no processing other than relaying the commands or updating the goals on the management dashboard.

Case 4: As drone manufacturers make incredible progress in the scope and purpose of drone activities, they would like to outsource software targeting repeated drills across models and versions of their drones including abilities to plugin customizations for enhanced intelligence. These drone manufacturers are experimenting with a variety of shapes, compositions and degrees of freedom both individually and collectively for formations and their ability to overcome obstacles. A cloud software that can be reached ubiquitously by drones themselves or relayers will be cost-effective in maximizing the output of these drones. Among the features expected by the manufacturers are ability to repeat tests, maintain test history,  and generate test reports. A single transparent pane of glass for observability and manageability of the drones along with these reports and dashboards will be very helpful to them for updating their drones.  Initially the size of the fleets for most of these manufactures might be small in research and development but their deployments on their customer premises could be large and require dial-home capabilities from the units or their controllers and relayers. Different kinds of topology involving different types of units participating in overall fleet management and formations must be supported by this software.


Monday, July 8, 2024

 These are the use cases targeted for a commercial drone fleet management software that scales elastically and helps drones manage their flight path in real-time.

Case 1. A retail company owns and operates a fleet of drones with proprietary software to deliver merchandise purchased by its customers to their residences. The software tracks each drone individually providing route and schedule information independent of others. The number of drones exceeds hundreds of thousands. The software is tasked with the dual goal of assigning non-overlapping,  contention free and flow maximizing  flight manifests for each drone as well as keeping the costs low for the operation of a single drone deployed to serve a customer. Controllers for the drones are placed in multiple cities worldwide and operate their own fleet independent of others and cover a specific non-overlapping geographic region. The software differentiates from the one used to mange the fleet of robots in its warehouse in that the space to operate is not a grid but a hub-and-spoke model and the destinations are not internally managed but received from order processing service bearing address, volume, weight and delivery date information in a streaming manner. The software does not differentiate between fleet members and requires the ability to form the fleet dynamically by replacing , adding or removing members. When this proprietary software becomes general purpose use for fleets of varying sizes, operating loads, and quality of service, it becomes promising as a multitenant platform so that different companies do not need to reinvent the wheel. This platform must keep the use of cloud resources as efficient as possible to pass on the savings to businesses and streamline consumption of additional resources when any single parameter is stretched. Additionally, it must provide offloading of any interface of its components for customization by these businesses. For example, they can determine their own scheduling plug-in and are not bound to supplying values to predetermined scheduling templates. Volume and rate of drone command updates must cover the six sigma of normalizes  probability distribution of current and foreseeable future fleet sizes.

Case 2. A small and medium sized business is looking to improve the efficiency of  scheduling for its fleet and wants to download models that it can operate on its own premises or invoke remotely from APIs. This controller-offload-to-the cloud scenario demands world class performance and availability at affordable price. This business does not expect to grow its fleet or experience a lot of churns in its fleet but appreciates full service outsourcing of its fleet management so that it merely controls the inventory and the commands to the fleet members. It also expects to include a clause for liability of drone damages resulting from faulty instructions. It might want to change scheduling algorithms depending on changing business priorities that are not fully covered by the scheduling parameters.

Case 3. Many businesses outsource their fleet with a fleet provider that maintains a large inventory of hybrid models that are continually updated in their degrees of motion, capabilities and inputs. These businesses expect to have one interface with the fleet provider and another with the fleet management service such that they can choose to organize their fleet dynamically and pass the fleet details to their management service for commands that they can relay to their fleet members. They expect a detailed and comprehensive management dashboard or portal where they can monitor the key performance indicators aka KPI  for the fleet and drill down. They expect these programmability interfaces to be compatible in a way that requires little or no processing other than relaying the commands or updating the goals on the management dashboard.

References: https://1drv.ms/w/s!Ashlm-Nw-wnWhPA9saJLYQGA7q2Wiw?e=AONTxo for data architecture 

https://1drv.ms/w/s!Ashlm-Nw-wnWhO4OGADjCj0GVLyFTA?e=UGMEpB for software description.



Sunday, July 7, 2024

 A self organizing map algorithm for scheduling meeting times as availabilities and bookings.  A map is a low-dimensional representation of a training sample comprising of elements e. It is represented by nodes n. The map is transformed by a  regression operation to modify the nodes position one element from the model (e) at a time. With preferences translating to nodes and availabilities as elements, this allows the map to start getting a closer match to the sample space with each epoch/iteration.

from sys import argv


import numpy as np


from io_helper import read_xyz, normalize

from neuron import generate_network, get_neighborhood, get_boundary

from distance import select_closest, euclidean_distance, boundary_distance

from plot import plot_network, plot_boundary


def main():

    if len(argv) != 2:

        print("Correct use: python src/main.py <filename>.xyz")

        return -1


    problem = read_xyz(argv[1])


    boundary = som(problem, 100000)


    problem = problem.reindex(boundary)


    distance = boundary_distance(problem)


    print('Boundary found of length {}'.format(distance))



def som(problem, iterations, learning_rate=0.8):

    """Solve the xyz using a Self-Organizing Map."""


    # Obtain the normalized set of timeslots (w/ coord in [0,1])

    timeslots = problem.copy()

    # print(timeslots)

    #timeslots[['X', 'Y', 'Z']] = normalize(timeslots[['X', 'Y', 'Z']])


    # The population size is 8 times the number of timeslots

    n = timeslots.shape[0] * 8


    # Generate an adequate network of neurons:

    network = generate_network(n)

    print('Network of {} neurons created. Starting the iterations:'.format(n))


    for i in range(iterations):

        if not i % 100:

            print('\t> Iteration {}/{}'.format(i, iterations), end="\r")

        # Choose a random timeslot

        timeslot = timeslots.sample(1)[['X', 'Y', 'Z']].values

        winner_idx = select_closest(network, timeslot)

        # Generate a filter that applies changes to the winner's gaussian

        gaussian = get_neighborhood(winner_idx, n//10, network.shape[0])

        # Update the network's weights (closer to the timeslot)

        network += gaussian[:,np.newaxis] * learning_rate * (timeslot - network)

        # Decay the variables

        learning_rate = learning_rate * 0.99997

        n = n * 0.9997


        # Check for plotting interval

        if not i % 1000:

            plot_network(timeslots, network, name='diagrams/{:05d}.png'.format(i))


        # Check if any parameter has completely decayed.

        if n < 1:

            print('Radius has completely decayed, finishing execution',

            'at {} iterations'.format(i))

            break

        if learning_rate < 0.001:

            print('Learning rate has completely decayed, finishing execution',

            'at {} iterations'.format(i))

            break

    else:

        print('Completed {} iterations.'.format(iterations))


    # plot_network(timeslots, network, name='diagrams/final.png')


    boundary = get_boundary(timeslots, network)

    plot_boundary(timeslots, boundary, 'diagrams/boundary.png')

    return boundary


if __name__ == '__main__':

    main()


Reference: 

https://github.com/raja0034/som4drones


DroneCommercialSoftware.docx


Saturday, July 6, 2024

 Problem Statement: A 0-indexed integer array nums is given.

Swaps of adjacent elements are able to be performed on nums.

A valid array meets the following conditions:

The largest element (any of the largest elements if there are multiple) is at the rightmost position in the array.

The smallest element (any of the smallest elements if there are multiple) is at the leftmost position in the array.

Return the minimum swaps required to make nums a valid array.

 

Example 1:

Input: nums = [3,4,5,5,3,1]

Output: 6

Explanation: Perform the following swaps:

- Swap 1: Swap the 3rd and 4th elements, nums is then [3,4,5,3,5,1].

- Swap 2: Swap the 4th and 5th elements, nums is then [3,4,5,3,1,5].

- Swap 3: Swap the 3rd and 4th elements, nums is then [3,4,5,1,3,5].

- Swap 4: Swap the 2nd and 3rd elements, nums is then [3,4,1,5,3,5].

- Swap 5: Swap the 1st and 2nd elements, nums is then [3,1,4,5,3,5].

- Swap 6: Swap the 0th and 1st elements, nums is then [1,3,4,5,3,5].

It can be shown that 6 swaps is the minimum swaps required to make a valid array.

Example 2:

Input: nums = [9]

Output: 0

Explanation: The array is already valid, so we return 0.

 

Constraints:

1 <= nums.length <= 105

1 <= nums[i] <= 105

Solution: 

class Solution {

    public int minimumSwaps(int[] nums) {

        int min = Arrays.stream(nums).min().getAsInt();

        int max = Arrays.stream(nums).max().getAsInt();

        int count = 0;

        while (nums[0] != min && nums[nums.length-1] != max && count < 2 * nums.length) {            

            var numsList = Arrays.stream(nums).boxed().collect(Collectors.toList());

            var end = numsList.lastIndexOf(max);

            for (int i = end; i < nums.length-1; i++) {

                swap(nums, i, i+1);

                count++;

            }

 

            numsList = Arrays.stream(nums).boxed().collect(Collectors.toList());

            var start = numsList.indexOf(min);

            for (int j = start; j >= 1; j--) {

                swap(nums, j, j-1);

                count++;

            }

        }

 

        return count;

    }

 

    public void swap (int[] nums, int i, int j) {

        int temp = nums[j];

        nums[j] = nums[i];

        nums[i] = temp;

    }

}


Input

nums =

[3,4,5,5,3,1]

Output

6

Expected

6


Input

nums =

[9]

Output

0

Expected

0


Friday, July 5, 2024

 Find minimum in a rotated sorted array:

class Solution {

    public int findMin(int[] A) {

        If (A == null || A.length == 0) { return Integer.MIN_VALUE; }

        int start = 0;

        int end = A.length -1;

        while (start < end) {

            int mid = (start + end) / 2;


            // check monotonically increasing series

            if (A[start] <= A[end] && A[start] <= A[mid] && A[mid] <= A[end]]) { return A[start];};


            // check if only [start, end]

            if (mid == start || mid == end) { if (A[start] < A[end]) return A[start]; else return A[end];}


            // detect rotation point 

            if (A[start] > A[mid]){

                end = mid;

            } else {

                if (A[mid] > A[mid+1]) return A[mid+1]; 

                start = mid + 1;

            }

        }

        return A[0];

    }   

}

Works for:

[0 1 4 4 5 6 7]

[7 0 1 4 4 5 6]

[6 7 0 1 4 4 5]

[5 6 7 0 1 4 4]

[4 5 6 7 0 1 4]

[4 4 5 6 7 0 1]

[1 4 4 5 6 7 0]

[1 0 0 0 0 0 1]



Thursday, July 4, 2024

One of the convenient automations uses a well-known algorithm.

String matching algorithms: 


Void PrintMatch(String text, string pattern) 



Regex r = new Regex(pattern, options); 


Int[] gnums = r.GetGroupNumber(); 


Match m = r.Match(text); 


While (m.Success) 



Group g = m.Groups[gnums[i]]; 


CaptureCollection cc = g.Captures; 


For (int j = 0; j < cc.Count; j++) 



capture c = cc[j]; 


Console.WriteLine(“\t\tCapture{0} = [{1}] Index={2} and Length={3}”, j, c,c.Index, c.Length); 



m = m.NextMatch(); 



}


Wednesday, July 3, 2024

 A self organizing map algorithm for scheduling meeting times as availabilities and bookings.  A map is a low-dimensional representation of a training sample comprising of elements e. It is represented by nodes n. The map is transformed by a  regression operation to modify the nodes position one element from the model (e) at a time. With preferences translating to nodes and availabilities as elements, this allows the map to start getting a closer match to the sample space with each epoch/iteration.

from sys import argv


import numpy as np


from io_helper import read_xyz, normalize

from neuron import generate_network, get_neighborhood, get_boundary

from distance import select_closest, euclidean_distance, boundary_distance

from plot import plot_network, plot_boundary


def main():

    if len(argv) != 2:

        print("Correct use: python src/main.py <filename>.xyz")

        return -1


    problem = read_xyz(argv[1])


    boundary = som(problem, 100000)


    problem = problem.reindex(boundary)


    distance = boundary_distance(problem)


    print('Boundary found of length {}'.format(distance))



def som(problem, iterations, learning_rate=0.8):

    """Solve the xyz using a Self-Organizing Map."""


    # Obtain the normalized set of timeslots (w/ coord in [0,1])

    timeslots = problem.copy()

    # print(timeslots)

    #timeslots[['X', 'Y', 'Z']] = normalize(timeslots[['X', 'Y', 'Z']])


    # The population size is 8 times the number of timeslots

    n = timeslots.shape[0] * 8


    # Generate an adequate network of neurons:

    network = generate_network(n)

    print('Network of {} neurons created. Starting the iterations:'.format(n))


    for i in range(iterations):

        if not i % 100:

            print('\t> Iteration {}/{}'.format(i, iterations), end="\r")

        # Choose a random timeslot

        timeslot = timeslots.sample(1)[['X', 'Y', 'Z']].values

        winner_idx = select_closest(network, timeslot)

        # Generate a filter that applies changes to the winner's gaussian

        gaussian = get_neighborhood(winner_idx, n//10, network.shape[0])

        # Update the network's weights (closer to the timeslot)

        network += gaussian[:,np.newaxis] * learning_rate * (timeslot - network)

        # Decay the variables

        learning_rate = learning_rate * 0.99997

        n = n * 0.9997


        # Check for plotting interval

        if not i % 1000:

            plot_network(timeslots, network, name='diagrams/{:05d}.png'.format(i))


        # Check if any parameter has completely decayed.

        if n < 1:

            print('Radius has completely decayed, finishing execution',

            'at {} iterations'.format(i))

            break

        if learning_rate < 0.001:

            print('Learning rate has completely decayed, finishing execution',

            'at {} iterations'.format(i))

            break

    else:

        print('Completed {} iterations.'.format(iterations))


    # plot_network(timeslots, network, name='diagrams/final.png')


    boundary = get_boundary(timeslots, network)

    plot_boundary(timeslots, boundary, 'diagrams/boundary.png')

    return boundary


if __name__ == '__main__':

    main()