Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CPG_CityScope_GAMA/models/CityScope_main.gaml
  • Loading branch information
agrignard committed Oct 20, 2017
2 parents 6a3fbee + 0a59fcc commit bb87ed6
Show file tree
Hide file tree
Showing 17 changed files with 1,306 additions and 11 deletions.
Binary file added CPG_CityScope_GAMA/images/big_hand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added CPG_CityScope_GAMA/images/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added CPG_CityScope_GAMA/images/small_hand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 133 additions & 0 deletions CPG_CityScope_GAMA/includes/data_viz/pie_charts.gaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/**
* Name: pie
* Author: Tri
* Description:
* Tags: Tag1, Tag2, TagN
*/

model pie_charts

/* Insert your model definition here */

/*
global{
list<rgb> color_list <- [rgb(3,169,244),rgb(255,235,59),rgb(255,152,0),rgb(255,87,34)];
list<float> valeurs <- [4,7,22];

init{
create pie{
labels <- ["Chat","Chien","Poulet"];
labels_h_offset <- [15,15,18];
values <- valeurs;
colors <- [color_list[1],color_list[2],color_list[3]];
location <-{50,50};
diameter <- 50;
inner_diameter <- 40;
font_size <- round(diameter/30);
type <- "ring";
}
}

reflex change{
loop i from: 0 to: length(valeurs)-1{
valeurs[i] <- max([0,valeurs[i] -2 + rnd(4)]);
}
ask first(pie) {
do calculate_pies;
do update_values(valeurs);
}

}

}*/

