Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

Allows to conveniently handle (one-dimensional) grids consisting of time points. More...

#include <grid.hpp>

Inheritance diagram for Grid:
Inheritance graph
[legend]

Public Member Functions

returnValue addTime (double _time)
 
returnValue coarsenGrid (uint factor)
 
returnValue equalizeGrids (Grid &arg)
 
int findFirstTime (double _time, uint startIdx=0) const
 
int findLastTime (double _time, uint startIdx=0) const
 
int findTime (double _time, uint startIdx=0) const
 
uint getCeilIndex (double time) const
 
double getFirstTime () const
 
uint getFloorIndex (double time) const
 
double getIntervalLength () const
 
double getIntervalLength (uint pointIdx) const
 
uint getLastIndex () const
 
double getLastTime () const
 
uint getNumIntervals () const
 
uint getNumPoints () const
 
returnValue getSubGrid (double tStart, double tEnd, Grid &_subGrid) const
 
double getTime (uint pointIdx) const
 
 Grid ()
 
 Grid (uint nPoints_, double *times_=0)
 
 Grid (const DVector &times_)
 
 Grid (double _firstTime, double _lastTime, uint _nPoints=2)
 
 Grid (const Grid &rhs)
 
BooleanType hasTime (double _time) const
 
returnValue init (uint _nPoints=0, const double *const _times=0)
 
returnValue init (const DVector &times_)
 
returnValue init (double _firstTime, double _lastTime, uint _nPoints=2)
 
returnValue init (const Grid &rhs)
 
BooleanType isEmpty () const
 
BooleanType isEquidistant () const
 
BooleanType isInInterval (double _time) const
 
BooleanType isInInterval (uint pointIdx, double _time) const
 
BooleanType isInLowerHalfOpenInterval (uint pointIdx, double _time) const
 
BooleanType isInUpperHalfOpenInterval (uint pointIdx, double _time) const
 
BooleanType isLast (uint pointIdx) const
 
returnValue merge (const Grid &arg, MergeMethod _mergeMethod=MM_DUPLICATE, BooleanType keepOverlap=BT_TRUE)
 
BooleanType operator!= (const Grid &arg) const
 
Gridoperator& (const Grid &arg)
 
BooleanType operator< (const Grid &arg) const
 
BooleanType operator<= (const Grid &arg) const
 
Gridoperator= (const Grid &rhs)
 
BooleanType operator== (const Grid &arg) const
 
BooleanType operator> (const Grid &arg) const
 
BooleanType operator>= (const Grid &arg) const
 
returnValue print () const
 
returnValue refineGrid (uint factor)
 
returnValue scaleTimes (double scaling)
 
returnValue setTime (double _time)
 
returnValue setTime (uint pointIdx, double _time)
 
GridshiftTimes (double timeShift)
 
 ~Grid ()
 

Protected Member Functions

int findNextIndex () const
 
returnValue setupEquidistant (double _firstTime, double _lastTime)
 

Protected Attributes

uint nPoints
 
double * times
 

Detailed Description

Allows to conveniently handle (one-dimensional) grids consisting of time points.

The class Grid allows to conveniently handle (one-dimensional) grids consisting of time points, as they usually occur when discretizing optimal control problems.

\note Time points of the grid are assumed to be ordered in increasing order.

\author Hans Joachim Ferreau, Boris Houska

Definition at line 58 of file grid.hpp.

Constructor & Destructor Documentation

BEGIN_NAMESPACE_ACADO Grid::Grid ( )

Default constructor.

Definition at line 47 of file grid.cpp.

Grid::Grid ( uint  nPoints_,
double *  times_ = 0 
)

Constructor that takes the number of grid points along with with an optional double array containing the initialization of the times.

Parameters
[in]_nPointsNumber of grid points.
[in]times_Initialization of time points.

Definition at line 54 of file grid.cpp.

Grid::Grid ( const DVector times_)

Constructor that takes the number of grid points along with with a initialization of the times in form of a vector.

Parameters
[in]timesInitialization of times.

Definition at line 63 of file grid.cpp.

Grid::Grid ( double  _firstTime,
double  _lastTime,
uint  _nPoints = 2 
)

Constructor that takes the number of grid points as well as as the time of the first and the last grid point. All intermediate grid points are setup to form a equidistant grid of time points.

Parameters
[in]_firstTimeTime of first grid point.
[in]_lastTimeTime of last grid point.
[in]_nPointsNumber of grid points.

