gama-platform / gama

Main repository for developing the 2024+ versions of GAMA
https://gama-platform.org
GNU General Public License v3.0
16 stars 5 forks source link

java error :nil value detected #267

Closed Eya934 closed 1 week ago

Eya934 commented 1 month ago

Steps to reproduce

1.3 occurrences in 3 agents at cycle 0: Java error: nil value detected in Simulation 0 in list dates_prod_ut <- tokenize(dates_prod,'|'); NullPointerException: Cannot invoke "String.length()" because "str" is null java.base/java.util.StringTokenizer.(StringTokenizer.java:197) java.base/java.util.StringTokenizer.(StringTokenizer.java:219) msi.gaml.operators.Strings.opTokenize(Strings.java:342) msi.gaml.operators.Strings.opTokenize(Strings.java:307) gaml.additions.core.GamlAdditions.lambda$1022(GamlAdditions.java:1075) msi.gaml.expressions.operators.BinaryOperator._value(BinaryOperator.java:150) msi.gaml.expressions.AbstractExpression.value(AbstractExpression.java:87) when applying the tokenize operator on nil and '|' in list dates_prod_ut <- tokenize(dates_prod,'|'); in create up from: shape_file_up with: [id_up::string(read('id')), dates_prod::string(read('Dates_prod')), quantites_prod::string(read('Quant_prod')), types_dechets::[string(read('Biomasse'))]] { list dates_prod_ut <- tokenize(dates_prod,'|'); list quantites_prod_ut <- tokenize(quantites_prod,'|'); if float(length(dates_prod_ut)) != length(quantites_prod_ut) { string msg_erreur <- id_up + ' - Les listes de dates de production et de quantités produites n\'ont pas la même longueur.'; ask myself { do raiseError (s:msg_erreur); }

}

loop i from: 0 to: length(dates_prod_ut) - 1  {
    calendrier_production_up <+ int(dates_prod_ut[i]) :: float(quantites_prod_ut[i]);
}

}

in create up from: shape_file_up with: [id_up::string(read('id')), dates_prod::string(read('Dates_prod')), quantites_prod::string(read('Quant_prod')), types_dechets::[string(read('Biomasse'))]] { list dates_prod_ut <- tokenize(dates_prod,'|'); list quantites_prod_ut <- tokenize(quantites_prod,'|'); if float(length(dates_prod_ut)) != length(quantites_prod_ut) { string msg_erreur <- id_up + ' - Les listes de dates de production et de quantités produites n\'ont pas la même longueur.'; ask myself { do raiseError (s:msg_erreur); }

}

loop i from: 0 to: length(dates_prod_ut) - 1  {
    calendrier_production_up <+ int(dates_prod_ut[i]) :: float(quantites_prod_ut[i]);
}

}

in init { write (' -- ' + time) + ' : start initialisation --' ; write 'Création des UT et de leur(s) camions' ; create ut from: shape_file_ut with: [id_ut::string(read('id')), volume_max::float(read('vol_max')), nj_sejour::int(read('nj_sejour')), type_traitement::string(read('type_ut'))] { create truck number: nb_camions { speed <- rnd(min_speed,max_speed); mon_ut <- myself; objective <- 'resting'; location <- any_location_in(mon_ut); volume_benne <- 7.0; nb_heures_max_journee <- 3.0; }

}

create up from: shape_file_up with: [id_up::string(read('id')), dates_prod::string(read('Dates_prod')), quantites_prod::string(read('Quant_prod')), types_dechets::[string(read('Biomasse'))]] {
    list<string> dates_prod_ut <- tokenize(dates_prod,'|');
    list<string> quantites_prod_ut <- tokenize(quantites_prod,'|');
    if float(length(dates_prod_ut)) != length(quantites_prod_ut)  {
        string msg_erreur <- id_up + ' - Les listes de dates de production et de quantités produites n\'ont pas la même longueur.';
        ask myself  {
            do raiseError (s:msg_erreur);
        }

    }

    loop i from: 0 to: length(dates_prod_ut) - 1  {
        calendrier_production_up <+ int(dates_prod_ut[i]) :: float(quantites_prod_ut[i]);
    }

}

matrix matrix_types_biomasses <- matrix(types_biomasses);
int nrows <- length(column_at(matrix_types_biomasses,0));
loop i from: 1 to: nrows - 1  {
    list<string> ligne <- list<string>(row_at(matrix_types_biomasses,i));
    map<string, list<string>> 
    string type_biomasse_courant <- ligne[0];
    loop j from: 1 to: length(ligne) - 1  {
        string age <- list<string>(row_at(matrix_types_biomasses,0))[j];
        traitements_biomasses_possibles[age] <- tokenize(ligne[j],'|');
    }

    traitements_biomasses_par_age[type_biomasse_courant] <- traitements_biomasses_possibles;
}

write 'Nombre de types de biomasses possibles = ' + length(traitements_biomasses_par_age) ;
write traitements_biomasses_par_age ;
create road from: shape_file_in  {
    create road with: [shape::line(reverse(shape.points))] {
        longueur <- shape.perimeter / 1000;
    }

}

the_graph <- directed(as_edge_graph(road));
the_graph <- with_shortest_path_algorithm(the_graph,shortest_path_algo);
the_graph <- use_cache(the_graph,memorize_shortest_paths);
if save_shortest_paths  {
    write 'Calcul des chemins les plus court (ceci peut prendre du temps)' ;
    matrix<int> ssp <- all_pairs_shortest_path(the_graph);
    save ssp format: 'text' to: shortest_paths_file ;
}else  {
    if load_shortest_paths  {
        the_graph <- load_shortest_paths(the_graph,matrix<string>(file<unknown, string>(shortest_paths_file)));
        write 'Chargement des chemins les plus courts depuis fichier effectué' ;
    }

}

write (' -- ' + time) + ' : end initialisation --' ;

}

in agents up0, Simulation 0, goto_network0

2.

3.

Expected behavior

Tell us what should happen (include all relevant expectations)

Actual behavior

Tell us what happens instead (include relevant information, like logs, snapshots, etc.)

System and version

Which version of GAMA, JDK, OS ... (if necessary, copy Help>Installation Details>Configuration in GAMA)

lesquoyb commented 1 month ago

Hello, to be helped please formulate a proper question, this is just an error stack, we are not (well, not all) wizards.

AlexisDrogoul commented 1 week ago

Closing for lack of better definition.