species pie{
/* general parameters that must be set by the user */
string id;
string type <- "pie"; // among "pie", "ring"
list<string> labels; // labels of the categories to be displayed
list<float> values; // values to be displayed
list<rgb> colors; // colors of the different categories

/* display parameters */
float diameter <- 50.0; // pie or ring diameter
float inner_diameter <- 40.0; // ring inner diameter
int nb_points <- 72; // number of points on the outer circle, useful to set the level of detail
float labels_v_offset <- 1.3; // vertical offset for labels
list<float> labels_h_offset; // horizontal offset for strings which are displayed on the left side of the chart. Necessary until the string display is fixed in Gama
float font_size <- 20.0;
float line_width <- float(round(diameter/30));

/* parameters for internal use */
list<list<point>> pies <-[];
list<list<point>> label_lines <-[];
list<point> label_locations <-[];

list<point> calculate_slice(int start_index, int end_index){ // calculate the vertices coordinates for one slice of the pie
list<point> vertices <- (type = "ring")?[]:[location];
loop i from: start_index to: end_index{
vertices << {location.x + sin(i/nb_points * 360)*diameter/2, location.y -cos(i/nb_points * 360)*diameter/2};
}
if type = "ring"{
loop i from: start_index to: end_index {
vertices << {location.x + sin((end_index+start_index-i)/nb_points * 360)*inner_diameter/2, location.y -cos((end_index+start_index-i)/nb_points * 360)*inner_diameter/2};
}
}
return vertices;
}

action update_values(list<float> val){// function use to update the values
self.values <- val;
}

action calculate_pies{// main function for drawing the pie
int nb_pies <- length(values);
pies <- [];
label_lines <- [];
label_locations <- [];
list<int> pies_indexes <- [0];
if (sum(values) = 0) { // if all values are equal to 0
pies <- [calculate_slice(0,nb_points), [],[]];
label_lines <- [[location + {diameter/2,0},location + {diameter/1.3,0}],[location + {diameter/2,0},location + {diameter/1.3,0}],[location + {diameter/2,0},location + {diameter/1.3,0}]];
label_locations <- [location + {diameter/1.3,0},location + {diameter/1.3,0},location + {diameter/1.3,0}];
}else{ // in the general case
list<float> cum_sum <- [0.0];
loop i from: 0 to: nb_pies-1{
cum_sum << last(cum_sum) + values[i]/sum(values) * nb_points;
}
pies_indexes <- cum_sum collect (round(each));
loop i from:0 to: nb_pies-1{
pies << calculate_slice(pies_indexes[i],pies_indexes[i+1]);
float angle <- (pies_indexes[i+1] + pies_indexes[i]) * 180 / nb_points;
label_locations << location+{2+signum(sin(angle))*(diameter/1.3) - int(sin(angle)<0)* labels_h_offset[i],-cos(angle)*diameter/1.5+labels_v_offset};
//label_lines << [location+{sin(angle)*diameter/2.2,-cos(angle)*diameter/2.2}, location+{sin(angle)*diameter/1.5,-cos(angle)*diameter/1.5},location+{signum(sin(angle))*diameter/1.3,-cos(angle)*diameter/1.5}];
label_lines << [location+{sin(angle)*diameter/2,-cos(angle)*diameter/2}, location+{sin(angle)*diameter/1.5,-cos(angle)*diameter/1.5},location+{signum(sin(angle))*diameter/1.3,-cos(angle)*diameter/1.5}];
}
}
}


aspect default{
loop i from:0 to: length(values)-1{
draw polygon(pies[i]) color: colors[i] ;
draw polyline(label_lines[i]) color: colors[i] width: line_width;
draw labels[i] font: font("Helvetica",font_size,#plain) at: label_locations[i] color: colors[i] ;
}
}

}





/*
experiment "Pie Charts" type: gui{

output {
display camembert type: opengl background: color_list[0] {
species pie aspect:default;
}

}
}*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
,00:00,01:00,02:00,03:00,04:00,05:00,06:00,07:00,08:00,09:00,10:00,11:00,12:00,13:00,14:00,15:00,16:00,17:00,18:00,19:00,20:00,21:00,22:00,23:00
High School Student,RM,RM,RM,RM,RM,RM,RM,RM,,HS,HS,HS,HS,HS,HS,HS,HS,Park,Park,Park,,RM,RM,RM
College student,RS|Night,RS|Night,RS,RS,RS,RS,RS,RS,,Uni,Uni,Uni,Uni,Uni,Uni,Uni,Park,Park,,RS,RS,RS|Night,RS|Night,RS|Night
Young professional,RS|Night|Restaurant,RS|Night|Restaurant,RS,RS,RS,RS,RS,OS,OS,OS,OS,OS,OS,OS,OS,OS,OS|Park,OS|Park,OS|Park,RS,RS,RS|Night|Restaurant,RS|Night|Restaurant,RS|Night|Restaurant
Home maker,RM|Restaurant,RM|Restaurant,RM,RM,RM,RM,RM,RM,RM,RM,Shopping,Shopping,Shopping,Shopping,,,Park,Park,Park,RM,RM,RM,RM,RM|Restaurant
Executives,RL|Restaurant,RL|Restaurant,RL,RL,RL,RL,RL,OL,OL,OL,OL,OL,OL,OL,OL,OL,OL,OL,Cultural,Cultural,RL,RL,RL,RL|Restaurant
Mid-career workers,RL|Restaurant,RL|Restaurant,RL,RL,RL,RL,RL,OL,OL,OL,OL,OL,OL,OL,OL,OL,OL,OL,Cultural,Cultural,RL,RL,RL,RL|Restaurant
Retirees,RM|Restaurant,RM|Restaurant,RM,RM,RM,RM,RM,RM,RM,RM,RM,RM,RM,RM,RM,RM,RM|Park,RM|Park,RM,RM,RM,RM,RM,RM|Restaurant
12 changes: 12 additions & 0 deletions CPG_CityScope_GAMA/includes/game_IT/CriteriaFile.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Nb Criteria,4,,,,,,,,,,,,,,,
Nb Trip Objective,4,,,,,,,,,,,,,,,
Purpose,O|Uni|HS,,,,R,,,,Park|Restaurant|Night|Cultural,,,,Shopping,,,
Characteristics,Price,Time,Social Pattern,Difficulty,Price,Time,Social Pattern,Difficulty,Price,Time,Social Pattern,Difficulty,Price,Time,Social Pattern,Difficulty
Role,,,,,,,,,,,,,,,,
High School Student,-1,-0.5,1,-0.5,-1,-0.5,1,-0.5,-1,-0.15,1,-0.25,-1,-0.25,1,-0.75
College student,-0.9,-0.75,1,-0.65,-0.9,-0.75,1,-0.65,-0.75,-0.5,1,-0.5,-0.75,-0.5,1,-0.85
Young professional,-0.7,-0.9,0.9,-0.75,-0.7,-0.9,0.9,-0.75,-0.7,-0.9,0.9,-0.75,-0.7,-0.9,0.9,-0.75
Home maker,0,0,0,0,0,0,0,0,-0.5,-0.85,0.8,-0.9,-0.5,-0.85,0.8,-0.9
Mid-career workers,0,-1,0.2,-1,0,-1,0.2,-1,0,-1,0.2,-1,0,-1,0.2,-1
Executives,0,-1,0.2,-1,0,-1,0.2,-1,0,-1,0.2,-1,0,-1,0.2,-1
Retirees,0,0,0,0,0,0,0,0,-0.5,0,0,-1,-0.5,0,0,-1
11 changes: 11 additions & 0 deletions CPG_CityScope_GAMA/includes/game_IT/DataOnModes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
,color,width,speed
walking,green,2,3
bike,yellow,3,5
eScooter,orange,4,20
PEV,red,5,20
Shared Vehicles (Taxi/Carpooling/...),red,5,20
car,red,5,20
Motorcycles/scooters,orange,5,20
Track based vehicles (subway,red,5,20
bus,blue,5,20
Delivery (Trucks,red,5,20
8 changes: 8 additions & 0 deletions CPG_CityScope_GAMA/includes/game_IT/DataOnProfiles.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
color proba car proba bike proportion
High School Student lightblue 0.05 0.8 0.2
College student blue 0.25 0.8 0.1
Young professional green 0.8 0.7 0.1
Home maker orange 0.3 0.4 0.1
Mid-career workers yellow 0.9 0.4 0.2
Executives red 0.95 0.4 0.1
Retirees darkorange 0.5 0.3 0.2
11 changes: 11 additions & 0 deletions CPG_CityScope_GAMA/includes/game_IT/ModeCharacteristics.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
,Fix price per trip,Price/km,waiting time per segment (minutes),Time/km,Social Pattern,Difficulty / per trip
walking,0,0.001,0.2,15,0.1,0
bike,0,0.01,1,8,0.5,0.1
eScooter; eboard; estuff,0,0.15,1.5,,0.75,0
PEV,0,0.1,3,6,1,0.3
Shared Vehicles (Taxi/Carpooling/...),0,0.7,5,,0.5,0.4
car,0,0.32,2.5,,1,0.2
Motorcycles/scooters,0,0.18,2,,0.3,0.1
Track based vehicles (subway; train; ...),2.5,0,5,2,0.2,
bus,0,0,10,3,0.15,0.5
Delivery (Trucks; Vans; ...),0,0.2,3,,1,1
7 changes: 6 additions & 1 deletion CPG_CityScope_GAMA/models/CityScope_Andorra_demo.gaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ global {
}

experiment CityScopeAndorraDemo type: gui parent:CityScopeMainVirtual{
parameter 'CityScope:' var: cityScopeCity category: 'GIS' <-"andorra";
//parameter 'CityScope:' var: cityScopeCity category: 'GIS' <-"andorra";
float minimum_cycle_duration <- 0.02;

action _init_ {
create CityScope_Andorra_Demo_model with: [cityScopeCity::"andorra", angle :: 3.0,center ::{2550,895}, brickSize :: 37.5, coeffPop::2.0, coeffSize::2];
}

output {
display CityScope type:opengl parent:CityScopeVirtual{}

Expand Down
2 changes: 1 addition & 1 deletion CPG_CityScope_GAMA/models/CityScope_Kendall_data.gaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ global {
global_end_date<-max(mobileData collect int(each["init_date"]));
}
reflex cluster_building when:(cycle=0 and clustering=true){
eps <-cycle*10;
eps <-cycle*10.0;
list<list> instances <- mobileData collect ([each.location.x, each.location.y]);
//DBSCAN
list<list<int>> clusters_dbscan <- list<list<int>>(dbscan(instances, eps,minPoints));
Expand Down
6 changes: 5 additions & 1 deletion CPG_CityScope_GAMA/models/CityScope_Volpe_demo.gaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ global {

}
experiment CityScopeVolpeDemo type: gui parent:CityScopeMainVirtual{
parameter 'CityScope:' var: cityScopeCity category: 'GIS' <-"volpe" among:["volpe", "Andorra"];
action _init_ {
create CityScope_Kendall_Volpe_Demo_model with: [cityScopeCity::"volpe",angle :: -9.74,center ::{3305,2075}, brickSize :: 70.0, coeffPop::1.0, coeffSize::1];
}

//parameter 'CityScope:' var: cityScopeCity category: 'GIS' <-"volpe" among:["volpe", "Andorra"];
float minimum_cycle_duration <- 0.02;
output {

Expand Down
4 changes: 2 additions & 2 deletions CPG_CityScope_GAMA/models/CityScope_generic.gaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ global {

//PARAMETERS
bool moveOnRoadNetworkGlobal <- true parameter: "Move on road network:" category: "Simulation";
int distance parameter: 'distance ' category: "Visualization" min: 1 <- 100#m;
int distance parameter: 'distance ' category: "Visualization" min: 1 <- int(100#m);
bool drawInteraction <- false parameter: "Draw Interaction:" category: "Visualization";
bool cityMatrix <-false parameter: "CityMatrix:" category: "Environment";
bool onlineGrid <-false parameter: "Online Grid:" category: "Environment";
Expand Down Expand Up @@ -67,7 +67,7 @@ global {
location<-any_location_in(world.shape);
area <-shape.area;
perimeter<-shape.perimeter;
totalSqm<-totalSqm+area;
totalSqm<-int(totalSqm+area);
}
create road number:100{
shape<-line([any_location_in(world.shape), any_location_in(world.shape),any_location_in(world.shape)]);
Expand Down
4 changes: 0 additions & 4 deletions CPG_CityScope_GAMA/models/CityScope_main.gaml
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,3 @@ experiment CityScopeMainVirtual type: gui{







4 changes: 2 additions & 2 deletions CPG_CityScope_GAMA/models/SandBox/CityScope_Kendall_Anim.gaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ global {

//PARAMETERS
bool moveOnRoadNetworkGlobal <- true parameter: "Move on road network:" category: "Simulation";
int distance parameter: 'distance ' category: "Visualization" min: 1 <- 100#m;
int distance parameter: 'distance ' category: "Visualization" min: 1 <- int(100#m);
bool drawInteraction <- false parameter: "Draw Interaction:" category: "Visualization";
bool onlineGrid <-true parameter: "Online Grid:" category: "Environment";
bool dynamicGrid <-false parameter: "Update Grid:" category: "Environment";
Expand All @@ -40,7 +40,7 @@ global {
float step <- 10 #sec;
int current_hour update: (time / #hour) mod 24;
int min_work_start <-4 ;
int max_work_start <- 10;
int max_work_start <- 10;
int min_lunch_start <- 11;
int max_lunch_start <- 13;
int min_rework_start <- 14;
Expand Down
Loading

0 comments on commit bb87ed6

Please sign in to comment.