CityScope / CS_Simulation_GAMA

Agent Based Simulation platform for CityScope
GNU General Public License v3.0
31 stars 21 forks source link

Numeric indicator #137

Closed agrignard closed 4 years ago

agrignard commented 4 years ago

Provide an exemple to build and send a numerical indicator to cityIO.

This need to be send here https://cityio.media.mit.edu/api/table/dungeonmaster/indicators

And here the format of the indicators

[{"indicator_type":"numeric","name":"Diversity of land use","value":0.9016420530467626,"viz_type":"bar"}]
agrignard commented 4 years ago

Seems to work pretty well now for a Hello World indicator sent by GAMA with this method

    action sendIndicator(string type){
        string myIndicator;
        myIndicator<-"[{\"indicator_type\":\"" + type+"\",\"name\":\"Gama Indicator\",\"value\":"+length(block)+",\"viz_type\":\"bar\"}]";
        save myIndicator to: "indicator.json" rewrite: true;
        file JsonFileResults <- json_file("./indicator.json");
        map<string, unknown> c <- JsonFileResults.contents;
        try{            
          save(json_file("https://cityio.media.mit.edu/api/table/update/"+city_io_table+"/indicators", c));     
        }catch{
          write #current_error + " Impossible to write to cityIO - Connection to Internet lost or cityIO is offline";   
        }
        write #now +" Indicator Sucessfully sent to cityIO at iteration:" + cycle ;

    }

see https://cityio.media.mit.edu/api/table/dungeonmaster/indicators

crisjf commented 4 years ago

Nice! Did you push this?

agrignard commented 4 years ago

Yes just pushed with your modification also

crisjf commented 4 years ago

Looks good! Let's try something more agent-based-like to help us think about the record mode for the simulation. Let's do a random walker that moves between the blocks and count the number of times it visits a park?

agrignard commented 4 years ago

Yes of course this is just the Hello World. There is no agent yet in the model to keep it simple for now.

agrignard commented 4 years ago

Also we need to be able to send several indicator, right now it just send the last, we should have a list of indicator sent

crisjf commented 4 years ago

I already started working on this, see #142

crisjf commented 4 years ago

4f8ba7c9c1c54ddb20db9be1b90f3bf96a6fd259 makes indicators their own species.

crisjf commented 4 years ago

I think we can close this for now. The numeric indicators are working pretty well. We can reopen if we need to develop them more.

crisjf commented 4 years ago

Referencing a commit with documentation here:

8ab9ea8e2f369f477516e259edba1f132953777e

crisjf commented 4 years ago

I guess we can also build this using the same logic as the other two indicators and using cityio_agent as the parent class.

crisjf commented 4 years ago

All indicators now use cityio_agent as their parent class.