0

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:

Exchange apples for pears.

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:

  1. 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.
  2. 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.

Alex D.
  • 1
  • 1
  • 1
    There are only two goods, right? Hint: think greedily, given you can only use a trader at most once, should use start with the best traders or leave those for the end? – Bernardo Subercaseaux Sep 08 '23 at 16:26
  • https://cs.stackexchange.com/q/59964/755 – D.W. Sep 08 '23 at 19:06
  • @BernardoSubercaseaux thank you very much for your reply. I believe the greedy algorithm is the only viable option for my problem. However, I am currently unsure how it would handle situations where the best trade at a given node does not result in the overall best path. (I have included a "pineapple" to the picture to illustrate such case). – Alex D. Sep 13 '23 at 09:40

0 Answers0