Package isochrones

This package contains the implementation of the isochrones routing method.

isochrones

Created on Wed Dec 20 13:48:13 2017

@author: j.belley

class isochrones.Isochrone(simulateur, coord_depart, coord_arrivee, delta_cap=10, increment_cap=9, nb_secteur=10, resolution=200, temps=0)

Bases: object

Class making the determinist isochrone method described by Hideki Hagiwara.

Variables:
  • sim (Simulator) – Object Simulator which have to be initialized with the geographic position of the problem and the weather forcast desired.
  • dep (list) – Latitude and longitude in degree of the starting point. For instance, [47.5, 356.5].
  • arr (list) – Latitude and longitude in degree of the destination point. For instance, [47.8, 352.3].
  • isochrone_actuelle (list) – List of the nodes which constitute the current isochrone shape.
  • isochrone_future (list) – List of the nodes which are made in order to find the shape of the next isochrone.
  • isochrone_stock (list) – List of used isochrone (list of list of states)
  • distance_moy_iso (float) – Average distance of the current isochrone from the starting point in meters.
  • reso (float) – Resolution of the current isochrone (average distance between nodes of the isochrone shape in meters).
  • p (int) – Half of the number of sectors used by the isochrone algorithm (half of the maximal number of nodes of the current isochrone).
  • constante (float) – Used to change units.
  • delta_t (float) – Time step of the simulator in days.
  • liste_actions (list) – List of the bearings in degree that the ship can use to join its destination. After solving the problem, it become the policy to follow to reach the destination.
  • liste_positions (list) – List of the positions (lat,lon) where the ship goes and changes its bearing in order to reach the destination.
  • temps_transit (float) – Time spend during the trip in days.
  • C0 (float) – Bearing between the departure and the arrival in degree.
  • temps_dep (int) – time indice used in the ship Simulator. Chose another value than 0 if you want to start your isochrone research at a precise temps (different from forcast initial hour).
aller_point_arrivee(Top_noeud)

Method which takes all the nodes close from the arrival and make them arrive by going straight ahead. Then it returns the node which joins earlier the destination, the time spend during all the journey between the starting point and the destination and the list of the heandings followed during the last 20 km

associer_xij_a_S(liste_S, delta_S)

Associates to all the nodes reachable from the current isochrone an angular sector and returns the list of those sectors.

isochrone_brouillon()

Generates all the future nodes reachable from the current isochrone by doing the different actions allowed.

isochrone_methode()

If it can, it finds the ship routing solution which minimises the travel time between two points with determinist ship dynamic and weather forcast. It returns the minimum time of trip, the list of heading used during the journey, the list of the final headings and the list of the nodes positions.

isochrone_proche_arrivee()

Method which tests if the nodes of the current isochrone are close from the arrival point (under 20 km). If they are, it returns a boolean True and the list of the node which are almost arrived

nouvelle_isochrone_propre(liste_S)

Keep, for each sector, only the farthest node reachable from the current isochrone and so create the new current isochrone.

positions_to_states()

Changes the list of nodes’ position in a list of states.

recentrage_cap(cap)

Keep the heading in degree between 0 and 360.

Parameters:cap (float) – Bearing to correct.
reset(coord_depart=None, coord_arrivee=None)

Reset the problem to slove with a different departure and arrival but the same weather forcast. To change the weather forcast, change self.sim and reset the Isochrone.

Parameters:
  • coord_depart (list) – Latitude and longitude in degree of the starting point.
  • coord_arrivee (list) – Latitude and longitude in degree of the destination point.
secteur_liste()

Creates all the angular sectors used to select the nodes of the future isochrone and return a list of them. Returns also the width of a sector at the average distance of the future isochrone.

class isochrones.Node(time, lat, lon, parent=None, action=None, C=None, D=None)

Bases: object

Class which is used to make the points of the isochrone curves. It is based on a node structure of a linked list.

Variables:
  • time (int) – time indice used by the ship simulator to define a state.
  • lat (float) – latitude used by the ship simulator to define a state.
  • lon (float) – longitude used by the ship simulator to define a state.
  • pere (isochrones.Node) – parent node from the previous isochrone curve.
  • act (float) – heading follow from the parent node to the actual node.
  • C (float) – heading between the starting point and the node position.
  • D (float) – distance between the starting point and the node position.
give_state()

Method which returns the state of a node. The definition of a state is given in simulatorTLKT documentation

class isochrones.Secteur(cap_sup, cap_inf)

Bases: object

Class used to partition the space in order to apply Hagiwara’s isochrone method. :ivar float cap_sup: upper bond of the angular sector which start from the beginning point.

Variables:
  • cap_inf (float) – lower bond of the angular sector which start from the beginning point.
  • liste_noeud (list) – list of the nodes which belong to the angular sector.
  • liste_distance (list) – list of the distances between the starting point and the nodes in liste_noeud.
recherche_meilleur_noeud()

Method which returns the farthest node of liste_noeud according to the data in liste_distance

isochrones.estimate_perfomance_plan(sims, ntra, stateinit, destination, plan=[], plot=False, verbose=True)

Estimates the performances of two plans and compares them on two scenarios.

Parameters:
  • sims (list()) – List of simulatorTLKT.Simulator
  • ntra (int) – Number of trajectories used to estimate the performances on each scenarios
  • stateinit (list(int,float,float)) – [t_index, lat, lon], starting point of the plans
  • destination (list(int,float,float)) – [t_index, lat, lon], destination point of the plans
  • plan (list) – list of actions to apply
  • plot (bool) – if True displays the mean trajectories per scenario
  • verbose (bool) – if True verbose results
Returns:

mean_arrival_times, var_arrival_times, global_mean_time, variance_globale with length : len(list) = len(sims)

Return type:

list(float), list(float), float, float

isochrones.plot_comparision(means1, var1, means2, var2, mean_straight_line, var_straight_line, titles)

plot the histograms of the mean times obtained by PMCTS and Isochrones optimal plans and straight line strategy for all the weather forcast scenarios. In addition it plots also the standard deviation of each mean time. Attention lenght(titles) = 3

isochrones.plot_comparision_percent(means1, var1, means2, var2, mean_straight_line, var_straight_line, titles)

plot the histograms of the mean times obtained by PMCTS and Isochrones optimal plans for all the weather forcast scenarios. In addition it plots also the variance of each mean time. Means and variances of the travelling times obtained by the optimal plans are normalised by the ones of the straight line plan (in percent). Attention lenght(titles) = 2

isochrones.plot_mean_squared_error(means1, var1, means2, var2, mean_straight_line, var_straight_line, titles)

plot the histograms of the mean squared error on times obtained by PMCTS and Isochrones optimal plans and straight line strategy for all the weather forcast scenarios. Attention lenght(titles) = 3

isochrones.plot_risk_probability(means1, var1, means2, var2, titles, t_lim=0)

plot the histograms of the probability of times obtained by PMCTS and Isochrones optimal plans to be over t_lim for all the weather forcast scenarios. Attention lenght(titles) = 2

isochrones.plot_trajectory(sim, trajectoire, quiv=True, scatter=False)

plot the trajectory on the map of the simulator with the wind forcast associated