Definition at line 71 of file grid.cpp.

Grid::Grid ( const Grid rhs)

Copy constructor (deep copy).

@param[in] rhs      Right-hand side object.

Definition at line 82 of file grid.cpp.

Grid::~Grid ( )

Destructor.

Definition at line 100 of file grid.cpp.

Member Function Documentation

returnValue Grid::addTime ( double  _time)

Adds a new grid point with given time to grid.

@param[in] _time    Time point to be added.
Returns
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

Definition at line 339 of file grid.cpp.

returnValue Grid::coarsenGrid ( uint  factor)

Coarsens grid by a given factor by equally leaving out time points from the existing ones.

Parameters
[in]factorCoarsening factor.
Returns
RET_NOT_YET_IMPLEMENTED,
RET_INVALID_ARGUMENTS

Definition at line 506 of file grid.cpp.

returnValue Grid::equalizeGrids ( Grid arg)

Constructs the set union of two grids and replaces both grids by this union grid. Note that both the original as well as the argument grid is changed!

@param[in] arg      Right-hand side object.
Returns
SUCCESSFUL_RETURN

Definition at line 293 of file grid.cpp.

int Grid::findFirstTime ( double  _time,
uint  startIdx = 0 
) const

Returns index of first grid point at given time, starting at startIdx.

Parameters
[in]_timeTime to be found.
[in]startIdxStart index for searching for time point.
Returns
>= 0: index of first grid point with given time,
-1: time point does not exist

Definition at line 539 of file grid.cpp.

int Grid::findLastTime ( double  _time,
uint  startIdx = 0 
) const

Returns index of last grid point at given time, starting at startIdx.

Parameters
[in]_timeTime to be found.
[in]startIdxStart index for searching for time point.
Returns
>= 0: index of last grid point with given time,
-1: time point does not exist

Definition at line 561 of file grid.cpp.

int Grid::findNextIndex ( ) const
protected

Returns index of next unintialized grid point.

Returns
>= 0: index of next unintialized grid point,
-1: time point does not exist

Definition at line 741 of file grid.cpp.

int Grid::findTime ( double  _time,
uint  startIdx = 0 
) const

Returns index of an grid point at given time, starting at startIdx.

Parameters
[in]_timeTime to be found.
[in]startIdxStart index for searching for time point.
Returns
>= 0: index of grid point with given time,
-1: time point does not exist

Definition at line 531 of file grid.cpp.

uint Grid::getCeilIndex ( double  time) const

Returns index of grid point with smallest time greater or equal to given time.

@param[in] _time    Time smaller or equal than that of the time point to be found.
Returns
>= 0: index of grid point with smallest time greater or equal to given time,
-1: time point does not exist

Definition at line 625 of file grid.cpp.

double Grid::getFirstTime ( ) const
inline

Returns time of first grid point.

Returns
Time of first grid point
uint Grid::getFloorIndex ( double  time) const

Returns index of grid point with greatest time smaller or equal to given time.

@param[in] _time    Time greater or equal than that of the time point to be found.
Returns
>= 0: index of grid point with greatest time smaller or equal to given time,
-1: time point does not exist

Definition at line 593 of file grid.cpp.

double Grid::getIntervalLength ( ) const
inline

Returns total interval length of grid.

Returns
Total interval length of grid
double Grid::getIntervalLength ( uint  pointIdx) const
inline

Returns interval length between given grid point and next one.

@param[in] pointIdx         Index of grid point at beginning of interval.
Returns
Interval length between given grid point and next one
uint Grid::getLastIndex ( ) const
inline

Returns largest index of grid (note the difference to getNumPoints()).

Returns
Largest index of grid.
double Grid::getLastTime ( ) const
inline

Returns time of last grid point.

Returns
Time of last grid point
uint Grid::getNumIntervals ( ) const
inline

Returns number of grid intervals.

Returns
Number of grid intervals
uint Grid::getNumPoints ( ) const
inline

Returns number of grid points.

Returns
Number of grid points
returnValue Grid::getSubGrid ( double  tStart,
double  tEnd,
Grid _subGrid 
) const

Returns a sub-grid of current grid starting a given start time end ending at given end time.

Parameters
[in]tStartStart time of sub-grid.
[in]tEndEnd time of sub-grid.
[out]_subGridDesired sub-grid.
Returns
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

