djgroen / flee

flee agent-based modelling code
BSD 3-Clause "New" or "Revised" License
8 stars 7 forks source link

Error with population of conflict_zones #28

Closed mrichey17 closed 3 years ago

mrichey17 commented 3 years ago

I am using Python 3.7.2 in PyCharm and applying the code to Turkey. Screenshots of my input files and error are attached.

The tutorial says to run the code using this command: python3 <country_name>.py <simulation_period> > out<country_name>/out.csv

But I can only get the code to run specifying the system arguments using this command: python3 Turkey.py Turkey/input_csv Turkey/source_data 10 2019-01-31 outTurkey/output.csv

I am getting this error:

Traceback (most recent call last): File "C:/Users/mrich/Downloads/FLEE/Turkey.py", line 92, in <module> e.add_agents_to_conflict_zones(new_refs) File "C:\Users\mrich\Downloads\FLEE\flee\flee.py", line 845, in add_agents_to_conflict_zones cl = self.pick_conflict_locations(number) File "C:\Users\mrich\Downloads\FLEE\flee\flee.py", line 839, in pick_conflict_locations return np.random.choice(self.conflict_zones, number, p=self.conflict_weights / self.conflict_pop) File "mtrand.pyx", line 1125, in mtrand.RandomState.choice ValueError: 'a' cannot be empty unless no samples are taken

It seems as though the 'population' and 'capacity' may be getting mixed up, though there is no mention of 'capacity' in the tutorial for loading data.

In camps, the 'capacity' becomes the population that is read in and the 'population' is 0. Example in error:

Location name: Apaydin, X: 36.235, Y: 36.352, movechance: 0.001, cap: 4390, pop: 0, country: Turkey, conflict? False, camp? True Location name: Ceylanpinar, X: 36.814, Y: 39.924, movechance: 0.001, cap: 21176, pop: 0, country: Turkey, conflict? False, camp? True Location name: Harran Kokenli, X: 36.873, Y: 38.932, movechance: 0.001, cap: 13761, pop: 0, country: Turkey, conflict? False, camp? True

In towns, the 'capacity' is -1 and the 'population' is also 0. Example in error:

Location name: Diyarbakir, X: 37.925631, Y: 40.210571, movechance: 0.3, cap: -1, pop: 0, country: Turkey, conflict? False, camp? False Location name: Batman, X: 37.889964, Y: 41.130106, movechance: 0.3, cap: -1, pop: 0, country: Turkey, conflict? False, camp? False Location name: Van, X: 38.500085, Y: 43.374066, movechance: 0.3, cap: -1, pop: 0, country: Turkey, conflict? False, camp? False

There is no error print-out for conflizt_zones but I suspect that the 'population' may also be interpreted as the 'capacity?'

I have debugged my input data as far as I can and still cannot get the code to run without throwing this error.

djgroen commented 3 years ago

I assigned Diana to this one to begin with :).

cspgdds commented 3 years ago

Arranged skype call and resolved the issue. It was due to conflicts starting from day 2 without an initial conflict on day 1.