Malfunction data generator does not work

Hi everyone!

I would like to point out that malfunction data generator in latest FLATland version (for example in flatland_2_0_example.py) does not work at all. I tried to set the maximum percentage of defective agents parameter but didn`t get a single occurence.

Please add this feature again. Thank you!

Hi @vetrov_andrew

This is only temporary. The fix is on it’s way just waiting for the test pipeline to pass and then we will merge. Would be great if you can then run a test again. But currently it does work on the feature branch with the bugfixes.

We had issues with diverging instances of different environments that needed to be addressed.

Best regards,
The Flatland Team

Out of curiosity what do you get if you print this at every step:

print(env.agents[a].malfunction_data)

where a is the agent number.

Hi mlerik

Just on every step…
Note that it is the latest master branch. If you want to test something else, I have some time right now.

Hi @vetrov_andrew

The current state and next release is on this branch.

It would be great to get some feedback if your code runs with this or if there are any issues.

Best regards
Erik

Branch will be deleted when pipeline succeeds, then you can head over to master again.

Thanks to all participants for actively pointing out bugs and helping us evolve Flatland further.

Best regards,
The Flatland Team

Well, I have already downloaded and tested my code with this branch.

Firstly, I want to say that this branch uses gym utils (so, I had to download them to continue) - I saw an isssue with this problem.

Secondly, I send you a report with malfunction information. I did not explore it deeply, but found that there are some mistakes. As you can see, malfunction length do not update on the first steps.

Start episode…
0.9744243621826172
5
========== step number 0 ==========
0 [True, True, True, True, True] [2, 4, 0, 1, 3]
My action: {0: 4, 1: 4, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 56, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 19, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 1 ==========
My action: {0: 4, 1: 4, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 56, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 19, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 2 ==========
My action: {0: 4, 1: 4, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 56, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 19, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 3 ==========
My action: {0: 4, 1: 4, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 56, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 19, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 4 ==========
My action: {0: 2, 1: 4, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 3, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 19, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 5 ==========
My action: {0: 2, 1: 4, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 2, ‘malfunction_rate’: 30, ‘next_malfunction’: 54, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 19, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 6 ==========
My action: {0: 2, 1: 2, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 1, ‘malfunction_rate’: 30, ‘next_malfunction’: 53, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 5, ‘malfunction_rate’: 30, ‘next_malfunction’: 18, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 7 ==========
My action: {0: 2, 1: 2, 2: 4, 3: 2, 4: 2}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 52, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 17, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 5, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 8 ==========
My action: {0: 2, 1: 2, 2: 4, 3: 2, 4: 2}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 51, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 3, ‘malfunction_rate’: 30, ‘next_malfunction’: 16, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 5, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 5, ‘malfunction_rate’: 30, ‘next_malfunction’: 4, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 9 ==========
My action: {0: 2, 1: 2, 2: 4, 3: 2, 4: 1}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 50, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 2, ‘malfunction_rate’: 30, ‘next_malfunction’: 15, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 3, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 10 ==========
My action: {0: 3, 1: 2, 2: 4, 3: 2, 4: 3}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 49, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 1, ‘malfunction_rate’: 30, ‘next_malfunction’: 14, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 11, ‘malfunction_rate’: 30, ‘next_malfunction’: 55, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 3, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 3, ‘malfunction_rate’: 30, ‘next_malfunction’: 2, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 11 ==========
My action: {0: 3, 1: 2, 2: 2, 3: 2, 4: 1}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 48, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 13, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 10, ‘malfunction_rate’: 30, ‘next_malfunction’: 54, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 2, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 2, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 12 ==========
My action: {0: 1, 1: 2, 2: 2, 3: 2, 4: 3}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 47, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 12, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 9, ‘malfunction_rate’: 30, ‘next_malfunction’: 53, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 1, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 1, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 13 ==========
My action: {0: 4, 1: 2, 2: 2, 3: 4, 4: 2}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 46, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 11, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 8, ‘malfunction_rate’: 30, ‘next_malfunction’: 52, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 0, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}

========== step number 14 ==========
My action: {0: 4, 1: 4, 2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 45, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 10, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 51, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 5, ‘malfunction_rate’: 30, ‘next_malfunction’: 29, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 9, ‘malfunction_rate’: 30, ‘next_malfunction’: 100, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 15 ==========
0 [False, False, False, False, False] [2, 4, 0, 1, 3]
1 [False, False, False, False, False] [3, 4, 1, 0, 2]
2 [False, False, False, False, False] [0, 3, 1, 2, 4]
3 [False, False, False, False, False] [2, 4, 1, 0, 3]
4 [False, False, False, False, False] [3, 2, 1, 4, 0]
5 [False, False, False, False, False] [3, 2, 1, 0, 4]
6 [False, False, False, False, False] [0, 3, 2, 4, 1]
7 [False, False, False, False, False] [2, 4, 0, 1, 3]
8 [False, False, False, False, False] [1, 0, 3, 4, 2]
9 [False, False, False, False, False] [2, 4, 3, 0, 1]
My action: {2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 44, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 9, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 50, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 28, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 8, ‘malfunction_rate’: 30, ‘next_malfunction’: 99, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 16 ==========
My action: {2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 43, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 8, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 5, ‘malfunction_rate’: 30, ‘next_malfunction’: 49, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 3, ‘malfunction_rate’: 30, ‘next_malfunction’: 27, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 7, ‘malfunction_rate’: 30, ‘next_malfunction’: 98, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 17 ==========
My action: {2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 42, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 7, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 48, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 2, ‘malfunction_rate’: 30, ‘next_malfunction’: 26, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 6, ‘malfunction_rate’: 30, ‘next_malfunction’: 97, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 18 ==========
My action: {2: 4, 3: 4, 4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 41, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 6, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 3, ‘malfunction_rate’: 30, ‘next_malfunction’: 47, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 1, ‘malfunction_rate’: 30, ‘next_malfunction’: 25, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 5, ‘malfunction_rate’: 30, ‘next_malfunction’: 96, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 19 ==========
My action: {2: 4, 4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 40, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 5, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 2, ‘malfunction_rate’: 30, ‘next_malfunction’: 46, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 24, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 4, ‘malfunction_rate’: 30, ‘next_malfunction’: 95, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 20 ==========
My action: {2: 4, 4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 39, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 4, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 1, ‘malfunction_rate’: 30, ‘next_malfunction’: 45, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 23, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 3, ‘malfunction_rate’: 30, ‘next_malfunction’: 94, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 21 ==========
My action: {4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 38, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 3, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 44, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 22, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 2, ‘malfunction_rate’: 30, ‘next_malfunction’: 93, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 22 ==========
My action: {4: 4}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 37, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 2, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 43, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 21, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 1, ‘malfunction_rate’: 30, ‘next_malfunction’: 92, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

========== step number 23 ==========
My action: {}
agent num 0 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 36, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 1 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 1, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 2 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 42, ‘nr_malfunctions’: 1, ‘moving_before_malfunction’: False}
agent num 3 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 20, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: False}
agent num 4 {‘malfunction’: 0, ‘malfunction_rate’: 30, ‘next_malfunction’: 91, ‘nr_malfunctions’: 2, ‘moving_before_malfunction’: True}

Episode: Steps 23 Score = -80.0

Hi @vetrov_andrew

Thank you for the feedback. We are lookig into the issue with gym, which is needed to unify the seeding process across multiple instances.

The malfunction only starts counting when an agent actively enters the environment. This is a design choice. But we are happy to discuss benefits and drawbacks of this implementation.

Best regards,
Erik

Hi @mlerik!

Please, check the behavior of the last agent in my new simulation. It seems that new_malfunction is not shown correctly on step number 5. I see that this problem occurs on the first steps only (but all agents have entered the environment).

import time

import numpy as np

from flatland.envs.observations import TreeObsForRailEnv, GlobalObsForRailEnv
from flatland.envs.predictions import ShortestPathPredictorForRailEnv
from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_generators import sparse_rail_generator
from flatland.envs.schedule_generators import sparse_schedule_generator
from flatland.utils.rendertools import RenderTool, AgentRenderVariant

np.random.seed(1)

stochastic_data = {'prop_malfunction': 0.5,  # Percentage of defective agents
                   'malfunction_rate': 30,  # Rate of malfunction occurence
                   'min_duration': 3,  # Minimal duration of malfunction
                   'max_duration': 10  # Max duration of malfunction
                   }

TreeObservation = TreeObsForRailEnv(max_depth=2, predictor=ShortestPathPredictorForRailEnv())

speed_ration_map = {1.: 0.25,  # Fast passenger train
                    1. / 2.: 0.25,  # Fast freight train
                    1. / 3.: 0.25,  # Slow commuter train
                    1. / 4.: 0.25}  # Slow freight train

env = RailEnv(width=60,
              height=60,
              rail_generator=sparse_rail_generator(max_num_cities=12,
                                                   # Number of cities in map (where train stations are)
                                                   seed=14,  # Random seed
                                                   grid_mode=False,
                                                   max_rails_between_cities=2,
                                                   max_rails_in_city=6,
                                                   ),
              schedule_generator=sparse_schedule_generator(speed_ration_map),
              number_of_agents=5,
              stochastic_data=stochastic_data,  # Malfunction data generator
              obs_builder_object=GlobalObsForRailEnv(),
              remove_agents_at_target=True
              )

obs = env.reset()

MY_ACTION = []
MY_ACTION.append({0: 4, 1: 2, 2: 4, 3: 4, 4: 2})
MY_ACTION.append({0: 2, 1: 2, 2: 2, 3: 2, 4: 2})
MY_ACTION.append({0: 2, 1: 2, 2: 2, 3: 2, 4: 2})
MY_ACTION.append({0: 2, 1: 2, 2: 2, 3: 2, 4: 2})
MY_ACTION.append({0: 2, 1: 2, 2: 3, 3: 2, 4: 4})
MY_ACTION.append({0: 2, 1: 2, 2: 1, 3: 2, 4: 2})
MY_ACTION.append({1: 4, 4: 4})

for step in range(7):
    print("========== step number ", step, " ==========", sep = "")
    action_dict = MY_ACTION[step]
    print("my action ", action_dict)
    for ind in range(env.get_num_agents()):
        print(env.agents[ind].malfunction_data)
    next_obs, all_rewards, done, _ = env.step(action_dict)

Thanks @vetrov_andrew for reporting this bug.

Turns out there was a next malfunction time set to 0 in this case. I fixed this issue and also updated when the counter goes down for next malfunction. WIll run a few tests and push the updated version soon.

In a few hours there will be an announcement on the next round and the next version of Flatland and an example to highlight all the changes. Would be great if you can do an early review of that file as soon as it is online as you already have quite some experience with the new changes.

Best regards,
Erik

All right, I am ready.

This isn’t the case anymore starting with version 2.1.10, is it? I am now seeing the malfunction duration being updated also for agents who did not enter the environment.

This was quite surprising, because you explicitly mentioned this behavior in at least 2 posts, only to see it changed with the updated version. Anyway, I currently updated my logic to consider the new behavior, so I’m hoping there won’t be any more going back and forth on this topic.

Please note that every time you change some core behavior in the simulator there’s a really non-trivial amount of work required to update existing solutions only to behave correctly, when at this point I feel we should be focusing on improving the quality of the solutions, and not at reverse engineering what’s new with the latest version of the simulator.