Public Member Functions | Protected Member Functions | Protected Attributes

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

#include <grid.hpp>

Inheritance diagram for Grid:
Inheritance graph
[legend]

List of all members.

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

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).

Parameters:
[in]rhsRight-hand side object.

Definition at line 82 of file grid.cpp.

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.

Parameters:
[in]_timeTime point to be added.
Returns:
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

Definition at line 339 of file grid.cpp.

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.

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!

Parameters:
[in]argRight-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.

Parameters:
[in]_timeTime 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.

Parameters:
[in]_timeTime 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.

Parameters:
[in]pointIdxIndex 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.

Parameters:
[in]pointIdxIndex 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.

Parameters:
[in]_timeTime 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.

Parameters:
[in]rhsGrid 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.

Parameters:
[in]_timeTime 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.

Parameters:
[in]pointIdxIndex 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.

Parameters:
[in]rhsObject 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.

Parameters:
[in]argRight-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).

Parameters:
[in]rhsObject 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.

Parameters:
[in]rhsObject 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).

Parameters:
[in]rhsRight-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.

Parameters:
[in]rhsObject 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).

Parameters:
[in]rhsObject 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.

Parameters:
[in]rhsObject of comparison.
Returns:
BT_TRUE iff right object is a subset of the left one,
BT_FALSE otherwise

Prints times of all grid points to screen.

Returns:
SUCCESSFUL_RETURN

Definition at line 700 of file grid.cpp.

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.

Parameters:
[in]scalingPositive 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.

Parameters:
[in]_timeNew 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.

Parameters:
[in]pointIdxIndex of grid point.
[in]_timeNew 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.

Parameters:
[in]timeShiftTime offset for shifting.
Returns:
Reference to object with shifted times

Reimplemented in MatrixVariablesGrid, and VariablesGrid.

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 Thu Aug 27 2015 12:01:39