Jump to content


Trying to figure out the name or algorythm for a system


4 replies to this topic

#1 Saigumi

    New Member

  • Members
  • Pip
  • 2 posts

Posted 06 December 2006 - 04:48 PM

Ok, I'm working on a bit of freeware and am trying to optimize a system of performing trades.

The basic system is that there are a lot group of nodes, say 20 to 200 of items for trade. Each node then has a weighted line to a bunch of other nodes. This basically represents the item for trade and then the order of desire of what that wants to be traded for. The trades also need to wrap themselves into the most inclusive loop or multiple loops.

I've been doing it sort of like A* at the moment. But it's not really meeting the right need and seems wonky. Basically, I want to be able to select one of two outcomes. One being the highest weight with the most people and the other would include the most people while trying to stay with the highest weight.

Does anyone know the name of what this type of algorythm is? I've been trying to find some more guidance on making this, but am having the roughest time.

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5344 posts
  • LocationSanta Clara, CA

Posted 06 December 2006 - 04:53 PM

I'm not quite clear on what you want the algorithm to produce. You've got a graph with vertices representing commodities and edges representing exchange rates (prices)? Or are the edges something else? And you're looking for what - a highest weight path? A heighest weight cycle?
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 Jare

    Valued Member

  • Members
  • PipPipPip
  • 247 posts

Posted 16 December 2006 - 01:12 AM

Let me try another interpretation:

- You have a number of nodes, for example planets.
- Each node has a number of items.
- Each node has some connections to other nodes.
- A connection represents a specific possible trade that can be performed.
- Each connection includes which items will be given and which items will be received, as well as an overall value of the connection.
- For the sake of simplicity, I'll assume that a node can't have more than one connection with any other given node.
- A node can't perform all the possible trades it has with other nodes, because the resources being traded are limited.

You want to find, for a given node, some sets of trades that can be performed at once, with two criteria:
- Which set of trades represents the highest total value?
- Which set of trades includes the largest amount of different trades, and if there's more than one set, which among them represents the highest total value?

Is that what you want? I can't even remotely guess what "The trades also need to wrap themselves into the most inclusive loop or multiple loops" might mean.

If you can't bruteforce this and can live with an approximation, "Greedy algorithms" are usually a good starting point for this kind of problems. Google or wikipedia the term.

#4 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 16 December 2006 - 01:32 AM

Genetic algorithms (GA) may also be appropriate, although GA rarely gives an optimal solution

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 5344 posts
  • LocationSanta Clara, CA

Posted 16 December 2006 - 04:26 AM

It sounds sort of like a max flow problem although I'm not quite sure how you would characterize it as such. If you could state it as a flow problem though there are plenty well known and pretty fast algorithms for solving it.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users