Samudrapath is a ship-routing toolkit and web application for route optimization in the Indian Ocean. It produces multiple route alternatives (fuel-efficient, safe, and fastest) using a combination of grid-based pathfinding (Theta*) to seed candidate routes and a multi-objective Genetic Algorithm (NSGA-II) to evolve a Pareto set of optimized routes while accounting for weather, waves, pirate-risk zones, ecological areas, and ship parameters.
- Quick start
- What this project does
- How it works (high level)
- Project layout
- Requirements
- Entire Algorithm notebook —
entire_algorithm.ipynb - Setup & run — Backend
- Setup & run — Frontend
- Usage (API + UI)
- Configuration & input formats
- Outputs & visualization
- Clone the repository.
- Start the backend (Flask) and then the frontend (npm).
- Open the frontend UI (usually
http://localhost:3000) and request routes by selecting start / goal and ship parameters.
-
Generates candidate maritime routes between two points.
-
Optimizes routes simultaneously for:
- fuel consumption,
- travel time,
- safety/risk (wind, waves, piracy, ecological constraints).
-
Returns a Pareto front of non-dominated solutions so users can choose trade-offs.
- Convert lat/lon to the project's grid coordinates and load environmental rasters (wind, waves, risk maps).
- Use Theta* on a navigability grid to generate initial candidate paths.
- Seed an NSGA-II population by perturbing waypoints from Theta*.
- Evaluate each candidate for fuel, time, and safety using the ship model + environmental data.
- Evolve the population with crossover and mutation, keeping the non-dominated solutions as the Pareto front.
- Backend returns route geometries and metrics; frontend visualizes them and the Pareto trade-offs.
/backend
├─ server.py # flask app entrypoint
├─ routes.py
├─ theta_star.py
├─ nsga2.py
├─ eval.py
├─ utils.py
└─ requirements.txt
/frontend
├─ package.json
├─ public/
└─ src/
├─ components/
└─ pages/ # api client
/docs/
└─ Samudrapath Documentation.pdf
/algorithm
└─ entire_algorithm.ipynb
- Python 3.x
- Node.js + npm
requirements.txt
Purpose: The included Jupyter notebook is a runnable demo that demonstrates the core pipeline: generating baseline path(s) (Theta*), seeding and running a multi-objective GA (NSGA-II), and visualizing the resulting Pareto front and routes. Use it to quickly validate algorithm behavior, test parameter changes, and visualize intermediate results (waypoints, fitness scores, Pareto sets).
-
A minimal, self-contained demo that:
- sets up a small navigability grid or loads sample rasters/maps,
- constructs an initial Theta* path between start and goal,
- seeds and runs NSGA-II with configurable GA parameters,
- evaluates each route for fuel/time/risk and computes a Pareto front,
- visualizes routes and the Pareto scatterplot (fuel vs time, colored by risk).
-
Example configuration cells where you can edit start/goal, ship parameters, and GA settings.
-
Helper visualization cells (matplotlib / folium / plotly) to inspect geometry and metrics.
- Python virtual environment with project dependencies installed (see Setup & run — Backend). Additionally install notebook tools if not present:
pip install jupyterlab jupyter matplotlib pandas notebook- Activate
.venv(see above). - Launch Jupyter:
jupyter lab
# or
jupyter notebook-
Open
entire_algorithm.ipynb. -
Run cells from top to bottom. The first cell(s) typically define configuration variables — set
start,goal,ship_params,ga_params, and data paths as needed. -
Inspect outputs:
- a plotted baseline Theta* route (grid visualization),
- evolution progress values (it prints generation summaries),
- final Pareto scatterplot and a list/table of candidate routes with metrics,
- route geometries plotted on a map.
- A valid Theta* baseline path between the chosen points (no land/obstacle crossing).
- GA evolution logs or summarized metrics showing improvement or exploration across generations.
- A Pareto plot showing trade-offs (fuel vs time) and routes colored or labeled by risk.
- A small set of non-dominated routes (the Pareto front) from which you can pick different trade-offs.
- Change GA parameters (
population,generations,crossover_prob,mutation_sigma) and re-run the GA cell to see how solutions differ. - Modify ship parameters (speed, efficiencies, SFOC) and observe effects on fuel/time metrics.
- Instrument intermediate values: insert print or plot statements in evaluation cells to inspect per-segment resistance, effective speed, or per-segment risk.
From project root, run the following commands.
# create virtual environment
python3 -m venv .venv
# activate the virtualenv
# On Windows (PowerShell or cmd as in your instructions):
.venv\Scripts\activate
# On macOS / Linux:
# source .venv/bin/activate
# install dependencies
pip install -r requirements.txt
# run the Flask app
flask --app server runFrom the frontend directory:
cd frontend
npm install
npm startnpm start typically runs a development server (often at http://localhost:3000). Make sure the frontend is configured to call your backend host/port (e.g., http://localhost:5000).
-
Start backend and frontend.
-
In the web UI:
- Set start and destination (lat/lon or pick on the map).
- Choose ship type or enter ship parameters.
- Optionally choose environmental data inputs or allow automatic forecast fetching.
- Request route(s) and review the Pareto plot and map overlays.
- Grid/binary map: 2D raster/grid marking navigable vs blocked cells.
- Environmental rasters: wind speed/direction, wave height/direction aligned to the grid.
- Piracy / risk maps: raster with numeric risk levels.
- Ship parameters: JSON fields for speed, displacement, efficiencies, SFOC, etc.
- See
docs/Samudrapath Documentation.pdffor precise formats and units used in the code.
- Route geometries (lat/lon waypoints).
- Metrics for each route: fuel (units), travel time (hours), aggregated risk score.
- Map overlays: routes, wind/wave fields, risk zones.
- Pareto visual: fuel vs time vs (color-coded) risk for non-dominated routes.
- Fork the repo.
- Create a branch:
git checkout -b feat/your-feature. - Add tests and documentation updates.
- Submit a pull request with description and reproducible examples.
Thank You :)