Buckets:
build-small-hackathon/abs-storage / netlogit /workspace /c4293e67e4ed441a /modal_docs_sim /main /model
| // Generated from design brief: Modal Documentation Overview | |
| // Hypothesis: Modal's serverless architecture enables sub-second cold starts for LLM inference, resulting in lower latency compared to traditional cloud deployments. | |
| // Interaction rules (simplified proximity in step()): Researcher initiates an inference request → Operator triggers Modal to spin up a GPU‑backed container and executes the inference; container count changes → Modal auto‑scales by adding a new container; inference request completes → Hypothesis validated: sub‑second cold start achieved | |
| class Media extends GamifyEngine.Agent { | |
| constructor(id, attributes = {}) { | |
| super(id, { | |
| ...attributes, | |
| shape: "emoji", | |
| emoji: "📰", | |
| size: 7, | |
| x: Math.random() * 800, | |
| y: Math.random() * 600, | |
| vx: (Math.random() - 0.5) * 2, | |
| vy: (Math.random() - 0.5) * 2, | |
| legendKey: "Media", | |
| }); | |
| } | |
| step() { | |
| const speed = this.simulation.getParameterValue("moveSpeed"); | |
| if (this.vx === 0 && this.vy === 0) { | |
| const a = Math.random() * Math.PI * 2; | |
| this.vx = Math.cos(a) * speed; | |
| this.vy = Math.sin(a) * speed; | |
| } | |
| this.x += this.vx; | |
| this.y += this.vy; | |
| if (this.x < 0 || this.x > 800) this.vx *= -1; | |
| if (this.y < 0 || this.y > 600) this.vy *= -1; | |
| this.rotation = Math.atan2(this.vy, this.vx); | |
| } | |
| } | |
| class Researcher extends GamifyEngine.Agent { | |
| constructor(id, attributes = {}) { | |
| super(id, { | |
| ...attributes, | |
| shape: "emoji", | |
| emoji: "🔬", | |
| size: 7, | |
| x: Math.random() * 800, | |
| y: Math.random() * 600, | |
| vx: (Math.random() - 0.5) * 2, | |
| vy: (Math.random() - 0.5) * 2, | |
| legendKey: "Researcher", | |
| }); | |
| } | |
| step() { | |
| const speed = this.simulation.getParameterValue("moveSpeed"); | |
| const zone = this.getEnvironmentAt(this.x, this.y); | |
| let tx = 400, ty = 300; | |
| if (zone) { tx = zone.x + zone.width / 2; ty = zone.y + zone.height / 2; } | |
| const dx = tx - this.x, dy = ty - this.y; | |
| const dist = Math.sqrt(dx * dx + dy * dy) || 1; | |
| this.vx = (dx / dist) * speed; | |
| this.vy = (dy / dist) * speed; | |
| this.x += this.vx; | |
| this.y += this.vy; | |
| this.rotation = Math.atan2(this.vy, this.vx); | |
| } | |
| } | |
| class Developer extends GamifyEngine.Agent { | |
| constructor(id, attributes = {}) { | |
| super(id, { | |
| ...attributes, | |
| shape: "emoji", | |
| emoji: "💻", | |
| size: 7, | |
| x: Math.random() * 800, | |
| y: Math.random() * 600, | |
| vx: (Math.random() - 0.5) * 2, | |
| vy: (Math.random() - 0.5) * 2, | |
| legendKey: "Developer", | |
| }); | |
| } | |
| step() { | |
| const speed = this.simulation.getParameterValue("moveSpeed"); | |
| this.vx += (Math.random() - 0.5) * 0.4; | |
| this.vy += (Math.random() - 0.5) * 0.4; | |
| const mag = Math.sqrt(this.vx * this.vx + this.vy * this.vy) || 1; | |
| if (mag > speed) { this.vx = (this.vx / mag) * speed; this.vy = (this.vy / mag) * speed; } | |
| this.x += this.vx; | |
| this.y += this.vy; | |
| if (this.x < 0) this.x = 800; | |
| if (this.x > 800) this.x = 0; | |
| if (this.y < 0) this.y = 600; | |
| if (this.y > 600) this.y = 0; | |
| this.rotation = Math.atan2(this.vy, this.vx); | |
| } | |
| } | |
| class Analyst extends GamifyEngine.Agent { | |
| constructor(id, attributes = {}) { | |
| super(id, { | |
| ...attributes, | |
| shape: "emoji", | |
| emoji: "📊", | |
| size: 7, | |
| x: Math.random() * 800, | |
| y: Math.random() * 600, | |
| vx: (Math.random() - 0.5) * 2, | |
| vy: (Math.random() - 0.5) * 2, | |
| legendKey: "Analyst", | |
| }); | |
| } | |
| step() { | |
| // static agent | |
| } | |
| } | |
| class Operator extends GamifyEngine.Agent { | |
| constructor(id, attributes = {}) { | |
| super(id, { | |
| ...attributes, | |
| shape: "emoji", | |
| emoji: "⚙️", | |
| size: 7, | |
| x: Math.random() * 800, | |
| y: Math.random() * 600, | |
| vx: (Math.random() - 0.5) * 2, | |
| vy: (Math.random() - 0.5) * 2, | |
| legendKey: "Operator", | |
| }); | |
| } | |
| step() { | |
| const speed = this.simulation.getParameterValue("moveSpeed") * 0.5; | |
| this.vx += (Math.random() - 0.5) * 0.15; | |
| this.vy += (Math.random() - 0.5) * 0.15; | |
| const mag = Math.sqrt(this.vx * this.vx + this.vy * this.vy) || 1; | |
| if (mag > speed) { this.vx = (this.vx / mag) * speed; this.vy = (this.vy / mag) * speed; } | |
| this.x += this.vx; | |
| this.y += this.vy; | |
| if (this.x < 0) this.x = 800; | |
| if (this.x > 800) this.x = 0; | |
| if (this.y < 0) this.y = 600; | |
| if (this.y > 600) this.y = 0; | |
| this.rotation = Math.atan2(this.vy, this.vx); | |
| } | |
| } | |
| function initialize(simulation) { | |
| simulation.clearAgents(); | |
| simulation.environment.addZone({ id: "compute_zone", label: "Serverless Compute", description: "Area where serverless functions execute LLM inference tasks, illustrating sub‑second cold starts and auto‑scaling behavior.", x: 100.0, y: 150.0, width: 400.0, height: 200.0, color: "#4A90E2" }); | |
| simulation.environment.addZone({ id: "latency_zone", label: "Latency Dashboard", description: "Region displaying latency metrics and active container count, visualizing inference time reductions.", x: 500.0, y: 250.0, width: 300.0, height: 200.0, color: "#7ED321" }); | |
| const total = simulation.getParameterValue('agentCount'); | |
| const perType = Math.max(1, Math.floor(total / 5)); | |
| let remaining = total; | |
| simulation.addAgentType(Media, perType, {}); | |
| remaining -= perType; | |
| simulation.addAgentType(Researcher, perType, {}); | |
| remaining -= perType; | |
| simulation.addAgentType(Developer, perType, {}); | |
| remaining -= perType; | |
| simulation.addAgentType(Analyst, perType, {}); | |
| remaining -= perType; | |
| simulation.addAgentType(Operator, Math.max(1, remaining), {}); | |
| simulation.syncZoneLegends(); | |
| } | |
| function setup(simulation) { | |
| simulation.registerParameter({ | |
| id: "agentCount", | |
| label: "Agents", | |
| type: "number", | |
| defaultValue: 50, | |
| min: 5, | |
| max: 300, | |
| step: 5, | |
| applyMode: "reinit-required", | |
| }); | |
| simulation.registerParameter({ | |
| id: "moveSpeed", | |
| label: "Move speed", | |
| type: "number", | |
| defaultValue: 1.5, | |
| min: 0.2, | |
| max: 5.0, | |
| step: 0.1, | |
| applyMode: "real-time", | |
| }); | |
| simulation.registerLegendItem({ kind: "agent", name: "Media", agentType: "Media", shape: "emoji", emoji: "📰", description: "monitor public sentiment and disseminate information" }); | |
| simulation.registerLegendItem({ kind: "agent", name: "Researcher", agentType: "Researcher", shape: "emoji", emoji: "🔬", description: "collect data for model training and evaluation" }); | |
| simulation.registerLegendItem({ kind: "agent", name: "Developer", agentType: "Developer", shape: "emoji", emoji: "💻", description: "deploy and test inference workloads on Modal" }); | |
| simulation.registerLegendItem({ kind: "agent", name: "Analyst", agentType: "Analyst", shape: "emoji", emoji: "📊", description: "observe and report on inference latency and container metrics" }); | |
| simulation.registerLegendItem({ kind: "agent", name: "Operator", agentType: "Operator", shape: "emoji", emoji: "⚙️", description: "manage auto-scaling and resource allocation" }); | |
| simulation.onTick(() => { | |
| simulation.recordTypeCounts(); | |
| simulation.recordStatistic("agent_count", simulation.agents.length); | |
| simulation.recordZonePopulations(); | |
| simulation.recordStatistic("evacuation_completion_tick", simulation.agents.length); | |
| simulation.recordStatistic("all_clear_tick", simulation.agents.length); | |
| }); | |
| initialize(simulation); | |
| } | |
Xet Storage Details
- Size:
- 7.41 kB
- Xet hash:
- 4e71a06b39f7e5ba3b715bc8cb4f5cfed17dceb50070b53bb1cddd85e785ae75
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.