Definition at line 655 of file grid.cpp.

double Grid::getTime ( uint  pointIdx) const
inline

Returns time of grid point with given index.

@param[in] pointIdx         Index of grid point.
Returns
Time of grid point with given index
BooleanType Grid::hasTime ( double  _time) const

Returns whether the grid contains a given time point.

@param[in] _time    Time point to be checked for existence.
Returns
BT_TRUE iff grid contains given time point,
BT_FALSE otherwise

Definition at line 520 of file grid.cpp.

returnValue Grid::init ( uint  _nPoints = 0,
const double *const  _times = 0 
)

Initializes grid with given number of grid points and given times.

Parameters
[in]_nPointsNumber of grid points.
[in]_timesInitialization of times.
Returns
SUCCESSFUL_RETURN

Definition at line 107 of file grid.cpp.

returnValue Grid::init ( const DVector times_)

Initializes grid with given number of grid points and given times in form of a vector.

Parameters
[in]timesInitialization of times.
Returns
SUCCESSFUL_RETURN

Definition at line 136 of file grid.cpp.

returnValue Grid::init ( double  _firstTime,
double  _lastTime,
uint  _nPoints = 2 
)

Initializes grid with given number of grid points and an equidistant grid of time points between given time of the first and last grid point.

Parameters
[in]_firstTimeTime of first grid point.
[in]_lastTimeTime of last grid point.
[in]_nPointsNumber of grid points.
Returns
SUCCESSFUL_RETURN

Definition at line 156 of file grid.cpp.

returnValue Grid::init ( const Grid rhs)

Initializes grid with given grid.

@param[in] rhs                      Grid to be taken for initialization.

\note This routine is introduced only for convenience and

is equivalent to the assignment operator.

Returns
SUCCESSFUL_RETURN

Definition at line 175 of file grid.cpp.

BooleanType Grid::isEmpty ( ) const
inline

Returns whether the grid is empty (i.e. no grid points) or not.

Returns
BT_TRUE iff grid is empty,
BT_FALSE otherwise
BooleanType Grid::isEquidistant ( ) const
inline

Returns whether the grid has equally spaced grid points or not.

Returns
BT_TRUE iff grid is equidistant,
BT_FALSE otherwise
BooleanType Grid::isInInterval ( double  _time) const
inline

Returns whether given time lies within the total interval of the grid.

@param[in] _time    Time point to be checked.
Returns
BT_TRUE iff time within total interval,
BT_FALSE otherwise
BooleanType Grid::isInInterval ( uint  pointIdx,
double  _time 
) const
inline

Returns whether given time lies within the interval between given grid point and next one.

Parameters
[in]pointIdxIndex of grid point at beginning of interval.
[in]_timeTime point to be checked.
Returns
BT_TRUE iff time within interval,
BT_FALSE otherwise
BooleanType Grid::isInLowerHalfOpenInterval ( uint  pointIdx,
double  _time 
) const
inline

Returns whether given time lies within the half-open interval between given grid point (given grid point not included) and next one.

Parameters
[in]pointIdxIndex of grid point at beginning of interval.
[in]_timeTime point to be checked.
Returns
BT_TRUE iff time within interval,
BT_FALSE otherwise
BooleanType Grid::isInUpperHalfOpenInterval ( uint  pointIdx,
double  _time 
) const
inline

Returns whether given time lies within the half-open interval between given grid point and next one (next one not included).

Parameters
[in]pointIdxIndex of grid point at beginning of interval.
[in]_timeTime point to be checked.
Returns
BT_TRUE iff time within interval,
BT_FALSE otherwise
BooleanType Grid::isLast ( uint  pointIdx) const
inline

Returns whether given index is the last one of the grid.

@param[in] pointIdx         Index of grid point.
Returns
BT_TRUE iff given index is the last one,
BT_FALSE otherwise
returnValue Grid::merge ( const Grid arg,
MergeMethod  _mergeMethod = MM_DUPLICATE,
BooleanType  keepOverlap = BT_TRUE 
)

Constructs the set union in time of current and given grid. A merge method defines the way duplicate entries are handled. Moreover, it can be specified whether an overlap in time of both grids shall be kept or if only the entries of one of them shall be kept according to the merge method.

Parameters
[in]argGrid to append.
[in]_mergeMethodMerge method, see documentation of MergeMethod for details.
[in]keepOverlapFlag indicating whether overlap shall be kept.
Returns
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

