djgroen / flee Goto Github PK
View Code? Open in Web Editor NEWflee agent-based modelling code
License: BSD 3-Clause "New" or "Revised" License
flee agent-based modelling code
License: BSD 3-Clause "New" or "Revised" License
I am currently finalizing the ruleset 2.0 implementation. In it I will enable a mode that approximates the behavior of the original ruleset.
I already fixed one bug, where the setting to start on foot could not be disabled.
In this ticket I just want to remind myself to also look at the changed calculateLinkWeight()
. It may be that the logic is subtly different here in the new version...
As requested by Auke
Hi Ali.
I made some progress, and after fixing a few bugs I get a missing input file.
I run python3 ssudan_mscalecity 0
, which then gives me the following error:
FileNotFoundError -> examples/ssudan_input_files/conflict_period.csv
Could you please upload this file and any other missing input files to the GitHub repo in your branch?
This has now been added. Ticket is for record keeping :).
e.g. infinite?
fabsim localhost validate_flee
Check how it compares with previous versions, and what kind of issues arise.
When I type:
fab localhost plot_output:mali_localhost_16,output_dir=tmp/
The plotting script operates on ~/FabSim3/results, which is not the local copy, but the staged one (the local one in my case is ~/Codes/FabSim3/results). This will cause this script to do processing in an unusual location and, moreover, to fail if anyone uses it on a run that is not done on localhost.
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.
Is the total # of agents in both models equal to the ones in refugees.csv? Are agents from the microscale model indeed added up correctly when adding new agents every time step?
Regarding technical documentation, I noticed when I was very new in using flee as a novice user, there is some complicated or incomplete documentation. For instance, the recent issue I noticed is about multiscale modelling and data preparation for it. I think we need completely guide users on how to do that.
We currently enter it manually as part of conflict zones, but population should become an attribute for a location.
The current version of Flee tutorial documents hasn't updated and reflected the new input files for simulations. Here is the new structure of input files which will be added to the tutorial:
source_data (directory)
- data_layout.csv
- refugees.csv
- country_name-camp_name.csv
closures.csv
conflict_period.csv
conflicts.csv
coupled_locations.csv (for multiscale and coupled simulations)
locations.csv
registration_corrections.csv
routes.csv
Besides, it is worth to add that for coupled multiscale simulations, there is a need to have two files for the above input files reflecting macro and micro models inputs.
Compare plots for:
With a default move chance of 1.0
name = "idpcamp"
An automated version of Burundi (2015) conflict has a forced redirection which was removed after certain days: https://github.com/djgroen/FabFlee/blob/master/config_files/burundi/input_csv/closures.csv
Currently, it is added in the closures.csv file but not implemented in the Flee code.
For reference, hard-coded version of Burundi run.py file
https://github.com/djgroen/FabFlee/blob/57dbca6ceeccd72bc6adb8d2375cc310fe0bca2a/config_files/validation/SWEEP/oldstyle_burundi/run.py#L173
Camp
or camp
?Traceback (most recent call last):
File "/home/csstdds/Codes/flee/runscripts/run_par.py", line 78, in <module>
e.evolve()
File "/home/csstdds/Codes/flee/flee/pflee.py", line 21, in wrapper
return func(*args, **kwargs)
File "/home/csstdds/Codes/flee/flee/pflee.py", line 621, in evolve
a.finish_travel(time=self.time)
File "/home/csstdds/Codes/flee/flee/pflee.py", line 21, in wrapper
return func(*args, **kwargs)
File "/home/csstdds/Codes/flee/flee/pflee.py", line 104, in finish_travel
super().finish_travel(time=time)
File "/home/csstdds/Codes/flee/flee/flee.py", line 184, in finish_travel
if self.location.Camp is True:
AttributeError: 'Location' object has no attribute 'Camp'. Did you mean: 'camp'?
Solution: flee.py
line 184: if self.location.Camp is True:
change to lower letter c
-> if self.location.camp is True:
line 516: if loc.Camp is True:
change to lower letter c
-> if loc.camp is True:
The start date of the simulation is set manully in run_csv_vanilla.py, which should rather read the start date through SimulationSettings.csv (requires change).
Line 435 in fb305ec
Level 1 registration is currently incorporated manually to csv scripts. We require implementation of Level 1 registrations within csv file formats and main flee import
The serial mode (using micro_flee instead of pmicro_flee) is essential because:
Could you please add in an argument to the ssudan_mscalecity.py script that allows on to switch between these modes?
Also, perhaps rename the script, as the "mscalecity" part seems inappropriate to me, given that we are modelling a region/country?
Low priority:
Enable this functionality, and expose a Flee API for easy external usage.
Please put all requests for this version below.
The management of conflict zones, changing move chances and calculating move probabilities are now in the python scripts. We should create shorthands for this in the FLEE libraries.
there is an issue with the latest version of pandas=1.0.1
with version pandas = 0.25.0
there is no problem
it seems in the new version, DataFrame
object has no attribute as_matrix
we need to investigate this issue and maybe other issues related to pandas library to make sure that flee
will work with latest version
$ fab localhost plot_output:mali_localhost_16,out
Traceback (most recent call last):
File "/home/hamid/BUL/flee/plot-flee-output.py", line 410, in <module>
:, ["refugees in camps (simulation)"]].as_matrix().flatten()
File "/home/hamid/.local/lib/python3.7/site-packages/pandas/core/generic.py", line 5274, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'as_matrix'
Fatal error: local() encountered an error (return code 1) while executing 'python3 ~/BUL/flee/plot-flee-output.py /home/hamid/BUL/FabSim3/results/mali_localhost_16 /home/hamid/BUL/FabSim3/results/mali_localhost_16/out'
Add a flag that changes the random choice to simply picking the highest weight.
Move chance and ConflictWeight scale from Default at 0 to Conflict at 1, interpolated in between.
Idea is to use a movestring array of location IDs (or names), and to have agents skip route choice decisions while this array is non-zero. An element is removed from the array whenever a location is visited.
The array will be erased whenever a location in the movestring can no longer be chosen for any reason.
This feature should be triggered automatically when awareness level is higher than 1.
During test executions with test input files of ssudan-mscale-test, I forgot to change the population from the original number to the test number and when I found that I realized that the population of conflict zones in location.csv hasn't affected the results before and after the correction the population. I wonder why this happens and how the population shouldn't affect the results?
The longer refugees are travelling, the more aware they become of their surroundings. This needs to be implemented.
Hi, please excuse me, this is probably a very basic question.
I am installing Flee in Ubuntu 22.10 for testing purposes. It is a VirtualBox VM. I created and activated a virtualenv for this installation. I followed the steps of installing/testing flee. But in the last step I got this error:
$ python3 tests/test_csv.py
Traceback (most recent call last):
File "...flee/tests/test_csv.py", line 4, in
import flee.postprocessing.analysis as a
ModuleNotFoundError: No module named 'flee'
Thank you,
Yonny
It's largely documented in SimulationSettings.py, but that's not a useful page. Perhaps we should have a ReadTheDocs page for it?
@cspgdds would you have time to make such a page?
Camp capacities appear to not be correctly enforced in FLEE. Determine why this is, and solve the issue.
#closure_type,name1,name2,closure_start,closure_end
should support one-way forced_redirections from name1 to name2. The support only needs to be on the link level.
Type:
And then remove all instances of the ZeroOnDayZero flag, as we now have removed this.
Add a link attribute that determines max move speeds for agents on that link.
There is a possible complication in determining how distancemovedthisturn needs to be interpreted in this context.
The readthedocs build has been broken for a long time. It is time to fix it.
There may be other hard-coded slashes too. Be sure to check!
It is now requested by two collaborators to include actual dates (YYYY-MM-DD or DD-MM-YYYY) in out.csv instead of simulation days.
Would you be able to include an additional column with actual dates to out.csv?
The plot_output plugin encounters a KeyError when producing plots. The specific key causing the error is 'Date sim'. This issue prevents the plugin from generating the expected output and saving plots in the desired png format.
fabsim localhost plot_output:output
after fetching the processed data.The plot_output plugin should successfully generate the desired plots without encountering a KeyError.
To address the KeyError, a temporary solution has been implemented in the code by modifying the loop to start from the second element of the list. While this temporarily resolves the issue, it is important to investigate the root cause of why 'Date sim' is stored in the CSV file headers. Identifying the inconsistency in CSV file generation will help in achieving a more robust and consistent solution.
Please let me know if any further information or clarification is needed.
I noticed the following libraries have been removed from ssudan_mscalecity.py.
Removing the latter one is alright, because it is for debugging,
but what about outputanalysis.analysis? It is used for output files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.