Skip to content

areasequence_computation

Mateus de Assis Silva edited this page Jan 5, 2020 · 2 revisions

The areasequence_computation() iterativelly generates the sequence of areas which were visited by the animal.

In the rep file, the function receives e(1).tempoareas, which contains the moments when the animal enters or leaves a predefined area. This parameter goes inside data.

The e(1).tempoareas is already sorted ascending. In each step, the algorithm takes the lowest values related to each area (the moment when the animal enters and leaves all the areas), and creates vectors (ti_vector and tf_vector) with it.

The lowest value in ti_vector represents the most previous moment when one area was visited. When ti_vector and tf_vector was made, each position is related to a specific area. Then, when we find the position of lowest time inside ti_vector, we find the most previous visited area.

After finding and displaying the area (note that, if we know which area was previously visited, we know that it was left), we would only need to erase the found values in data.

Repeat these steps until we get data.ti and data.tf with only one term. The tests showed erasing values forever does not work (so that we get void container), so let's substitute them by intmax. When we finally achieve data.ti and data.tf filled with intmax, we stop the procedure.

For some reason, the code runs one more time than necessary, so we only display lowest values different than intmax.