hyper graph algorithm for finding best complexity

I want to find a reference for this problem or a same problem for my paper. I find a greedy algorithm for this problem but writing such algorithm in my paper is not common and finding a reference is the best solution.

We have a connected hyper-graph. We want to choose a list of hyper-edges respectively with following property. if you add these hyper-edges to the empty hyper-graph one by one, in each step the number of connected components become lower. At first we have 𝑛 component and at the end of these steps we have 1 component. suppose that in $𝑖−𝑡ℎ$ step the number of components is reduced by 𝑎𝑖 number. if we have $𝑡+1$ steps we want to minimize $𝑚𝑎𝑥(𝑎_1,𝑎_2,…,𝑎_𝑡)$.

I have an algorithm that complexity of each step is $𝑂(𝑛^{𝑎_𝑖})$ and I solve this solution for minimizing the complexity of my algorithm but I glad to find a reference for this problem.

What’s the name of this sorting(?) algorithm?

Given the options of:

  • Red
  • Orange
  • Yellow
  • Green
  • Blue
  • Violet

You want to find your favorite color by comparing all pairs to each other, like so:
Red vs…

  • Red vs Orange = Orange
  • Red vs Yellow = Red
  • Red vs Green = Red
  • Red vs Blue = Red
  • Red vs Violet = Red

Orange vs…

  • Orange vs Yellow = Orange
  • Orange vs Green = Orange
  • Orange vs Blue = Orange
  • Orange vs Violet = Orange

Yellow vs…

  • Yellow vs Green = Green
  • Yellow vs Blue = Yellow
  • Yellow vs Violet = Yellow

Green vs…

  • Green vs Blue = Green
  • Green vs Violet = Green

Blue vs…

  • Blue vs Violet = Violet

In the end you’ll find your "most preferred". Not sure if you get a full order of preference.

What’s the name of this…thing?

Is there a library or algorithm I can use to solve this type of problem efficiently in C# (.NET Core 3.0)?

I’m having trouble defining this problem space (example below), where to look, what to search etc. and would appreciate any help with suggestions of algorithms or libraries that I should look into. I’ve spent some time looking into constraint programming & OR-Tools but most problems seem to be scalar and I haven’t yet been able to figure out how to use any of the solutions effectively to solve my problem. My project is in C# (.NET Core 3.0)

EXAMPLE:

Say I have 3 objects (o) that each have associated attributes (a):

//object 1 has attributes 1, 2, and 3
o1 { a1, a2, a3 }
//object 2 has attributes 1 and 3
o2 { a1, a3 }
//object 3 has attributes 2 and 3
o3 { a2, a3 }

Then say that a person is able to select certain attributes they are interested in, specifically in this example the person is interested in:

//the person wants to see objects or groups/sets of objects that have attributes 1 and 2
a1 and a2

The goal then would be to return to the person set(s) of the objects that best contain the selected attributes with the least number of objects needed. In this case the desired return result would be:

//object 1 is the best solution because it contains attributes 1 and 2 by itself
1. o1 
//object's 2 and 3 together is the 2nd best solution because they contain attributes 1 and 2 between themselves
2. o2 and o3

This is a very simple example but the actual scale of the objects and attributes associated to those objects will require something much more efficient than brute force. Thanks in advance!

approximation – Best algorithm / method to determine path length from noisy GPS points

i am analyzing a series of GPS points (with time stamps) which are noisy meaning have an accuracy of about 15 meter radius (sometime even more), and i need to extrapolate the distance the vehicle has gone via those GPS points, what is a good algorithm / method to solve such issues ?

What algorithm to use for automatic scheduling of field workers?

Imagine a large field worker company that employs a few thousand field workers (workers who must travel to different locations to complete unique work orders). Their field workers have many skills (photography, journalist, etc.). A work order is a unique “job” that the field worker must complete at a specific time and location. I’m wondering which algorithms that I can explore to solve this problem.

There are several requirements/constraints:

  • Each work order requires several criteria: 1. specific skill 2. some have specific date/time, some have preferred date/time 2. specific location 4. Varying time durations (some jobs require 1 hour, some require 2 hours, etc) 5. Varying urgency levels (high, medium, low) 6. some work orders require more than 1 field worker
  • Each field worker has several constraints: 1. schedule availability 2. trained skill(s) 3. location preferences (work close to their home?)

