Skip to content

Compact Drive agent storage - #578

Draft
vcharraut wants to merge 12 commits into
3.0from
vcha/compact-agents
Draft

Compact Drive agent storage#578
vcharraut wants to merge 12 commits into
3.0from
vcha/compact-agents

Conversation

@vcharraut

@vcharraut vcharraut commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

What

  • Compact simulated agents into contiguous active, moving-log, and static-log groups.
  • Remove active/static index arrays and use direct agent indexing throughout simulation, bindings, rendering, evaluation, and tests.
  • Standardize agent limits on num_max_agents and distinguish controllable num_agents from total num_sim_agents.
  • Simplify SDC state lookup and keep benchmark impairment probabilities explicit.
  • Change init/reset behavior. init now only loads map, and reset handles episode setup (agents' position, goals, traffic light states, etc) (issue Gigaflow reset: agents keep init positions between resamples; resample forces sync resets #540)

Why

Agent bookkeeping used several parallel index arrays and overlapping count fields. Contiguous storage makes ownership and iteration order explicit, reduces indirection, and gives capacity handling one consistent source of truth.

- Updated references from `active_agent_count` and `active_agent_indices` to `num_agents` and direct indexing in various functions to streamline agent management.
- Adjusted logic in rendering and observation functions to accommodate the new agent indexing scheme.
- Modified tests to reflect changes in agent handling, ensuring consistency across the codebase.
- Improved clarity and maintainability by reducing reliance on active agent tracking and simplifying loops and conditions related to agent processing.
@vcharraut
vcharraut marked this pull request as ready for review August 28, 2026 12:38
@vcharraut
vcharraut requested a review from Victorbares August 28, 2026 12:39
@vcharraut vcharraut changed the title Compact agents Compact Drive agent storage and unify capacity handling Aug 28, 2026
@vcharraut vcharraut changed the title Compact Drive agent storage and unify capacity handling Compact Drive agent storage Aug 28, 2026
agent->controller = resolve_agent_controller(env, i, 1, 0);
if (env->goal_source == GOAL_SOURCE_MAP) {
if (!generate_new_goals_from_map(env, agent)) {
fprintf(stderr, "[GIGAFLOW WARNING] -> Failed to generate map goals for agent %d\n", agent->id);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the map_id to this error ?

Comment thread pufferlib/ocean/drive/drive.h Outdated
Comment thread pufferlib/ocean/drive/drive.h Outdated

env->timestep = env->init_step;

begin_episode_rng(env);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think remove begin_episode_rng() makes env->episode_seed not correct anymore after a reset

int womd_track_idx = env->tracks_to_predict[i];
for (int i = 0; i < env->num_agents; i++) {
int agent_idx = i;
int womd_track_idx = env->agents[agent_idx].id;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all active agent, track to predict agent ?

@vcharraut
vcharraut marked this pull request as draft September 3, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants