CityScope / CS_Proxymix

ABM framework to study spatial configuration and human behaviour at the building scale
10 stars 7 forks source link

Cannot run UDG/CUAAD #105

Closed agrignard closed 4 years ago

agrignard commented 4 years ago

3 occurrences in 3 agents at cycle 0: Java error: nil value detected in closest_path <- paths with_min_of distance_to(each.free_space,location); NullPointerException: null when applying the distance_to operator on nil and {19.609053066740447,7.304609674349487,0.0} in closest_path <- paths with_min_of distance_to(each.free_space,location); in else { closest_path <- paths with_min_of distance_to(each.free_space,location); }

in if movement_model = 'moving skill' { closest_path <- paths with_min_of distance_to(each,location); }else { closest_path <- paths with_min_of distance_to(each.free_space,location); }

in if not(empty(pedestrian_path)) { list paths <- pedestrian_path at_distance 10.0; if movement_model = 'moving skill' { closest_path <- paths with_min_of distance_to(each,location); }else { closest_path <- paths with_min_of distance_to(each.free_space,location); }

if closest_path != nil  {
    init_place <- inter(shape,closest_path);
    if init_place = nil  {
        init_place <- closest_points_with(shape,closest_path)[0];
    }

}else  {
    init_place <- shape;
}

}else { init_place <- shape; }

in ask building_entrance { if not(empty(pedestrian_path)) { list paths <- pedestrian_path at_distance 10.0; if movement_model = 'moving skill' { closest_path <- paths with_min_of distance_to(each,location); }else { closest_path <- paths with_min_of distance_to(each.free_space,location); }

    if closest_path != nil  {
        init_place <- inter(shape,closest_path);
        if init_place = nil  {
            init_place <- closest_points_with(shape,closest_path)[0];
        }

    }else  {
        init_place <- shape;
    }

}else  {
    init_place <- shape;
}

}

in ask building_entrance { if not(empty(pedestrian_path)) { list paths <- pedestrian_path at_distance 10.0; if movement_model = 'moving skill' { closest_path <- paths with_min_of distance_to(each,location); }else { closest_path <- paths with_min_of distance_to(each.free_space,location); }

    if closest_path != nil  {
        init_place <- inter(shape,closest_path);
        if init_place = nil  {
            init_place <- closest_points_with(shape,closest_path)[0];
        }

    }else  {
        init_place <- shape;
    }

}else  {
    init_place <- shape;
}

}

in init { validator <- false; outputFilePathName <- ((((((((((((('../results/output' + #now.year) + '') + #now.month) + '') + #now.day) + '') + #now.hour) + '') + #now.minute) + '') + #now.second) + 'distance') + distance_people) + '.csv'; do initiliaze_dxf ; create pedestrian_path from: pedestrian_path_shape_file ; pedestrian_network <- as_edge_graph(pedestrian_path); loop se over: the_dxf_file { string type <- get(se,layer); if type = walls { create wall with: [shape::clean(polygon(se.points))]; }else { if type = entrance { create building_entrance with: [shape::polygon(se.points), type::type]; }else { if type in ([offices,meeting_rooms,coffee]) { create room with: [shape::polygon(se.points), type::type] { if flip(ventilation_ratio) { isVentilated <- true; }

                }

            }

        }

    }

}

if density_scenario = 'num_people_building'  {
    list<room> offices_list <- room where (each.type = offices);
    float tot_area <- sum_of(offices_list,each.shape.area);
    ask offices_list  {
        num_places <- max([1,round((num_people_per_building * shape.area) / tot_area)]);
    }

    int nb <- sum_of(offices_list,each.num_places);
    if (nb > num_people_per_building) and (length(offices_list) > num_people_per_building)  {
        loop times: nb - num_people_per_building  {
            room r <- one_of(offices_list where (each.num_places > 1));
            r.num_places <- r.num_places - 1;
        }

    }else  {
        if nb < num_people_per_building  {
            loop times: num_people_per_building - nb  {
                room r <- one_of(offices_list);
                r.num_places <- r.num_places + 1;
            }

        }

    }

}

ask room + building_entrance  {
    do intialization ;
}

ask dxf_element  {
    do die ;
}

ask wall  {
    if not(empty((room + building_entrance) inside self))  {
        shape <- shape.contour;
    }

}

ask room  {
    list<wall> ws <- wall overlapping self;
    loop w over: ws  {
        if covers(w,self)  {
            do die ;
        }

    }

}

ask room + building_entrance  {
    geometry contour <- nil;
    float dist <- 0.3;
    int cpt <- 0;
    loop while: contour = nil  {
        cpt <- cpt + 1;
        contour <- copy(shape.contour);
        ask wall at_distance 1.0  {
            contour <- contour - (shape + dist);
        }

        if cpt < 10  {
            ask (room + building_entrance) at_distance 1.0  {
                contour <- contour - (shape + dist);
            }

        }

        if cpt = 20  {
            break;
        }

        dist <- dist * 0.5;
    }

    if contour != nil  {
        entrances <- points_on(contour,2.0);
    }

    ask places  {
        point pte <- closest_to(myself.entrances,self);
        dists <- distance_to(self,pte);
    }

}

map<string, list<room>> rooms_type <- room group_by each.type;
loop ty over: rooms_type.keys - ([offices,entrance])  {
    create activity  {
        name <- ty;
        activity_places <- rooms_type[ty];
    }

}

create working ;
create going_home_act with: [activity_places::list<building_entrance>(building_entrance)];
create eating_outside_act with: [activity_places::list<building_entrance>(building_entrance)];
available_offices <- rooms_type[offices] where (each.is_available());
if movement_model = pedestrian_skill  {
    do initialize_pedestrian_model ;
}

ask building_entrance  {
    if not(empty(pedestrian_path))  {
        list<pedestrian_path> paths <- pedestrian_path at_distance 10.0;
        if movement_model = 'moving skill'  {
            closest_path <- paths with_min_of distance_to(each,location);
        }else  {
            closest_path <- paths with_min_of distance_to(each.free_space,location);
        }

        if closest_path != nil  {
            init_place <- inter(shape,closest_path);
            if init_place = nil  {
                init_place <- closest_points_with(shape,closest_path)[0];
            }

        }else  {
            init_place <- shape;
        }

    }else  {
        init_place <- shape;
    }

}

ask wall  {
    ask proximityCell overlapping self  {
        is_walking_area <- false;
    }

}

nbOffices <- room count (each.type = 'Offices');
officeArea <- sum((room where (each.type = 'Offices')) collect each.shape.area);
nbMeetingRooms <- room count (each.type = 'Meeting rooms');
meetingRoomsArea <- sum((room where (each.type = 'Meeting rooms')) collect each.shape.area);
nbDesk <- length(room collect each.available_places);

}

in agents building_entrance0, Simulation 0, DailyRoutine0

agrignard commented 4 years ago

Fixed with the last PR