- if (dot_output == NULL)
- XBT_DEBUG("State %d already visited ! (equal to state %d)",
- new_state->num, state_test->num);
- else
- XBT_DEBUG(
- "State %d already visited ! (equal to state %d (state %d in dot_output))",
- new_state->num, state_test->num, new_state->other_num);
-
- /* Replace the old state with the new one (with a bigger num)
- (when the max number of visited states is reached, the oldest
- one is removed according to its number (= with the min number) */
- xbt_dynar_remove_at(visited_states, cursor, NULL);
- xbt_dynar_insert_at(visited_states, cursor, &new_state);
- XBT_DEBUG("Replace visited state %d with the new visited state %d",
- state_test->num, new_state->num);
+ int cursor = 0;
+ int start = 0;
+ int end = list.size() - 1;
+ while (start <= end) {
+ cursor = (start + end) / 2;
+ int nb_processes_test = list[cursor]->nb_processes;
+ int heap_bytes_used_test = list[cursor]->heap_bytes_used;
+
+ if (nb_processes_test < nb_processes)
+ start = cursor + 1;
+ else if (nb_processes_test > nb_processes)
+ end = cursor - 1;
+ else if (heap_bytes_used_test < heap_bytes_used)
+ start = cursor + 1;
+ else if (heap_bytes_used_test > heap_bytes_used)
+ end = cursor - 1;
+ else {
+ *min = *max = cursor;
+ int previous_cursor = cursor - 1;
+ while (previous_cursor >= 0) {
+ nb_processes_test = list[previous_cursor]->nb_processes;
+ heap_bytes_used_test = list[previous_cursor]->heap_bytes_used;
+ if (nb_processes_test != nb_processes || heap_bytes_used_test != heap_bytes_used)
+ break;
+ *min = previous_cursor;
+ previous_cursor--;
+ }
+ size_t next_cursor = cursor + 1;
+ while (next_cursor < list.size()) {
+ nb_processes_test = list[next_cursor]->nb_processes;
+ heap_bytes_used_test = list[next_cursor]->heap_bytes_used;
+ if (nb_processes_test != nb_processes || heap_bytes_used_test != heap_bytes_used)
+ break;
+ *max = next_cursor;
+ next_cursor++;
+ }
+ return -1;
+ }
+ }
+ return cursor;
+}
+
+static
+bool some_communications_are_not_finished()
+{
+ for (size_t current_process = 1; current_process < MC_smx_get_maxpid(); current_process++) {
+ xbt_dynar_t pattern = xbt_dynar_get_as(
+ incomplete_communications_pattern, current_process, xbt_dynar_t);
+ if (!xbt_dynar_is_empty(pattern)) {
+ XBT_DEBUG("Some communications are not finished, cannot stop the exploration ! State not visited.");
+ return true;
+ }
+ }
+ return false;