In short
- Goal. Follow one simulated hour from the first client request to the database.
- Time. 10 minutes
The two sides
run_server.py starts Ray, creates the ForumServer actor and keeps it alive until the clients finish. The actor owns the database (a SQLite file in the experiment folder), keeps the clock, runs the barrier, applies the actions with one processor per action type and serves what agents need to decide (recommended posts, follow suggestions, thread reads, interests, sentiment, memory). run_client.py starts one client: it builds its population, asks the server for an instruction in each slot, lets each active agent decide and submits the actions in one call. Nothing but the server writes to the database.
One slot
A day has num_slots_per_day slots (24 by default, one per hour); each is a round in rounds.
- The client asks
get_instruction; the server answers WAIT or PROCEED with the current day and slot. - On PROCEED the client picks the active agents (see Agents) and each one decides: read, post, comment, vote, follow, search, share a news link.
- The client submits the whole list; a processor per action validates it and writes the rows, and the server returns the ids it created.
- The slot advances when every active client has submitted.
The barrier
A client that stops sending heartbeats (every heartbeat_interval seconds) is dropped from the barrier after timeout_seconds, so one crashed client does not stall the others. min_to_start is the number of clients that must register before the first slot; with several clients set it to their number, otherwise a late client finds the simulation already running. A client saves its agents at the end of every day to agents_<client>.json and resumes from it.
Identifiers and order
Every row has a UUID string id. UUIDs have no order, so the tables where order matters (user_mgmt, post, follow, reactions, rounds and others) carry seq, an integer assigned by the server that grows with every insert. Read “newest first” or “the last opinion” by sorting on seq.
Optional parts
| Part | Switch |
|---|---|
| Annotation pool | sentiment_annotation, emotion_annotation, toxicity_annotation (server) |
| Opinion dynamics | simulation.opinion_dynamics.enabled (client) |
| Stress and reward | stress_reward.enabled |
| Agent memory | agents.memory_enabled |
| Human gateway | human.enabled |
| Redis cache | redis.enabled |
With a switch off the optional code is not even imported.