๐Ÿด 5 Dining Philosophers - All Fed Successfully

Generated by GenServerVirtualTime โ€ข Mermaid Flowchart

๐Ÿ“ˆ Simulation Summary

Virtual Time
600ms
Real Time
22ms
Speedup
27.3x
Termination
โšก Early

๐Ÿ“Š Actor Topology

flowchart TB philosopher_0("philosopher_0
๐Ÿ“ค Sent: 55
๐Ÿ“ฅ Recv: 40") philosopher_4("philosopher_4
๐Ÿ“ค Sent: 36
๐Ÿ“ฅ Recv: 31") fork_0("fork_0
๐Ÿ“ค Sent: 17
๐Ÿ“ฅ Recv: 28") fork_4("fork_4
๐Ÿ“ค Sent: 24
๐Ÿ“ฅ Recv: 34") philosopher_1("philosopher_1
๐Ÿ“ค Sent: 46
๐Ÿ“ฅ Recv: 36") philosopher_2("philosopher_2
๐Ÿ“ค Sent: 45
๐Ÿ“ฅ Recv: 35") philosopher_3("philosopher_3
๐Ÿ“ค Sent: 45
๐Ÿ“ฅ Recv: 35") fork_1("fork_1
๐Ÿ“ค Sent: 16
๐Ÿ“ฅ Recv: 26") fork_2("fork_2
๐Ÿ“ค Sent: 24
๐Ÿ“ฅ Recv: 34") fork_3("fork_3
๐Ÿ“ค Sent: 11
๐Ÿ“ฅ Recv: 20") fork_0 -->|10ร— #123;:fork_granted, :fork_0#125;
18.3/s| philosopher_0 fork_0 -->|3ร— #123;:fork_denied, :fork_0#125;
6.7/s| philosopher_4 fork_1 -->|5ร— #123;:fork_denied, :fork_1#125;
16.7/s| philosopher_0 fork_1 -->|#123;:fork_granted, :fork_1#125;
8.3/s| philosopher_1 fork_2 -->|6ร— #123;:fork_denied, :fork_2#125;
18.3/s| philosopher_1 fork_2 -->|6ร— #123;:fork_denied, :fork_2#125;
18.3/s| philosopher_2 fork_3 -->|#123;:fork_granted, :fork_3#125;
8.3/s| philosopher_2 fork_3 -->|4ร— #123;:fork_granted, :fork_3#125;
10/s| philosopher_3 fork_4 -->|6ร— #123;:fork_granted, :fork_4#125;
18.3/s| philosopher_3 fork_4 -->|7ร— #123;:fork_denied, :fork_4#125;
18.3/s| philosopher_4 philosopher_0 -->|11ร— #123;:request_fork, :philosopher_0#125;
35/s| fork_0 philosopher_0 -->|10ร— #123;:request_fork, :philosopher_0#125;
25/s| fork_1 philosopher_0 -->|#123;:start_hungry, :fork_0, :fork_1#125;
every 50ms| philosopher_0 philosopher_1 -->|5ร— #123;:release_fork, :philosopher_1#125;
16.7/s| fork_1 philosopher_1 -->|11ร— #123;:request_fork, :philosopher_1#125;
26.7/s| fork_2 philosopher_1 -->|#123;:start_hungry, :fork_2, :fork_1#125;
every 50ms| philosopher_1 philosopher_2 -->|11ร— #123;:request_fork, :philosopher_2#125;
26.7/s| fork_2 philosopher_2 -->|5ร— #123;:release_fork, :philosopher_2#125;
16.7/s| fork_3 philosopher_2 -->|#123;:start_hungry, :fork_2, :fork_3#125;
every 50ms| philosopher_2 philosopher_3 -->|6ร— #123;:request_fork, :philosopher_3#125;
16.7/s| fork_3 philosopher_3 -->|11ร— #123;:request_fork, :philosopher_3#125;
28.3/s| fork_4 philosopher_3 -->|#123;:start_hungry, :fork_4, :fork_3#125;
every 50ms| philosopher_3 philosopher_4 -->|4ร— #123;:request_fork, :philosopher_4#125;
8.3/s| fork_0 philosopher_4 -->|11ร— #123;:request_fork, :philosopher_4#125;
25/s| fork_4 philosopher_4 -->|#123;:start_hungry, :fork_4, :fork_0#125;
every 50ms| philosopher_4 style philosopher_0 fill:#fff3e0,stroke:#f57c00,stroke-width:3px style philosopher_4 fill:#fff3e0,stroke:#f57c00,stroke-width:3px style fork_0 fill:#e8f5e9,stroke:#388e3c style fork_4 fill:#fff3e0,stroke:#f57c00,stroke-width:3px style philosopher_1 fill:#fff3e0,stroke:#f57c00,stroke-width:3px style philosopher_2 fill:#fff3e0,stroke:#f57c00,stroke-width:3px style philosopher_3 fill:#fff3e0,stroke:#f57c00,stroke-width:3px style fork_1 fill:#e8f5e9,stroke:#388e3c style fork_2 fill:#fff3e0,stroke:#f57c00,stroke-width:3px style fork_3 fill:#e8f5e9,stroke:#388e3c

Node Shapes (Actor Type)

flowchart TD legend_processor("Processor
(send & receive)") legend_sink["Sink
(receives only)"] style legend_processor fill:#ffffff,stroke:#666666,stroke-width:2px style legend_sink fill:#ffffff,stroke:#666666,stroke-width:2px

Node Colors (Activity Level)

flowchart LR activity_0["๐ŸŸข Medium Activity (10-50 msgs)"] activity_1["๐ŸŸ  High Activity (>50 msgs)"] style activity_0 fill:#e8f5e9,stroke:#388e3c style activity_1 fill:#fff3e0,stroke:#f57c00,stroke-width:3px

๐Ÿ“‰ Detailed Statistics

Actor Sent Received Send Rate Receive Rate Activity
philosopher_0 55 40 91.67 msg/s 66.67 msg/s 95 total
philosopher_4 36 31 60.0 msg/s 51.67 msg/s 67 total
fork_0 17 28 28.33 msg/s 46.67 msg/s 45 total
fork_4 24 34 40.0 msg/s 56.67 msg/s 58 total
philosopher_1 46 36 76.67 msg/s 60.0 msg/s 82 total
philosopher_2 45 35 75.0 msg/s 58.33 msg/s 80 total
philosopher_3 45 35 75.0 msg/s 58.33 msg/s 80 total
fork_1 16 26 26.67 msg/s 43.33 msg/s 42 total
fork_2 24 34 40.0 msg/s 56.67 msg/s 58 total
fork_3 11 20 18.33 msg/s 33.33 msg/s 31 total
Summary: Total messages: 638 โ€ข Duration: 600ms โ€ข Actors: 10

๐Ÿ’ป Model Source Code

This is the Elixir code that defines the actor simulation model:

simulation =
  DiningPhilosophers.create_simulation(
    num_philosophers: 5,
    think_time: 50,
    eat_time: 25,
    trace: true
  )
  |> ActorSimulation.run(
    max_duration: 120_000,
    terminate_when: fn sim ->
      # Check if all philosophers have eaten
      trace = sim.trace
      philosophers_who_ate =
        Enum.filter(0..4, fn i ->
          name = :"philosopher_#{i}"
          Enum.any?(trace, fn event ->
            event.from == name and event.to == name and
              event.message == {:mumble, "I'm full!"}
          end)
        end)
      length(philosophers_who_ate) == 5
    end
  )