Home › Forums › Urban Modeling and Simulation › attractivity map – alternatives to roulette wheel
- This topic has 8 replies, 2 voices, and was last updated 5 years, 7 months ago by
Martina Benetollo.
- AuthorPosts
- July 1, 2019 at 16:06 #9576
Martina Benetollo
ParticipantHello,
I’m looking for an alternative way to select slots to assign land uses to them, and I’d prefer if it looked at the nearest best placement, verify if it’s empty, and then assigned the land use to it. The main purpose of this would be to avoid getting empty areas between plots that have the same typology, but I don’t know what to replace the random roulette values with.
Thank you!
- July 1, 2019 at 17:00 #9578
Reinhard Koenig
KeymasterDear Martina,
for selecting the most attractive location (I assume that is meant with “nearest best placement”) you can use this code instead of the roulette wheel:
// — select the location with the highest attractivity —
double tempBest = 0;
for(int k = 0; k < AttractPop.Count; k++)
{
tempBest = AttractPop.Max();
slot = AttractPop.IndexOf(tempBest, 0);
}The peaks in the plot show that the selection prefers for a while only one location.
Best regards
Reinhard
- July 1, 2019 at 18:36 #9585
Martina Benetollo
ParticipantWhile with the roulette I had many colored units, now I only get the initial ones, as if the loop didn’t work. I’m working without a sumList so I’m using these conditions in the if loop to make sure that only one lad use is assigned to each unit, but I don’t know if that’s what is causing the problem now. I’m getting an error any time i try to add the land use to a unit
- July 1, 2019 at 20:34 #9586
Reinhard Koenig
KeymasterDear Martina,
jep, something is wrong in your script… but from your screenshot, I cannot figure out the reason for your issue. Can you please send the GH definition as a zip file?
Best regards
Reinhard
- July 1, 2019 at 17:10 #9579
Reinhard Koenig
KeymasterYou can get a similar result if you add some code to make attractive locations more attractive (how much more depends on the poser variable):
// — make attractive locations even more attractive —
for(int i = 0; i < newPop; i++)
{
double power = 6;
AttractPop[i] = Math.Pow((1+AttractPop[i]), power);
}That’s probably the more elegent version.
Best regards
Reinhard
- July 1, 2019 at 17:31 #9583
Reinhard Koenig
KeymasterSmall update, this should be used for making attractive locations more attractive:
// — make attractive locations even more attractive —
for(int i = 0; i < newPop; i++)
{
double power = 6;
if (AttractPop[i]>0)
AttractPop[i] = Math.Pow((1+AttractPop[i]), power);
}
- July 2, 2019 at 09:02 #9600
Reinhard Koenig
KeymasterDear Martina,
I looked into your definition. I’m not sure what your aim is. But if you assign new elements to the most attractive location, the algorithm will always choose the same location until something changed. In your case, you always select the same location and restrict the assignment of new functions by the max density setting. That’s why you cannot add new functions. This was avoided by the randomness of the roulette wheel in before.
To help you, you need to describe what you’d like to do and what the problem is in detail.
Best regards
Reinhard
- July 2, 2019 at 11:54 #9602
Martina Benetollo
Participantmy intention is to have a point on the map, and then the first residential unit of the settlement is near this point. From there, the other residential units find their best location (which should be around the existing residential unit since in the code I write that people want to live close to other people).
Just now I recomputed the gh definition and it worked, but as soon as i touched the c# code again, it stopped visualizing any result, even if I went back to the version of the code that was giving me outputs…
- July 2, 2019 at 09:09 #9601
Reinhard Koenig
KeymasterBy the way, using a lot of panels with large data output makes you definition very slow.
- AuthorPosts
- You must be logged in to reply to this topic.