Allows to conveniently handle (one-dimensional) grids consisting of time points. More...
#include <grid.hpp>
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 ×_) | |
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 ×_) |
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 |
Grid & | operator& (const Grid &arg) |
BooleanType | operator< (const Grid &arg) const |
BooleanType | operator<= (const Grid &arg) const |
Grid & | operator= (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) |
Grid & | shiftTimes (double timeShift) |
~Grid () | |
Protected Member Functions | |
int | findNextIndex () const |
returnValue | setupEquidistant (double _firstTime, double _lastTime) |
Protected Attributes | |
uint | nPoints |
double * | times |
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
BEGIN_NAMESPACE_ACADO Grid::Grid | ( | ) |
Grid::Grid | ( | uint | nPoints_, |
double * | times_ = 0 |
||
) |
Grid::Grid | ( | const DVector & | times_ | ) |
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.
[in] | _firstTime | Time of first grid point. |
[in] | _lastTime | Time of last grid point. |
[in] | _nPoints | Number of grid points. |
Grid::Grid | ( | const Grid & | rhs | ) |
returnValue Grid::addTime | ( | double | _time | ) |
returnValue Grid::coarsenGrid | ( | uint | factor | ) |
returnValue Grid::equalizeGrids | ( | Grid & | arg | ) |
int Grid::findFirstTime | ( | double | _time, |
uint | startIdx = 0 |
||
) | const |
int Grid::findLastTime | ( | double | _time, |
uint | startIdx = 0 |
||
) | const |
|
protected |
int Grid::findTime | ( | double | _time, |
uint | startIdx = 0 |
||
) | const |
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.
|
inline |
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.
|
inline |
Returns total interval length of grid.
|
inline |
Returns interval length between given grid point and next one.
@param[in] pointIdx Index of grid point at beginning of interval.
|
inline |
Returns largest index of grid (note the difference to getNumPoints()).
|
inline |
Returns time of last grid point.
|
inline |
Returns number of grid intervals.
|
inline |
Returns number of grid points.
returnValue Grid::getSubGrid | ( | double | tStart, |
double | tEnd, | ||
Grid & | _subGrid | ||
) | const |
|
inline |
Returns time of grid point with given index.
@param[in] pointIdx Index of grid point.
BooleanType Grid::hasTime | ( | double | _time | ) | const |
returnValue Grid::init | ( | uint | _nPoints = 0 , |
const double *const | _times = 0 |
||
) |
returnValue Grid::init | ( | const DVector & | times_ | ) |
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.
[in] | _firstTime | Time of first grid point. |
[in] | _lastTime | Time of last grid point. |
[in] | _nPoints | Number of grid points. |
returnValue Grid::init | ( | const Grid & | rhs | ) |
|
inline |
Returns whether the grid is empty (i.e. no grid points) or not.
|
inline |
Returns whether the grid has equally spaced grid points or not.
|
inline |
Returns whether given time lies within the total interval of the grid.
@param[in] _time Time point to be checked.
|
inline |
Returns whether given time lies within the interval between given grid point and next one.
[in] | pointIdx | Index of grid point at beginning of interval. |
[in] | _time | Time point to be checked. |
|
inline |
Returns whether given time lies within the half-open interval between given grid point (given grid point not included) and next one.
[in] | pointIdx | Index of grid point at beginning of interval. |
[in] | _time | Time point to be checked. |
|
inline |
Returns whether given time lies within the half-open interval between given grid point and next one (next one not included).
[in] | pointIdx | Index of grid point at beginning of interval. |
[in] | _time | Time point to be checked. |
|
inline |
Returns whether given index is the last one of the grid.
@param[in] pointIdx Index of grid point.
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.
[in] | arg | Grid to append. |
[in] | _mergeMethod | Merge method, see documentation of MergeMethod for details. |
[in] | keepOverlap | Flag indicating whether overlap shall be kept. |
|
inline |
Tests for non-equality.
@param[in] rhs Object of comparison.
|
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.
|
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.
|
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.
|
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.
|
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.
returnValue Grid::print | ( | ) | const |
returnValue Grid::refineGrid | ( | uint | factor | ) |
returnValue Grid::scaleTimes | ( | double | scaling | ) |
returnValue Grid::setTime | ( | double | _time | ) |
returnValue Grid::setTime | ( | uint | pointIdx, |
double | _time | ||
) |
|
protected |
Grid & Grid::shiftTimes | ( | double | timeShift | ) |