Issues:

  • There may be more work orders than available field workers (need to schedule priority orders first, and remaining lower priority items will be scheduled to the next available day)

  • Sometimes work orders that are manually assigned to a specific field worker (someone requested a specific field worker for a specific job)

  • Some work orders can not be completed within the time slot allocated, and the same field worker must come back at the next availability to complete the work order

  • Optimization Problem:

  1. Want to fill up the schedule of a field worker (don’t want long unnecessary gaps between jobs)
  2. Want to cluster the orders by location so that the worker does minimal traveling (wasting time)

Would be great to get some recommendations on algorithms to explore to solve this problem. I’ve looked at some of the other automatic scheduling algorithms but the main factor that is missing in those algorithms is the traveling part. Any help would be greatly appreciated!!

Algorithm for line breaking in monospace text

Is there a de facto standard algorithm for finding good places to put line breaks in a paragraph of text rendered in a monospace font (e.g. to a text console)?

The algorithm should aim to output lines of an equal length (which is given as an argument), inserting a variable number of spaces between each pair of adjacent words on the same line to produce a pleasing result.

The TeX algorithm (Breaking Paragraphs into Lines, Knuth & Plass 1981) is the go-to algorithm for fancy typesetting with variable-width fonts. It should be usable with fixed-width fonts by treating them like variable-width fonts, but is there a simpler algorithm tailor-made for monospace fonts?

What is the SetHorspool string searching algorithm?

What is the SetHorspool string searching algorithm with pseudo-code so it can be easily implemented in a language of choice?

This has been implemented in 2 libraries I have come across:

  • https://app-db.com/seqan/1.3/SPEC_Set_Horspool.html,
  • http://stringsearchalgorithms.amygdalum.net/.

But there seem to be very little details of the algorithm available online to understand its working.

beginner – Sorting and Searching Algorithm

The searching algorithm that I created is dependent upon the sorting algorithm (which many of you have seen in my previous question). I believe that the sorting algorithm can’t be better (for beginner-level programmers like me) but I would like to know what you think about my descriptions for the searching algorithm. I would appreciate your insight on the commented sections of my code (again, for the searching algorithm). I will provide the entire code (sorting + searching algorithm) so you can get the entire picture. And if there are any other changes I can make, please don’t hesitate to let me know.

def sorting_algorithm(list):
    for index in range(1, len(list)):
        current = list(index)
        while index > 0 and list(index - 1) > current:
            list(index) = list(index - 1)
            index = index - 1
            list(index) = current
    return list


print("the sorted list is", (sorting_algorithm((45, 14, 1, 7, 98, 23, 102, 57))))

#SEARCHING ALGORITHM CODE:

def searching_algorithm(list, num):
    fir = 0                                        #the first number of the list.
    las = len(list)-1                              #the last number of the list.
    i = -1                                         #the index is at the last number of the list.
    while (fir <= las) and (i == -1):              #the first number is less than or equals to the last number and the
                                                   #index is at -1 (so the last number).
        mid = (fir + las) // 2                     #the middle number is equal to the first num divided by the last number
                                                   #but without the remainder part.
        if list(mid) == num:                       #if the middle number of the list equals the number
            i = mid                                #then the index is moved to the middle number of the list.
        else:                                      #if that isn't true then we move on to the following condition.
            if num<list(mid):                      #if the number is less than the middle number of the list
                las = mid -1                       #then the index moves one to the right.
            else:                                  #if that isn't true either, then move on to the following condition.
                fir = mid +1                       #then the program will conclude that the number is the greater than
                                                   #the middle number.
    return i

print("your number is at index",searching_algorithm((1, 7, 14, 23, 45, 57, 98, 102), 23))

What Is The Latest Seo Algorithm Update From Google..?

 

c++ – Pathfinding algorithm isn’t finding correct route

I am attempting an online coding challenge wherein I am to implement a pathfinding algorithm that finds the shortest path between two points on a 2D grid. The code that is submitted is tested against a number of test cases that I, unfortunately, am unable to see, but it will however tell me if my answer for shortest distance is correct or not. My implementation of the A* algorithm returns a correct answer on 2/3 test cases and I cannot seem to figure out what scenario might create an incorrect answer on the third?

I have tried several of my own test cases and have gotten correct answers for all of those and at this point am feeling a little bit lost. There must be something small in my code that I am not seeing that is causing this third case to fail.

