//reflex of setting CP as target
reflex time_to_charge when: SoC < dSoC and going_home != true {
searching_for_cp <- true ;
let tobe_removed <- [] ;
loop thecp over: remaining_cps {
if condition: ((thecp as cp).occupied=true) {
add item: thecp to: tobe_removed ;
}
}
loop thecp over:tobe_removed {
remove item:(thecp as cp) from: remaining_cps ;
remove item:(thecp as cp) from: distances_cps ;
}
next_cp_index <- distances_cps index_of min(distances_cps);
destination_cp <- remaining_cps[next_cp_index];
the_target_cp <- point(destination_cp) ;
}
2 occurrences in 2 agents at cycle 26: Java error: index out of bounds
in destination_cp <- remaining_cps[next_cp_index];
IndexOutOfBoundsException: Index: 41, Size: 41
java.util.ArrayList.rangeCheck(ArrayList.java:657)
java.util.ArrayList.get(ArrayList.java:433)
msi.gama.util.IList.get(IList.java:181)
msi.gama.util.GamaList.getFromIndicesList(GamaList.java:99)
gaml.additions.GamlAdditions.lambda$938(GamlAdditions.java:995)
msi.gaml.expressions.BinaryOperator._value(BinaryOperator.java:77)
msi.gaml.expressions.AbstractExpression.value(AbstractExpression.java:70)
when applying the internal_at operator on [cp(0),cp(1),cp(2),cp(3),cp(4),cp(5),cp(8),cp(9),cp(10),cp(11),cp(12),cp(13),cp(14),cp(15),cp(16),cp(17),cp(18),cp(19),cp(20),cp(21),cp(22),cp(23),cp(24),cp(25),cp(26),cp(27),cp(28),cp(29),cp(30),cp(31),cp(32),cp(33),cp(34),cp(35),cp(36),cp(37),cp(38),cp(39),cp(40),cp(41),cp(42)] and [41]
in destination_cp <- remaining_cps[next_cp_index];
in reflex time_to_charge when: (SoC < dSoC) and (going_home != true) {
searching_for_cp <- true;
unknown tobe_removed <- [];
loop thecp over: remaining_cps {
if cp(thecp).occupied = true {
tobe_removed <+ thecp;
}
}
loop thecp over: tobe_removed {
remaining_cps >- cp(thecp);
distances_cps >- cp(thecp);
}
next_cp_index <- distances_cps index_of min(distances_cps);
destination_cp <- remaining_cps[next_cp_index];
the_target_cp <- point(destination_cp);
}
in agents EVagent21, Simulation 0
loop thecp from: 0 to:length(remaining_cps)-1 {
if condition: ((thecp as cp).occupied=true) {
add item: thecp to: tobe_removed ;
}
}
loop thecp from: 0 to:length(tobe_removed)-1 {
remove item:(thecp as cp) from: remaining_cps ;
remove item:(thecp as cp) from: distances_cps ;
}
reflex cp_list { let thecp type:cp ; loop thecp over: remaining_cps { if ((thecp as cp).occupied=true) and ((thecp as cp) in tobe_removed) != true { add (thecp as cp) to: tobe_removed ; } } let thecpi type:int ; loop thecp over: tobe_removed { remove thecp from: remaining_cps ; thecpi <- (remaining_cps index_of thecp) ; remove index: [thecpi] from: distances_cps ; } }
loop thecp over:tobe_removed {
int ind <- remaining_cps index_of thecp;
remove index: ind from: distances_cps;
remove thecp from: remaining_cps ;
}
Youcef
reflex cp_list {
let thecp type:cp ;
loop thecp over: remaining_cps {
if ((thecp as cp).occupied=true) and ((thecp as cp) in tobe_removed) != true {
add (thecp as cp) to: tobe_removed ;
}
}
loop thecp over: tobe_removed {
int ind <- remaining_cps index_of thecp ;
if ind >= 0 {
remove index: ind from: distances_cps ;
}
remove thecp from: remaining_cps ;
} }
reflex cp_list {
tobe_removed <- [];
loop thecp over: remaining_cps {
if (thecp.occupied=true) and (thecp in tobe_removed != true ) {
add thecp to: tobe_removed ;
}
}
loop elt over: tobe_removed {
int ind <- remaining_cps index_of elt ;
remove index: ind from: distances_cps ;
remove elt from: remaining_cps ;