Fix: Update requirements for simulations executions - #6
Open
Octávio Nascimento (OctavioNascimento) wants to merge 18 commits into
Open
Fix: Update requirements for simulations executions#6Octávio Nascimento (OctavioNascimento) wants to merge 18 commits into
Octávio Nascimento (OctavioNascimento) wants to merge 18 commits into
Conversation
Fix: Update requirements and README for Python 3.12 compatibility
Author
|
@microsoft-github-policy-service agree |
- Implemented SatelliteMEC with RAM/Battery constraints. - Added Task class with data size and deadlines. - Implemented LLM Scheduler using REST API to bypass SSL/Proxy. - Refactored init logic to use **kwargs. - Added heterogeneity test scenario.
- Replaced deprecated/unavailable model names with 'gemini-2.0-flash' to fix 404/429 errors. - Confirmed Chain-of-Thought (CoT) prompting strategy success: LLM correctly avoids OOM errors by prioritizing RAM constraints over CPU speed. - Achieved 100% task completion rate in heterogeneity test scenario (vs. ~40% with baseline).
- Validated LLM logic for Data Sovereignty (USA vs Brazil tasks). - Validated Energy constraints (Sat 101 dies due to critical battery usage). - Validated RAM protection logic. - Achieved realistic failure mode (Sat 101 depletion) proving simulation fidelity.
- Updated logging logic to overwrite 'sim_run_latest.jsonl' per execution. - Observed 80% rejection rate due to API 404 errors triggering failsafe mode (tasks rejected instead of randomly assigned). - Validated that without LLM response, the system defaults to 'No Route' to preserve satellite safety.
- Implemented 'MECOrchestrator' class to manage stochastic task generation (Poisson) and resource monitoring. - Integrated 'GeminiBrain' adapter (gemini-2.0-flash) for cognitive decision making. - Modified 'ManagerParallel.py' to inject AI logic directly into the main simulation loop, enabling synchronized execution with the physics engine. - Implemented attribute injection (Monkey Patching) to add MEC capabilities (RAM, Battery, Region) to legacy Satellite nodes. - Validated system integration: AI decisions successfully interspersed with NMA (Network Management Algorithm) execution logs.
2025 updates
… BASELINE Refactors the simulation to support four interchangeable cognitive engines selectable via --engine CLI flag (BASELINE, DRL, SLM, LLM), all receiving identical task sequences via random.seed(0) for fair scientific comparison. Schedulers: - BASELINE: greedy heuristic by region + battery/RAM - DRL: Q-value stub (0.6×battery + 0.4×RAM), intentionally ignores semantic anomalies - LLM: gemini-3.1-flash-lite-preview via Gemini API, synchronous per-task orchestration - SLM: gemma-3n-e4b-it via Gemini API, async NPU state machine (50ms simulated latency), sliding-window rate limiter (14 RPM), regex JSON parser for Gemma text output MECOrchestrator (ai_logic.py): - Poisson task arrival (λ=4/min), three regions (USA/BRAZIL/EUROPE via nodeID%3) - Semantic anomalies injected at 10% rate: restricao_gdpr_europa, restricao_soberania_brasil, falha_hardware_camera_esq - Per-task metrics: latency_ms, joules_cost, semantic_compliant - Exports CSV + JSON summary to logs/ after each run Infrastructure: - Added SAT nodeID=15 (USA region) to constellation, completing the three-region topology - Removed legacy main_simulation.py and ai_adapter.py - Old plot/log artifacts replaced by structured CSV/JSON metrics Baseline experiment results included in logs/ (seed=0, 20min simulation, 69 tasks, 8 anomalies). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_quality DRL engine rewritten as a genuine online Q-learning agent (tabular, TD(0)): - State space: (region × link_quality_bin × ram_ok × has_anomaly) — 36 states - Actions: PREFER_LINK | PREFER_RAM | PREFER_BALANCED | DROP - ε-greedy exploration: ε=0.30 → 0.05 over 200 decisions (linear decay) - Immediate reward: +1.0 routed (+0.1×lq bonus), -0.5 forced drop, -1.0 voluntary drop - TD(0) update: Q[s,a] += α·(r − Q[s,a]), α=0.10 - Prints Q-table and convergence stats at end of simulation Battery replaced by link_quality across all engines and ai_logic: - Modeled as orbital pass sinusoid: 50 + 50·sin(2π·(t+phase)/600s) - Three satellites with evenly-spaced phases (0s, 200s, 400s) — distinct profiles - Threshold: link_quality < 20% → satellite excluded from routing - Removed all battery drain, battery init, safe_mode, and alive fields Architecture fixes: - RAM recovery: tasks release RAM after TASK_DURATION_S=60s (prevents exhaustion) - SLM latency_ms now reports NPU_LATENCY_MS (50ms simulated), not API wall-clock - LLM scheduler: added sliding window rate limiter (14 RPM), semantic anomaly in prompt, link_quality routing rules, timeout 15s→30s, parse error logging - LLM pre-filter uses link_quality threshold instead of alive flag Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Physics layer overhaul across all 4 engines (BASELINE, DRL, SLM, LLM):
## ISL ideal model (remove link_quality)
- Removed sinusoidal link_quality (satellite-to-ground pass model) entirely
- Premise: ISL always available between LEO constellation nodes; if a satellite
cannot transfer a task it retries — loss is not modeled to keep focus on MEC
constraints
- link_quality field removed from fleet dict; no scheduler filters on it
## Battery / eclipse orbital model
- LEO satellites spend ~35% of each orbit in eclipse (no solar power)
- Model: sin(2π(t + phase) / 5400) ≤ -0.10 → eclipse (period = 90 min)
- 3 satellites with distinct orbital phases (0s, 1800s, 3600s) to simulate
different positions in the same orbit
- Different hardware capacities: 75Wh (BRAZIL), 50Wh (EUROPE), 100Wh (USA)
- SOC dynamics per 5s step:
solar: +0.083%/step (+1%/min charging)
eclipse: -0.040%/step (-0.48%/min housekeeping drain)
task: -2.0% SOC per routed task (MEC processing energy cost)
- Safety threshold: battery_pct ≤ 20% → satellite refuses new tasks
- Fleet dict now exposes battery_pct and solar_charging fields
## All schedulers updated
- baseline: filter battery_pct > 20%; score by (battery_pct, ram_free) desc
- drl: state encoding replaces lq_bin with bat_bin (low/mid/high); reward
uses battery bonus (+0.1×bat/100); action PREFER_LINK→PREFER_BATTERY
- slm/llm: prompt fleet lines show battery_pct + solar_charging; Rule 4
updated to "prefer highest battery_pct" instead of highest link_quality
- slm/llm: _resolve_action filters battery_pct > 20 instead of link_quality
- llm: pre-filter in decide() uses battery_pct instead of link_quality
- slm/llm: 429 retries now wait 30s×attempt before continuing (backoff)
## RAM visibility
- save_metrics() now exports avg_ram_utilization_pct and per-satellite
final battery SOC to the summary JSON
## Validated results (seed=0)
- BASELINE: 100% success, SAT-2 (50Wh) reached 21.8% SOC — near threshold
- DRL: Q-learning active, epsilon decaying, battery-aware action selection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
## DRL — Gymnasium + SB3 DQN (replaces Q-table) - New Gym environment: src/schedulers/drl_gym_env.py (NTNMECEnv) - Obs space: 13 floats (task region one-hot, has_anomaly, 3×sat features) - Action space: Discrete(4) — route SAT-1/2/15 or DROP - Reward: +1.0+0.1*(bat/100) on success, -2.0 invalid, -0.5 forced drop, -1.0 voluntary drop - Training script: scripts/train_drl.py (DQN, 50k steps, gamma=0.0, MLP 64×64) - Trained models saved: models/best_model.zip, models/drl_agent.zip - drl_scheduler.py rewritten: loads SB3 model, same decide() interface - Scientific invariant preserved: DRL sees has_anomaly=1 but not anomaly type ## Metrics — effective_success_rate - New field in save_metrics() and print_stats(): effective_success_rate = (routed AND semantically correct) / total correct_drop_count = drops that were semantically valid (e.g. hardware failure) - Resolves apparent paradox where BASELINE had higher success_rate than SLM: BASELINE routes everything (100% throughput) including wrong-region routings. Effective success: BASELINE 91.3% < SLM 92.8% (SLM never makes wrong decisions). ## SLM — robustness improvements for Gemma 4 - HTTP 500 retry with backoff (10s×attempt), 4 total attempts - _parse_gemma_json(): extracts key-value pairs even when model outputs chain-of-thought tokens between JSON fields (Gemma 4 behavior) - maxOutputTokens: 128 → 1024 (Gemma 4 echoes full prompt before JSON) - Prompt restored to original structured format (more reliable than compact) ## DRL results (SB3-DQN, seed=0) - success_rate: 100% (65/65), effective_success_rate: 92.3% - avg_latency_ms: ~0ms, joules/decision: 0.005J - anomaly_compliance: 28.6% (expected — black-box for anomaly type) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- LLM (gemini-3.1-flash-lite): 95.7% effective_success, 100% anomaly compliance
- SLM (Gemma 4 26B): 78.3% effective_success, 75% anomaly compliance (API prototype limitation)
- LLM prompt fix: explicit GDPR cross-region routing rule ('Ignore task origin region')
- RPM_LIMIT=10, timeout=60s, removed thinkingConfig for gemini-3.1-flash-lite
- Relatorio_ED2_241327.docx: KPI table updated with all 4-engine real results
- scripts/update_report.py: automation script to rebuild KPI table from JSON logs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Sec 2.1: rewrite from 'Q-tabular fallback' to 'SB3 DQN success (offline training + online inference)' - Sec 3.4.2: replace Q-table state/action description with SB3 DQN architecture - Sec 3.4.4: Gemini 2.5 Flash → Gemini 3.1 Flash Lite, 10 RPM, ~6s latency - Sec 5 intro/footnotes: remove 'run pending' notes, simplify DRL seed footnote - Sec 5.3: update DRL to 92.3%/28.6%, SLM to 75.0%/78.3%, add LLM 100%/95.7% - Sec 6.1/6.2: update DRL bullet and trade-off with real SB3 DQN numbers - scripts/patch_docx.py: reusable script for all paragraph-level text patches Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ompliance - src/schedulers/slm_scheduler.py: API Gemma retorna pensamento (thought=true) e resposta final em parts separadas; código lia só parts[0] (quase sempre o pensamento), causando ~40% de falsas falhas de parsing. Corrigido para usar as parts com thought=false. Drops por infraestrutura caem de 14 para 2/69. - src/schedulers/drl_gym_env.py: reward shaping com subtipo de anomalia oculto (nunca exposto na observação) durante o treino offline — DRL aprende a melhor estratégia "cega" possível. anomaly_compliance sobe de 25% para 37.5% (teto teórico de informação: só falha de hardware é identificável só com o bit has_anomaly), superando o BASELINE nas duas métricas de qualidade. - src/schedulers/drl_scheduler.py: corrige random.seed(0) após DQN.load() (SB3 reseedava o RNG global, deslocando a sequência de chegadas Poisson; DRL processava 65 tarefas em vez de 69 como os demais engines). - src/ai_logic.py: BATTERY_SAFETY_PCT agora passado explicitamente para scheduler.decide(); comentário do modelo de eclipse corrigido (~53%, não 35%). - Relatorio_ED2_241327.docx: reescrita de cenário/motivação, métricas de compliance semântica como KPI principal (não throughput bruto), e todos os números finais dos 4 engines após as correções acima. - scripts/rewrite_report_v2.py: script reusável da reescrita do relatório. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.