Package Realistic Simulator

This package contains all the classes required to build a realistic simulation of the boat. It uses the dynamic library libBoatModel.so which implements the accurate dynamic of the boat. It is coded in C in order to speed up the calculation process and hence the learning.

Realisitic Simulator

class Realistic_Simulator.Realistic_Simulator

Bases: object

This class holds a Simulink-based boat simulation, with methods to simulate and act upon it. Real simulation inputs are the heading reference for sail position is supposed to be fixed for a given configuration.

Variables:
  • time_step (float) – Smallest possible time step, inherited from Simulink model
  • simulation_time (float) – Timer of the real simulation time
  • U_hdg_ref (c_double) – Heading reference
  • U_sailpos (c_double) – Sail position
  • U_truewindspeed (c_double) – Absolute wind speed
  • U_truewindheading (c_double) – Absolute wind heading
  • U_truewaterspeed (c_double) – Absolute water speed
  • U_truewaterheading (c_double) – Absolute water heading
  • U_hdg0 (c_double) – Initial absolute boat heading
  • U_speed0 (c_double) – Initial absolute boat speed
  • Y_Windincidence (c_double) – Relative wind incidence wrt the wing
  • Y_SpeedOverGround (c_double) – Absolute boat speed
step(duration, precision)

Advance the simulation a certain amount of time and perform incidence and speed measures with a certain sample time, stored in np.arrays

Parameters:
  • duration (float) – How much to advance the simulation
  • precision (float) – Sampling time for the measures
Returns:

list of np.array Incidence, SpeedOverGround

terminate()

Terminate the simulation and its variables

Warning

Be careful to use the libBoatModel library corresponding to your OS (Linux or Mac).

If the dynamic library is not correctly compiled one can recompile it using the source file in the folder /libs/SourceLibs thanks to the command :

>> gcc -shared -o libBoatModel.so -fPIC Model_2_EXPORT_Discrete.c Model_2_EXPORT_Discrete_data.c rt_look.c rt_look1d.c

For further assistance please read this file.

Realistic MDP

class mdp_realistic.mdp_realistic(mdp_duration, history_duration, mdp_step, delta_t)

Bases: object

Markov Decision process modelization of the transition.

Variables:
  • history_duration (float) – Duration of the memory.
  • simulation_duration (float) – Duration of the memory.
  • mdp_step (float) – Sampling period for decision making measures
  • size (int) – size of the first dimension of the state.
  • dt (float) – time step between each value of the state.
  • s (np.array()) – state containing the history of angles of attacks and velocities.
  • idx_memory (range) – indices corresponding to the values shared by two successive states.
  • Simulator simulator (Realistic) – Simulator used to compute new values after a transition.
  • reward (float) – reward associated with a transition.
  • discount (float) – discount factor.
  • action (float) – action for transition.
copy()

Copy the MDP object

Returns:Deep copy of the object.
Return type:MDP
extractSimulationData()

Recover data from the simulation and add it to the state :return: state s

initializeMDP(hdg0, sailpos, speed0, truewaterheading, truewaterspeed, truewindspeed, truewindheading)

Initialization of the Markov Decision Process, filling the values of the history memory.

Parameters:
  • hdg0 – Initial cap
  • speed0 – Initial speed
  • truewaterheading – Absolute water heading
  • truewaterspeed – Absolute water speed
  • truewindspeed – Absolute wind speed
  • truewindheading – Absolute wind heading
  • truewindheading_std – Wind heading variance
Returns:

state s

transition(action)

Computes the mdp state when an action is applied.

Parameters:action – Action to perform
Returns:state, reward