More details

  • The grid is w by h and contains only 1’s (passable) and 0’s (impassable) with every edge having a cost of 1 and the pathway cannot move diagonally
    It all starts with the FindPath function which is to return the length of the shortest path, or -1 if no path is available
  • pOutBuffer is used to contain the path taken from beginning to end (excluding the starting point). If multiple paths are available then any will be accepted. So it isnt looking for one path in particular
  • I know the issue is not the result of time or memory inefficiency. I has to be either the distance returned is incorrect, or the values in pOutBuffer are incorrect.

Any help would be greatly appreciated as I am just about out of ideas as to what could possibly be wrong here. Thank you.

#include <set>
#include <vector>
#include <tuple>
#include <queue>
#include <unordered_map>

inline int PositionToIndex(const int x, const int y, const int w, const int h)
{
    return x >= 0 && y >= 0 && x < w  && y < h? x + y * w : -1;
}

inline std::pair<int, int> IndexToPosition(const int i, const int w)
{
    return std::make_pair<int, int>(i % w, i / w);
}

inline int Heuristic(const int xa, const int ya, const int xb, const int yb)
{
    return std::abs(xa - xb) + std::abs(ya - yb);
}

class Map
{
public:
    const unsigned char* mapData;
    int width, height;

    const std::vector<std::pair<int, int>> directions = { {1,0}, {0,1}, {-1,0}, {0,-1} };

    Map(const unsigned char* pMap, const int nMapWidth, const int nMapHeight)
    {
        mapData = pMap;
        width = nMapWidth;
        height = nMapHeight;
    }

    inline bool IsWithinBounds(const int x, const int y) 
    {
        return x >= 0 && y >= 0 && x < width && y < height;
    }

    inline bool IsPassable(const int i)
    {
        return mapData(i) == char(1);
    }


    std::vector<int> GetNeighbours(const int i)
    {
        std::vector<int> ret;

        int x, y, neighbourIndex;
        std::tie(x, y) = IndexToPosition(i, width);

        for (auto pair : directions)
        {
            neighbourIndex = PositionToIndex(x + pair.first, y + pair.second, width, height);
            if (neighbourIndex >= 0 && IsWithinBounds(x + pair.first, y + pair.second) && IsPassable(neighbourIndex))
                ret.push_back(neighbourIndex);
        }

        return ret;
    }
};

int FindPath(const int nStartX, const int nStartY,
    const int nTargetX, const int nTargetY,
    const unsigned char* pMap, const int nMapWidth, const int nMapHeight,
    int* pOutBuffer, const int nOutBufferSize)
{
    int ret = -1;

    // create the map
    Map map(pMap, nMapWidth, nMapHeight);

    // get start and end indecies
    int targetIndex = PositionToIndex(nTargetX, nTargetY, nMapWidth, nMapHeight);
    int startIndex = PositionToIndex(nStartX, nStartY, nMapWidth, nMapHeight);
    
    // if start and end are same exit
    if (targetIndex == startIndex) return 0;
    
    std::unordered_map<int, int> pathway = { {startIndex, startIndex} };
    std::unordered_map<int, int> distances = { {startIndex, 0} };

    // queue for indecies to process
    typedef std::pair<int, int> WeightedLocation;
    std::priority_queue<WeightedLocation, std::vector<WeightedLocation>, std::greater<WeightedLocation>> queue;

    queue.emplace(0, startIndex);
    
    while (!queue.empty())
    {
        int currentWeight, currentIndex;
        std::tie(currentWeight, currentIndex) = queue.top();
        queue.pop();

        if (currentIndex == targetIndex)
            break;

        int newDistance = distances(currentIndex) + 1;
        for (int n : map.GetNeighbours(currentIndex))
        {
            if (distances.find(n) == distances.end() || newDistance < distances(n))
            {
                distances(n) = newDistance;

                int weight = newDistance + Heuristic(n % nMapWidth, n / nMapWidth, nTargetX, nTargetY);
                queue.emplace(weight, n);
                pathway(n) = currentIndex;
            }
        }
    }

    if (pathway.find(targetIndex) != pathway.end())
    {
        int current = targetIndex;

        while (current != startIndex)
        {
            int outIndex = distances(current) - 1;
            pOutBuffer(distances(current) - 1) = current;
            current = pathway(current);
        }
        ret = distances(targetIndex);
    }
    
    return ret;
}