I am trying to solve the following problem:
Suppose there are traders who can exchange one good for another. Each trader $i$ defines two functions $y = f_{i1}(x)$ and $x = f_{i2}(y)$, with which we can determine how much of $y$ or $x$ we can receive after exchanging with this trader. For example, trader 1 can exchange apples for lemons with the formula:
$$numberOfLemons = 5 * numberOfApples$$
and vice versa:
$$numberOfApples = 0.2 * numberOfLemons$$
Suppose I have some amount of good A, and I want to receive the most possible amount of good B with my current amount. For example, I want to receive the most amount of pears for my 10 apples.
See the picture:
In the picture, the most amount of pears that I could receive for 10 apples is equal to 400 pears.
Could you help me with the following questions:
- What is the correct name of the described problem? I think the problem is related to the longest path problem, but I am not sure since the costs in the graph depend on the previous values.
- What algorithm could be used to solve such a problem? I think it's possible to use the Bellman-Ford algorithm here, but I am not sure.
I found a similar question, but in my case, I am trying to exchange some good A for another good B.
Therefore, the rules in my case are as follows:
- A != B.
- The amount of B should be the maximum possible.
- Each trader couldn't be visited more than once.
- You do not have to visit all the traders.
- Each trader is limited to one trade.
- The output amount on each trade is defined by functions $f_{i1}(x)$ and $f_{i2}(y)$.
- $x, y ∈ ℝ_{>=0}$.
- The amount of B should be the maximum possible with the given set of traders.
The actual data I am working with could consist of hundreds of thousands of traders and goods.