Module main
[hide private]
[frames] | no frames]

Module main

source code


Version: 1.3.0

Functions [hide private]
 
default(str) source code
 
validateOptionCombinations(args)
This functions validates we didn't mistakenly chosen options that don't work with each other.
source code
 
readCommand(argv)
Processes the command used to run the simulation from the command line.
source code
 
initWindFromFile(filePath) source code
 
initWaterCurrentsFromFile(filePath) source code
 
initWavesFromFile(filePath) source code
 
initObstaclesFromFile(filePath) source code
 
writeResults(resultsType, env, patrolPoints)
Write the simulation results.
source code
 
run(withDisplay, shipType, worldModel, strategy, inputFilesDir, taskFile, numSteps, rulesOfTheSea)
The main flow of the application.
source code
Variables [hide private]
  ALLOW_THREADS = 1
  BUFSIZE = 10000
  CLIP = 0
  ERR_CALL = 3
  ERR_DEFAULT = 0
  ERR_DEFAULT2 = 2084
  ERR_IGNORE = 0
  ERR_LOG = 5
  ERR_PRINT = 4
  ERR_RAISE = 2
  ERR_WARN = 1
  FLOATING_POINT_SUPPORT = 1
  FPE_DIVIDEBYZERO = 1
  FPE_INVALID = 8
  FPE_OVERFLOW = 2
  FPE_UNDERFLOW = 4
  False_ = False
  Inf = inf
  Infinity = inf
  MAXDIMS = 32
  NAN = nan
  NINF = -inf
  NZERO = -0.0
  NaN = nan
  PINF = inf
  PZERO = 0.0
  RAISE = 2
  SHIFT_DIVIDEBYZERO = 0
  SHIFT_INVALID = 9
  SHIFT_OVERFLOW = 3
  SHIFT_UNDERFLOW = 6
  ScalarType = (<type 'int'>, <type 'float'>, <type 'complex'>, ...
  True_ = True
  UFUNC_BUFSIZE_DEFAULT = 10000
  UFUNC_PYVALS_NAME = 'UFUNC_PYVALS'
  WRAP = 1
  __package__ = None
  absolute = <ufunc 'absolute'>
  add = <ufunc 'add'>
  arccos = <ufunc 'arccos'>
  arccosh = <ufunc 'arccosh'>
  arcsin = <ufunc 'arcsin'>
  arcsinh = <ufunc 'arcsinh'>
  arctan = <ufunc 'arctan'>
  arctan2 = <ufunc 'arctan2'>
  arctanh = <ufunc 'arctanh'>
  bitwise_and = <ufunc 'bitwise_and'>
  bitwise_not = <ufunc 'invert'>
  bitwise_or = <ufunc 'bitwise_or'>
  bitwise_xor = <ufunc 'bitwise_xor'>
  c_ = <numpy.lib.index_tricks.CClass object at 0xa43446c>
  cast = {<type 'numpy.int64'>: <function <lambda> at 0xa40ff7c>...
  conj = <ufunc 'conjugate'>
  conjugate = <ufunc 'conjugate'>
  deg2rad = <ufunc 'deg2rad'>
  divide = <ufunc 'divide'>
  e = 2.71828182846
  equal = <ufunc 'equal'>
  exp2 = <ufunc 'exp2'>
  expm1 = <ufunc 'expm1'>
  floor_divide = <ufunc 'floor_divide'>
  fmax = <ufunc 'fmax'>
  fmin = <ufunc 'fmin'>
  greater = <ufunc 'greater'>
  greater_equal = <ufunc 'greater_equal'>
  index_exp = <numpy.lib.index_tricks.IndexExpression object at ...
  inf = inf
  infty = inf
  invert = <ufunc 'invert'>
  isfinite = <ufunc 'isfinite'>
  left_shift = <ufunc 'left_shift'>
  less = <ufunc 'less'>
  less_equal = <ufunc 'less_equal'>
  little_endian = True
  logaddexp = <ufunc 'logaddexp'>
  logaddexp2 = <ufunc 'logaddexp2'>
  logical_and = <ufunc 'logical_and'>
  logical_not = <ufunc 'logical_not'>
  logical_or = <ufunc 'logical_or'>
  logical_xor = <ufunc 'logical_xor'>
  maximum = <ufunc 'maximum'>
  mgrid = <numpy.lib.index_tricks.nd_grid object at 0xa43434c>
  minimum = <ufunc 'minimum'>
  mod = <ufunc 'remainder'>
  multiply = <ufunc 'multiply'>
  nan = nan
  nbytes = {<type 'numpy.int64'>: 8, <type 'numpy.int16'>: 2, <t...
  negative = <ufunc 'negative'>
  newaxis = None
  not_equal = <ufunc 'not_equal'>
  ogrid = <numpy.lib.index_tricks.nd_grid object at 0xa43436c>
  ones_like = <ufunc 'ones_like'>
  pi = 3.14159265359
  power = <ufunc 'power'>
  r_ = <numpy.lib.index_tricks.RClass object at 0xa4343ec>
  rad2deg = <ufunc 'rad2deg'>
  reciprocal = <ufunc 'reciprocal'>
  remainder = <ufunc 'remainder'>
  right_shift = <ufunc 'right_shift'>
  rint = <ufunc 'rint'>
  s_ = <numpy.lib.index_tricks.IndexExpression object at 0xa43460c>
  sctypeDict = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>,...
  sctypeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bo...
  sctypes = {'complex': [<type 'numpy.complex64'>, <type 'numpy....
  sign = <ufunc 'sign'>
  signbit = <ufunc 'signbit'>
  square = <ufunc 'square'>
  subtract = <ufunc 'subtract'>
  true_divide = <ufunc 'true_divide'>
  typeDict = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>, 2...
  typeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bool...
  typecodes = {'All': '?bhilqpBHILQPfdgFDGSUVO', 'AllFloat': 'fd...
Function Details [hide private]

validateOptionCombinations(args)

source code 

This functions validates we didn't mistakenly chosen options that don't work with each other. If options are verified we just return to the the program execution. If the options are incorrect, we gracefully exit.

writeResults(resultsType, env, patrolPoints)

source code 

Write the simulation results.

TODO: this function needs to be further organized once we have a better picture regarding what types of results are usually needed. Also the function arguments should be revised as a part of the function reorganization.

Parameters:
  • resultsType (string) - a string identifier for the type of result to write
  • resultsType (string) - The simulation environment, used to extract data from
  • patrolPoints (array of (x,y) tuples) - All the points that participate in the patrol. This is required when writing data for heuristicDivide algorithm, and might be removed at some point.

run(withDisplay, shipType, worldModel, strategy, inputFilesDir, taskFile, numSteps, rulesOfTheSea)

source code 

The main flow of the application. The arguments are generated by command line options, or their defaults.

Parameters:
  • withDisplay (boolean) - Tells whether to run in a GUI mode or in non-GUI mode
  • shipType (string) - The ship model to allocate
  • worldModel (string) - The world model the agent has
  • strategy (string) - The decision-making strategy the agent has
  • inputFilesDir (string) - The directory in which the input files are
  • taskFile (string) - A task-definition-language file
  • numSteps (int) - Number of steps to simulate
  • rulesOfTheSea (boolean) - Tells whether to respect the rules of the sea

Variables Details [hide private]

ScalarType

Value:
(<type 'int'>,
 <type 'float'>,
 <type 'complex'>,
 <type 'long'>,
 <type 'bool'>,
 <type 'str'>,
 <type 'unicode'>,
 <type 'buffer'>,
...

cast

Value:
{<type 'numpy.int64'>: <function <lambda> at 0xa40ff7c>, <type 'numpy.\
int16'>: <function <lambda> at 0xa40ffb4>, <type 'numpy.object_'>: <fu\
nction <lambda> at 0xa41602c>, <type 'numpy.uint32'>: <function <lambd\
a> at 0xa416064>, <type 'numpy.bool_'>: <function <lambda> at 0xa41609\
c>, <type 'numpy.float96'>: <function <lambda> at 0xa4160d4>, <type 'n\
umpy.int32'>: <function <lambda> at 0xa41610c>, <type 'numpy.string_'>\
: <function <lambda> at 0xa416144>, <type 'numpy.uint32'>: <function <\
lambda> at 0xa41617c>, <type 'numpy.complex64'>: <function <lambda> at\
...

index_exp

Value:
<numpy.lib.index_tricks.IndexExpression object at 0xa4345cc>

nbytes

Value:
{<type 'numpy.int64'>: 8, <type 'numpy.int16'>: 2, <type 'numpy.object\
_'>: 4, <type 'numpy.uint32'>: 4, <type 'numpy.bool_'>: 1, <type 'nump\
y.float96'>: 12, <type 'numpy.int32'>: 4, <type 'numpy.string_'>: 0, <\
type 'numpy.uint32'>: 4, <type 'numpy.complex64'>: 8, <type 'numpy.uni\
code_'>: 0, <type 'numpy.uint64'>: 8, <type 'numpy.int8'>: 1, <type 'n\
umpy.complex128'>: 16, <type 'numpy.uint8'>: 1, <type 'numpy.void'>: 0\
, <type 'numpy.float32'>: 4, <type 'numpy.int32'>: 4, <type 'numpy.com\
plex192'>: 24, <type 'numpy.uint16'>: 2, <type 'numpy.float64'>: 8}

sctypeDict

Value:
{0: <type 'numpy.bool_'>,
 1: <type 'numpy.int8'>,
 2: <type 'numpy.uint8'>,
 3: <type 'numpy.int16'>,
 4: <type 'numpy.uint16'>,
 5: <type 'numpy.int32'>,
 6: <type 'numpy.uint32'>,
 7: <type 'numpy.int32'>,
...

sctypeNA

Value:
{'?': 'Bool',
 'B': 'UInt8',
 'Bool': <type 'numpy.bool_'>,
 'Complex32': <type 'numpy.complex64'>,
 'Complex64': <type 'numpy.complex128'>,
 'Complex96': <type 'numpy.complex192'>,
 'D': 'Complex64',
 'F': 'Complex32',
...

sctypes

Value:
{'complex': [<type 'numpy.complex64'>,
             <type 'numpy.complex128'>,
             <type 'numpy.complex192'>],
 'float': [<type 'numpy.float32'>,
           <type 'numpy.float64'>,
           <type 'numpy.float96'>],
 'int': [<type 'numpy.int8'>,
         <type 'numpy.int16'>,
...

typeDict

Value:
{0: <type 'numpy.bool_'>,
 1: <type 'numpy.int8'>,
 2: <type 'numpy.uint8'>,
 3: <type 'numpy.int16'>,
 4: <type 'numpy.uint16'>,
 5: <type 'numpy.int32'>,
 6: <type 'numpy.uint32'>,
 7: <type 'numpy.int32'>,
...

typeNA

Value:
{'?': 'Bool',
 'B': 'UInt8',
 'Bool': <type 'numpy.bool_'>,
 'Complex32': <type 'numpy.complex64'>,
 'Complex64': <type 'numpy.complex128'>,
 'Complex96': <type 'numpy.complex192'>,
 'D': 'Complex64',
 'F': 'Complex32',
...

typecodes

Value:
{'All': '?bhilqpBHILQPfdgFDGSUVO',
 'AllFloat': 'fdgFDG',
 'AllInteger': 'bBhHiIlLqQpP',
 'Character': 'c',
 'Complex': 'FDG',
 'Float': 'fdg',
 'Integer': 'bhilqp',
 'UnsignedInteger': 'BHILQP'}