Hey,
This might sound a bit odd, but I'm working on a simulation of sorts and having a slight mental block.
This would probably be best described if I used a real life sort of example (note, this is not a school assignment or similar).
Imagine you have 100 of some currency (I'll use dollars).
You walk into a room that has a random number of people in it, all in random locations.
Your objective is to pass out all your money, making sure everyone gets some of it.
The catch is, you are to give more money to people that are closer to you (not just more, but proportional).
So as an example, if there are 2 people in the room, and you know 1 is 5 feet from you and the other is 10 feet from you, the one 5 feet from you should get double the amount you give to the other person. In this case, you'd give the nearest guy 66.66 dollars and the other guy 33.33.
What would be the appropriate method to distribute the money when you do not know the number of people, but you do know how far each one is from you?
I hope that makes some sort of sense. Thanks for any and all help.
Edit:
Nevermind. I think I've got it. My only issue now is that the farther the 'people' are away, the less the distance impacts how much they would receive (that's trivial though).
Weights by proximity
If you want to distribute the money inverse proportional to the distance, then assign the weight w[sub]n[/sub] = 1/distance to person number n. Then, normalize the weights so they add up to unity: w'[sub]n[/sub] = w[sub]n[/sub]/sum(w[sub]n[/sub]). Now you just distribute the money as 100 dollars * w'[sub]n[/sub] to person n.
The method works for any weighing, just change the 1/distance to whatever weighting function you want.
The method works for any weighing, just change the 1/distance to whatever weighting function you want.
Ding. What he said. The kicker, of course, is that you have to know how many people there are and their respective distances before you can run the calculation.
Now if you REALLY want to have fun, distribute people around the room so that the path that you choose to take from one to the next affects the distance. You aren't measuring the distance from your starting place to each person, you are measuring the distances from each person to the next. Doable, but it just takes some iteration.
Now if you REALLY want to stab yourself in the eyes, use the Traveling Salesman problem to determine which is the most efficient path through the n people in the room.
Now if you REALLY want to have fun, distribute people around the room so that the path that you choose to take from one to the next affects the distance. You aren't measuring the distance from your starting place to each person, you are measuring the distances from each person to the next. Doable, but it just takes some iteration.
Now if you REALLY want to stab yourself in the eyes, use the Traveling Salesman problem to determine which is the most efficient path through the n people in the room.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement