Imagine a village with people trading goods. Each person has his own offer in this format: Giving amount a
of good b
for amount c
of good d
.
I have made a simple table to point out what I am trying to explain:
In this case there are three different goods: Wood, Sand and Gras.
I also live in the village and noticed that the prices of the traders vary greatly. I have 1 wood and want to increase it by simply trading between the five dealers. But: I must not visit a dealer more than once.
There would be different routes, for example I could do Dave - Adam
, which would result in +1 wood for me. A better route would be Earl - Berta - Adam
, because it would mean +2 wood.
I think at that point you might already know what I am asking for. I am looking for a technique / algorithm to find the route which maximizes my input. The rules are:
- Input good = Output good
- Output value > Input value
- Each node ("dealer") must not be visited more than once
- You do not have to visit all dealers
- Each dealer is limited to one trade ("Giving amount
a
of goodb
for amountc
of goodd
"). - $a\in\mathbb{R}_{>0}$ and $c\in\mathbb{R}_{>0}$
- The benefit is calculated at the end by output - input, i.e., by the increase in the quantity of the goods that you're starting with (if you start with 1 wood, then all that matters is the number of woods you end with).
- It is important that the input good is the same as the output good ("Input good = Output good"). If I start with wood, I need to end with wood. If I start with sand, I need to end with sand, etc.
I don't even know how such a problem is called. That means that anything like algorithm names to solve it, the general name for this kind of problem, etc. would help me to continue with my research. I have already tried approaching it by converting the table to a graph and then run path-finding algorithms. That did not work, because I wasn't sure how to weight the edges and the Longest-Path-Problem was also in my way, which is NP-Hard for non-DAGs.
The traveling salesman problem (TSP) was already mentioned. I had a look at the Wiki page of the TSP. Quote: "The travelling salesman problem (TSP) asks the following question: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?" I think my problem is very different, because:
- I look for the most profitable route, not the shortest.
- I don't have to visit every dealer ("city").
- I must not return to the origin, because as I said each node ("dealer") must not be visited more than once.
The "village" can get quite big. About 200 different goods and 500 dealers, so the algorithm should be able to perform good in this scenario.
The last possibility would be to brute-force, but I really want to avoid that.