Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

90 Commits

Folders and files

Repository files navigation

Samudrapath

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.


Table of contents


Quick start

  1. Clone the repository.
  2. Start the backend (Flask) and then the frontend (npm).
  3. Open the frontend UI (usually http://localhost:3000) and request routes by selecting start / goal and ship parameters.

What this project does

  • 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.


How it works (high level)

  1. Convert lat/lon to the project's grid coordinates and load environmental rasters (wind, waves, risk maps).
  2. Use Theta* on a navigability grid to generate initial candidate paths.
  3. Seed an NSGA-II population by perturbing waypoints from Theta*.
  4. Evaluate each candidate for fuel, time, and safety using the ship model + environmental data.
  5. Evolve the population with crossover and mutation, keeping the non-dominated solutions as the Pareto front.
  6. Backend returns route geometries and metrics; frontend visualizes them and the Pareto trade-offs.

Project layout

/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

Requirements

  • Python 3.x
  • Node.js + npm
  • requirements.txt

Entire Algorithm notebook — entire_algorithm.ipynb

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).

What you will find in the notebook

  • 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.

Prerequisites for running the notebook

  1. 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

Quick steps to run the demo

  1. Activate .venv (see above).
  2. Launch Jupyter:
jupyter lab
# or
jupyter notebook
  1. Open entire_algorithm.ipynb.

  2. 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.

  3. 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.

What to look for (expected results)

  • 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.

How to use the notebook to test changes

  • 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.

Setup & run — Backend

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 run

Setup & run — Frontend

From the frontend directory:

cd frontend
npm install
npm start

npm 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).


Usage (API + UI)

UI

  1. Start backend and frontend.

  2. 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.

Configuration & input formats

  • 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.pdf for precise formats and units used in the code.

Outputs & visualization

  • 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.

Contributing

  1. Fork the repo.
  2. Create a branch: git checkout -b feat/your-feature.
  3. Add tests and documentation updates.
  4. Submit a pull request with description and reproducible examples.

Thank You :)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages