Revert openenv.yaml, Dockerfile, README, requirements to original
Browse filesFiles changed (4)
- Dockerfile+17-5
- README.md+89-85
- openenv.yaml+6-64
- requirements.txt+9-2
1234567891011121314FROM python:3.11-slimWORKDIR /appCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .ENV API_BASE_URL="https://router.huggingface.co/v1"ENV MODEL_NAME="mistralai/Mistral-7B-Instruct-v0.1"ENV HF_TOKEN=""CMD ["python", "inference.py"]1234567891011121314151617181920212223242526# Use Python latest stable slim image for a small footprintFROM python:3.11-slim# Set the working directory in the containerWORKDIR /app# Copy the requirements file first to leverage Docker build cacheCOPY requirements.txt .# Install system dependencies and Python packagesRUN apt-get update && apt-get install -y --no-install-recommends \build-essential \&& rm -rf /var/lib/apt/lists/* \&& pip install --no-cache-dir -r requirements.txt# Copy all project files into the containerCOPY . .# Expose port 5000 for the Flask applicationEXPOSE 5000# Set default Flask environment variableENV FLASK_APP=app.py# Run the Flask applicationCMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485# SentinelRL — Adaptive Sensor Allocation EnvironmentA real-world OpenEnv environment where an AI agent allocates limited surveillance sensors (satellites, drones, radars) to dynamic high-priority targets under resource constraints.## Environment DescriptionAt each timestep, targets appear with different priority levels (1=low, 2=medium, 3=high). The agent must assign available sensors to active targets to maximize coverage. Sensors can fail, targets can move, and high-priority threats must not be missed.## Observation Space```json{"sensors": [{ "id": "S1", "type": "satellite", "range": 350.0, "available": true }],"targets": [{ "id": "T0_1", "priority": 3, "active": true }],"timestep": 0}```## Action Space```json{ "sensor_id": "S1", "target_id": "T0_1" }```## Reward Function| Event | Reward ||---|---|| Track priority-3 target | +10.0 || Track priority-2 target | +5.0 || Track priority-1 target | +2.0 || Miss a high-priority target | -10.0 || No action / idle | -2.0 |## Tasks| Task | Sensors | Targets | Steps | Difficulty ||---|---|---|---|---|| Easy | 2 | 3 static | 20 | No failures, no movement || Medium | 3 | 5 dynamic | 40 | 5% failure prob, targets move || Hard | 4 | 8 dynamic | 60 | 15% failure prob, high-risk zones |## Setup```bashpip install -r requirements.txtpython inference.py```## Docker```bashdocker build -t sentinelrl .docker run -e HF_TOKEN=your_token sentinelrl```## Environment Variables| Variable | Description ||---|---|| `HF_TOKEN` | HuggingFace API token || `API_BASE_URL` | LLM API endpoint (default: `https://router.huggingface.co/v1`) || `MODEL_NAME` | Model identifier (default: `mistralai/Mistral-7B-Instruct-v0.1`) |## Project Structure```sentinel_rl/├── env/│ ├── environment.py # SentinelEnv: reset(), step(), state()│ ├── models.py # Typed Pydantic models│ ├── dynamics.py # Target spawning and movement│ └── reward.py # Reward computation├── tasks/│ ├── easy_task.py # Static scenario│ ├── medium_task.py # Dynamic scenario│ ├── hard_task.py # High-risk scenario│ └── grader.py # Episode scoring (0.0–1.0)├── agent/│ └── policy.py # Greedy baseline policy├── inference.py # LLM agent inference script├── openenv.yaml # OpenEnv spec├── Dockerfile└── requirements.txt```1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889# AI Sensor Allocation System for Defense Surveillance## 🛡️ Project DescriptionThe **AI Sensor Allocation System** is an advanced, reinforcement learning-based platform designed to optimally assign limited surveillance sensors (such as satellites, drones, and radars) to high-priority targets, including missile activity, border movements, and airspace intrusions.By leveraging a custom Gym-style RL environment and real-time data streaming, the system maximizes threat coverage and minimizes blind spots to ensure maximum situational awareness.## ✨ Features- **Smart Sensor Allocation**: Uses Reinforcement Learning to dynamically allocate limited resources.- **Custom RL Environment**: Built with Gymnasium to simulate defense scenarios.- **Real-Time Dashboard**: React-based frontend for visualizing threat levels and sensor deployments.- **Secure Authentication**: JWT-based access control for API endpoints.- **REST API**: Fully-featured backend for manual sensor overrides and integrations.## 🛠️ Tech Stack- **Backend**: Python, Flask, Flask-RESTful- **Frontend**: React.js- **Machine Learning**: scikit-learn, Gymnasium (RL environment)- **Data Handling**: pandas, numpy- **Authentication**: JWT (JSON Web Tokens)- **Database**: SQLite (via SQLAlchemy)---## 🚀 Installation & Setup### Option 1: Using Docker (Recommended)This is the fastest way to get the system running with all dependencies pre-configured.1. Build the Docker image:```bashdocker build -t ai-sensor-system .```2. Run the container:```bashdocker run -p 5000:5000 ai-sensor-system```3. The API will be available at `http://localhost:5000`.### Option 2: Local Setup (Development)1. Clone the repository and navigate into the project directory.2. Create and activate a virtual environment:```bashpython -m venv venvsource venv/bin/activate # On Windows use: venv\Scripts\activate```3. Install backend dependencies:```bashpip install -r requirements.txt```4. Set up the environment variables by editing `openenv.yaml` or creating a `.env` file.5. Initialize the SQLite database:```bashflask db upgrade```6. Start the Flask Backend:```bashflask run --port=5000```7. In a separate terminal, navigate to the frontend directory and start the React app:```bashcd frontendnpm installnpm start```---## 📡 Example API Endpoints| Endpoint | Method | Description | Auth Required ||----------|--------|-------------|---------------|| `/api/auth/login` | POST | Authenticate and retrieve JWT token. | No || `/api/sensors/status` | GET | Retrieve the current status of all sensors. | Yes || `/api/targets/active` | GET | List all currently tracked high-priority targets. | Yes || `/api/allocation/optimize` | POST | Trigger the RL model to re-allocate sensors based on new threats. | Yes || `/api/allocation/manual` | POST | Manually override an AI allocation decision. | Yes |---## 🔮 Future Improvements- **Multi-Agent RL**: Transition from single-agent model to cooperative multi-agent reinforcement learning (MARL) for swarming drones.- **Live Satellite Feed Integration**: Consume mock/real satellite API data streams.- **PostgreSQL Migration**: Move from SQLite to PostgreSQL for production scalability.- **Mobile Application**: Extend the dashboard to a mobile app for field commanders.---*Created as a final-year AI/ML capstone project / hackathon submission.*
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364name: SentinelRLversion: "1.0.0"description: >Adaptive sensor allocation environment for dynamic target monitoring.An agent must assign limited sensors (satellites, drones, radars) tohigh-priority targets under resource constraints and sensor failures.tasks:- id: easydescription: Static targets, no sensor failures, 20 stepsmodule: tasks.easy_taskentry: get_easy_env- id: mediumdescription: Dynamic targets, moderate failures, 40 stepsmodule: tasks.medium_taskentry: get_medium_env- id: harddescription: High-risk zones, frequent failures, conflicting priorities, 60 stepsmodule: tasks.hard_taskentry: get_hard_envobservation_space:type: objectproperties:sensors:type: arrayitems:type: objectproperties:id: { type: string }type: { type: string, enum: [satellite, drone, radar] }range: { type: number }available: { type: boolean }targets:type: arrayitems:type: objectproperties:id: { type: string }priority: { type: integer, minimum: 1, maximum: 3 }active: { type: boolean }timestep: { type: integer }action_space:type: objectproperties:sensor_id: { type: string }target_id: { type: string }required: [sensor_id, target_id]reward:type: floatdescription: >+10 for tracking priority-3 target, +5 for priority-2, +2 for priority-1.-10 penalty per unassigned high-priority target. -2 idle penalty.episode:max_steps: 60termination: max_steps_reached or no_active_targetsenv:API_BASE_URL: "https://router.huggingface.co/v1"MODEL_NAME: "mistralai/Mistral-7B-Instruct-v0.1"HF_TOKEN: ""123456FLASK_ENV: "production"SECRET_KEY: "super-secret-defense-key-change-in-prod"JWT_SECRET_KEY: "jwt-defense-secret-key-change-in-prod"DATABASE_URL: "sqlite:///defense_surveillance.db"MODEL_PATH: "/app/models/sensor_rl_model.pkl"API_KEYS: "mock_key_alpha,mock_key_bravo"
1234pydantic>=2.0.0openai>=1.0.0numpy>=1.26.4gymnasium>=0.29.11234567891011Flask>=3.0.2flask-cors>=4.0.0flask-jwt-extended>=4.6.0pandas>=2.2.0numpy>=1.26.4scikit-learn>=1.4.0gymnasium>=0.29.1python-dotenv>=1.0.1requests>=2.31.0PyYAML>=6.0.1gunicorn>=21.2.0
Dockerfile+17-5
README.md+89-85
openenv.yaml+6-64
requirements.txt+9-2