gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
303 stars 99 forks source link

Bug when getting the key of each element of a map<int, pair<int,float>> #2058

Closed benoitgaudou closed 7 years ago

benoitgaudou commented 7 years ago

Steps to reproduce

  1. In a model, a map<int, pair<int, float>> is used. When we want to get all the key of the value of the map (the pairs), we get randomly value that are not correct.

  2. As an example, look at the following model:

    
    model towardMinimal

global { init { create home number:1 ; ask home { notPrunedTrees <- ([0::(5::0.0), 1::(2::0.0), 2::(3::0.0)]); }

}

reflex dl when: true {
        write ""; 
    list<list<int>> ll1 <- [];
    write "--------------------------------------------";

    loop h over: home {
        write h.notPrunedTrees;
        list<int> lkey <- h.notPrunedTrees collect each.key;
        write lkey;
        write "";
        if(lkey != [5,2,3]) {
            do pause;
        }
    }

} }

species home { map<int, pair<int,float>> notPrunedTrees <- []; }

experiment testAccu type: gui { output {} }



3. Run the model. It will stop when we get wrong values (the correct value of the list of keys of values is [5,2,3]).

### System and version 
GAMA v GIT, MACOSX
benoitgaudou commented 7 years ago

just to add that it occurs with a map<int, int> instead of map<int, map<int,float>>... As an example, this simpler model also shows the bug:

global {
    reflex dddl {
        map<int,int>     notPrunedTrees <- ([0::5, 1::2, 2::3]);
        list<int> lkey <- notPrunedTrees collect each;
        write lkey;

        if(lkey != [5,2,3]) {
            do pause;
        }           
    }
}