Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

A tool to perform optimization of ship routes based on fuel consumption in different weather conditions.

Install `virtualenv`, if it is not installed yet:

```
sudo pip install virtualenv
```

To install the minimal dependencies version for the computational functionality, do this inside the virtual environment:

```
pip install .
```

And, finally, test it with:

```
pytest tests
```

### Optional Dependencies

To access the complete feature set (including geographic mapping algorithms and visualisations using datastores and `matplotlib`), utilize the new optional installations:

**1) Visualisation Package:** `pip install .[vis]`
Provides data chart tools using `matplotlib` and `seaborn`.

**2) geospatial/GIS Package:** `pip install .[geo]`
Enables cartography map and coordinate conversions handling `geopandas`, `cartopy`, `global_land_mask`, and `shapely`.

**3) Extraneous data package:** `pip install .[data]`
Adds larger data fetching engines like `boto3`, `dask`, `datacube`, `netcdf4` and `scikit-image`.

**4) Everything Inclusive:** `pip install .[all]`
Combines all previous sets for an all-encompassing installation.

Documentation: https://52north.github.io/WeatherRoutingTool/

Introduction: [WRT-sandbox](https://github.com/52North/WRT-sandbox) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/52North/WRT-sandbox.git/HEAD?urlpath=%2Fdoc%2Ftree%2FNotebooks/execute-WRT.ipynb)
Expand Down
11 changes: 7 additions & 4 deletions WeatherRoutingTool/algorithms/genetic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import time
from datetime import timedelta

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np
from astropy import units as u
from pymoo.algorithms.moo.nsga2 import NSGA2
Expand Down Expand Up @@ -71,7 +69,7 @@ def execute_routing(
:param verbose: Verbosity setting for logs
:type verbose: Optional[bool]
"""

import matplotlib.pyplot as plt
plt.set_loglevel(level='warning') # deactivate matplotlib debug messages if debug mode activated
if self.config.GENETIC_FIX_RANDOM_SEED:
logger.info('Fixing random seed for genetic algorithm.')
Expand Down Expand Up @@ -236,7 +234,7 @@ def plot_running_metric(self, res):
:param res: Result object of minimization
:type res: pymoo.core.result.Result
"""

import matplotlib.pyplot as plt
running = RunningMetric()

plt.rcParams['font.size'] = graphics.get_standard('font_size')
Expand Down Expand Up @@ -297,6 +295,8 @@ def plot_population_per_generation(self, res, best_route):
:param best_route: Optimum route
:type best_route: np.ndarray
"""
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
input_crs = ccrs.PlateCarree()
history = res.history
fig, ax = plt.subplots(figsize=graphics.get_standard('fig_size'))
Expand Down Expand Up @@ -357,6 +357,8 @@ def plot_population_per_generation(self, res, best_route):
plt.savefig(os.path.join(self.figure_path, figname))

def plot_coverage(self, res, best_route):
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
history = res.history
input_crs = ccrs.PlateCarree()

Expand Down Expand Up @@ -385,6 +387,7 @@ def plot_coverage(self, res, best_route):

def plot_convergence(self, res):
"""Plot the convergence curve (best objective value per generation)."""
import matplotlib.pyplot as plt

best_f = []

Expand Down
4 changes: 2 additions & 2 deletions WeatherRoutingTool/algorithms/genetic/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import random
from operator import add, sub

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np
from geographiclib.geodesic import Geodesic
from pymoo.core.mutation import Mutation
Expand Down Expand Up @@ -360,6 +358,8 @@ def mutate(self, problem, rt, **kw):
])

if debug:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
print('mutated rt: ', rt_new)
map = Map(rt[0][0], rt[0][1], rt[-1][0], rt[-1][1])
input_crs = ccrs.PlateCarree()
Expand Down
2 changes: 1 addition & 1 deletion WeatherRoutingTool/algorithms/genetic/repair.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pymoo.core.repair import Repair, NoRepair
from pymoo.core.repair import Repair

import numpy as np
import logging
Expand Down
3 changes: 2 additions & 1 deletion WeatherRoutingTool/algorithms/routingalg.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
from datetime import datetime

import matplotlib
from astropy import units as u
from geovectorslib import geod
from matplotlib.figure import Figure

from WeatherRoutingTool.constraints.constraints import *
from WeatherRoutingTool.routeparams import RouteParams
Expand Down Expand Up @@ -48,6 +48,7 @@ def __init__(self, config):
self.gcr_course = self.gcr_course * u.degree

self.figure_path = get_figure_path()
import matplotlib.pyplot as plt
plt.switch_backend("Agg")

self.boat_speed = config.BOAT_SPEED * u.meter/u.second
Expand Down
Loading