Definition at line 358 of file grid.cpp.

BooleanType Grid::operator!= ( const Grid arg) const
inline

Tests for non-equality.

@param[in] rhs      Object of comparison.
Returns
BT_TRUE iff both objects are not equal (in the above-mentioned sense),
BT_FALSE otherwise
Grid & Grid::operator& ( const Grid arg)

Constructs the set union of two grids.

@param[in] arg      Right-hand side object.
Returns
Set union of two grids

Definition at line 212 of file grid.cpp.

BooleanType Grid::operator< ( const Grid arg) const
inline

Tests if left-hand side grid is a strict subset of the right-hand side one, i.e. if each the rhs grid contains all time points of the lhs (but is not equal).

@param[in] rhs      Object of comparison.
Returns
BT_TRUE iff left object is a strict subset of the right one,
BT_FALSE otherwise
BooleanType Grid::operator<= ( const Grid arg) const
inline

Tests if left-hand side grid is a subset of the right-hand side one, i.e. if each the rhs grid contains all time points of the lhs.

@param[in] rhs      Object of comparison.
Returns
BT_TRUE iff left object is a subset of the right one,
BT_FALSE otherwise
Grid & Grid::operator= ( const Grid rhs)

Assignment operator (deep copy).

    @param[in] rhs  Right-hand side object.

Definition at line 185 of file grid.cpp.

BooleanType Grid::operator== ( const Grid arg) const
inline

Tests for equality, i.e. if number of grid points AND time values at all grid points are equal.

@param[in] rhs      Object of comparison.
Returns
BT_TRUE iff both objects are equal,
BT_FALSE otherwise
BooleanType Grid::operator> ( const Grid arg) const
inline

Tests if right-hand side grid is a strict subset of the left-hand side one, i.e. if each the lhs grid contains all time points of the rhs (but is not equal).

@param[in] rhs      Object of comparison.
Returns
BT_TRUE iff right object is a strict subset of the left one,
BT_FALSE otherwise
BooleanType Grid::operator>= ( const Grid arg) const
inline

Tests if right-hand side grid is a subset of the left-hand side one, i.e. if each the lhs grid contains all time points of the rhs.

@param[in] rhs      Object of comparison.
Returns
BT_TRUE iff right object is a subset of the left one,
BT_FALSE otherwise
returnValue Grid::print ( ) const

Prints times of all grid points to screen.

Returns
SUCCESSFUL_RETURN

Definition at line 700 of file grid.cpp.

returnValue Grid::refineGrid ( uint  factor)

Refines grid by a given factor by adding equally spaced additional time points in between existing ones.

Parameters
[in]factorRefinement factor.
Returns
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

Definition at line 477 of file grid.cpp.

returnValue Grid::scaleTimes ( double  scaling)

Scales times at all grid points by a given positive factor.

@param[in] scaling  Positive scaling factor.
Returns
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

Definition at line 460 of file grid.cpp.

returnValue Grid::setTime ( double  _time)

Assigns next unintialized time point.

@param[in] _time    New time point.
Returns
SUCCESSFUL_RETURN,
RET_GRIDPOINT_SETUP_FAILED,
RET_GRIDPOINT_HAS_INVALID_TIME

Definition at line 307 of file grid.cpp.

returnValue Grid::setTime ( uint  pointIdx,
double  _time 
)

Assigns new time to grid point with given index.

@param[in] pointIdx         Index of grid point.
@param[in] _time            New time.
Returns
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS

Definition at line 326 of file grid.cpp.

returnValue Grid::setupEquidistant ( double  _firstTime,
double  _lastTime 
)
protected

Sets-up all times in an equidistant manner, starting at given start time and ending at given end time.

Parameters
[in]_firstTimeTime of first grid point.
[in]_lastTimeTime of last grid point.

Definition at line 715 of file grid.cpp.

Grid & Grid::shiftTimes ( double  timeShift)

Shifts times at all grid points by a given offset.

@param[in] timeShift        Time offset for shifting.
Returns
Reference to object with shifted times

Definition at line 449 of file grid.cpp.

Member Data Documentation

uint Grid::nPoints
protected

Number of grid points.

Definition at line 613 of file grid.hpp.

double* Grid::times
protected

Time values at grid points.

Definition at line 614 of file grid.hpp.


The documentation for this class was generated from the following files:


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:24