Dear all,
I've been dealing with the error - 2 occurrences in 2 agents at cycle X: Java Error: ConcurentModificationException (image below)
This error occurs at different cycles. I spotted the line which is responsible for the error, but I didn't get why and how to overcome it. This happens in the move function when I try to export the agents' variables:
reflex move when: the_target != nil {
do drive;
my_road <- road closest_to self;
string file_name <- "../includes/output/drivers_" +
driver.name;
save "" + self.name + "\t" + model_time + "\t" + my_road.name+"\t"+ self.real_speed +"\t"+ self.objective to: file_name+".csv" type: "text" rewrite: false; At first, that line was saving everything to one file (without the
driver.name in defining the
file_name). I thought that this was happening because of the parallelization - that two agents' variables tried to write them in the same file's line, so I make it saving to files for each agent individually (as it is shown above). However, I've still got it. The next clue was that specific attribute was responsible. So I tried to save only agents' name, still got it. Then I created a new reflex for exporting the attributes, didn't resolve it.
This error usually happens after few created files.
The model is pretty much similar to the example in the library which demonstrates the functioning of advanced traffic. The timestep is one second.
If someone can help me to understand why is it happening and how to solve it (without erasing the save functionality, I really need it :D ), I would be so grateful! I am dealing with it for quite of time, I am starting to be desperate. I am not a Java or OO programmer, so it making me difficult to understand it.
Thank you in advance!!