ACADO Toolkit  1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
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

 Grid ()
 Default constructor.
 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.
 Grid (const Vector &times_)
 Constructor that takes the number of grid points along with with a initialization of the times in form of a vector.
 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.
 Grid (const Grid &rhs)
 Copy constructor (deep copy).
 ~Grid ()
 Destructor.
Gridoperator= (const Grid &rhs)
 Assignment operator (deep copy).
returnValue init (uint _nPoints=0, const double *const _times=0)
 Initializes grid with given number of grid points and given times.
returnValue init (const Vector &times_)
 Initializes grid with given number of grid points and given times in form of a vector.
returnValue 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.
returnValue init (const Grid &rhs)
 Initializes grid with given grid.
BooleanType operator== (const Grid &arg) const
 Tests for equality, i.e.
BooleanType operator!= (const Grid &arg) const
 Tests for non-equality.
BooleanType operator< (const Grid &arg) const
 Tests if left-hand side grid is a strict subset of the right-hand side one, i.e.
BooleanType operator<= (const Grid &arg) const
 Tests if left-hand side grid is a subset of the right-hand side one, i.e.
BooleanType operator> (const Grid &arg) const
 Tests if right-hand side grid is a strict subset of the left-hand side one, i.e.
BooleanType operator>= (const Grid &arg) const
 Tests if right-hand side grid is a subset of the left-hand side one, i.e.
Gridoperator& (const Grid &arg)
 Constructs the set union of two grids.
returnValue equalizeGrids (Grid &arg)
 Constructs the set union of two grids and replaces both grids by this union grid.
returnValue setTime (double _time)
 Assigns next unintialized time point.
returnValue setTime (uint pointIdx, double _time)
 Assigns new time to grid point with given index.
returnValue addTime (double _time)
 Adds a new grid point with given time to grid.
returnValue merge (const Grid &arg, MergeMethod _mergeMethod=MM_DUPLICATE, BooleanType keepOverlap=BT_TRUE)
 Constructs the set union in time of current and given grid.
BooleanType isEmpty () const
 Returns whether the grid is empty (i.e.
uint getNumPoints () const
 Returns number of grid points.
uint getNumIntervals () const
 Returns number of grid intervals.
double getFirstTime () const
 Returns time of first grid point.
double getLastTime () const
 Returns time of last grid point.
double getTime (uint pointIdx) const
 Returns time of grid point with given index.
GridshiftTimes (double timeShift)
 Shifts times at all grid points by a given offset.
BooleanType isEquidistant () const
 Returns whether the grid has equally spaced grid points or not.
double getIntervalLength () const
 Returns total interval length of grid.
double getIntervalLength (uint pointIdx) const
 Returns interval length between given grid point and next one.
returnValue scaleTimes (double scaling)
 Scales times at all grid points by a given positive factor.
returnValue refineGrid (uint factor)
 Refines grid by a given factor by adding equally spaced additional time points in between existing ones.
returnValue coarsenGrid (uint factor)
 Coarsens grid by a given factor by equally leaving out time points from the existing ones.
BooleanType hasTime (double _time) const
 Returns whether the grid contains a given time point.
int findTime (double _time, uint startIdx=0) const
 Returns index of an grid point at given time, starting at startIdx.
int findFirstTime (double _time, uint startIdx=0) const
 Returns index of first grid point at given time, starting at startIdx.
int findLastTime (double _time, uint startIdx=0) const
 Returns index of last grid point at given time, starting at startIdx.
uint getFloorIndex (double time) const
 Returns index of grid point with greatest time smaller or equal to given time.
uint getCeilIndex (double time) const
 Returns index of grid point with smallest time greater or equal to given time.
uint getLastIndex () const
 Returns largest index of grid (note the difference to getNumPoints()).
BooleanType isLast (uint pointIdx) const
 Returns whether given index is the last one of the grid.
BooleanType isInInterval (double _time) const
 Returns whether given time lies within the total interval of the grid.
BooleanType isInInterval (uint pointIdx, double _time) const
 Returns whether given time lies within the interval between given grid point and next one.
BooleanType isInUpperHalfOpenInterval (uint pointIdx, double _time) const
 Returns whether given time lies within the half-open interval between given grid point and next one (next one not included).
BooleanType isInLowerHalfOpenInterval (uint pointIdx, double _time) const
 Returns whether given time lies within the half-open interval between given grid point (given grid point not included) and next one.
returnValue 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.
returnValue print () const
 Prints times of all grid points to screen.

Protected Member Functions

returnValue setupEquidistant (double _firstTime, double _lastTime)
 Sets-up all times in an equidistant manner, starting at given start time and ending at given end time.
int findNextIndex () const
 Returns index of next unintialized grid point.

Protected Attributes

uint nPoints
 Number of grid points.
double * times
 Time values at grid points.

Detailed Description

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

Constructor & Destructor Documentation

References nPoints, and times.

Grid::Grid ( uint  nPoints_,
double *  times_ = 0 
)
Parameters:
[in]_nPointsNumber of grid points.
[in]times_Initialization of time points.

References init(), and times.

Grid::Grid ( const Vector times_)
Parameters:
[in]timesInitialization of times.

References init(), and times.

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

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.

References init(), and times.

Grid::Grid ( const Grid rhs)
Parameters:
[in]rhsRight-hand side object.

References nPoints, times, and uint.

References times.


Member Function Documentation

returnValue Grid::addTime ( double  _time)
Parameters:
[in]factorCoarsening factor.
Returns:
RET_NOT_YET_IMPLEMENTED,
RET_INVALID_ARGUMENTS

References ACADOERROR, getNumIntervals(), RET_INVALID_ARGUMENTS, RET_NOT_YET_IMPLEMENTED, and SUCCESSFUL_RETURN.

Note that both the original as well as the argument grid is changed!

Parameters:
[in]argRight-hand side object.
Returns:
SUCCESSFUL_RETURN

References SUCCESSFUL_RETURN.

int Grid::findFirstTime ( double  _time,
uint  startIdx = 0 
) const
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

References acadoIsEqual(), BT_TRUE, getNumPoints(), times, and uint.

Referenced by findTime().

int Grid::findLastTime ( double  _time,
uint  startIdx = 0 
) const
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

References acadoIsEqual(), BT_TRUE, getNumPoints(), times, and uint.

Referenced by MatrixVariablesGrid::getCoarsenedGrid().

int Grid::findNextIndex ( ) const [protected]
Returns:
>= 0: index of next unintialized grid point,
-1: time point does not exist

References getNumPoints(), INFTY, times, and uint.

Referenced by setTime().

int Grid::findTime ( double  _time,
uint  startIdx = 0 
) const
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

References findFirstTime().

Referenced by hasTime(), operator<(), and operator>().

uint Grid::getCeilIndex ( double  time) const
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

References acadoIsGreater(), acadoIsSmaller(), BT_TRUE, getLastIndex(), getTime(), isInLowerHalfOpenInterval(), and uint.

Referenced by VariablesGrid::getTimeSubGrid(), and MatrixVariablesGrid::linearInterpolation().

double Grid::getFirstTime ( ) const [inline]
Returns:
Time of first grid point

References ASSERT, and times.

Referenced by Actuator::addActuatorNoise(), Sensor::addSensorNoise(), VariablesGrid::appendTimes(), MatrixVariablesGrid::appendTimes(), OCPiterate::areGridsConsistent(), Actuator::checkInputConsistency(), Process::checkInputConsistency(), Actuator::delayActuatorInput(), Sensor::delaySensorOutput(), IntegratorBDF::evaluate(), IntegratorRK::evaluate(), IntegratorLYAPUNOV::evaluate(), ImplicitRungeKuttaExport::evaluateDerivedPolynomial(), ImplicitRungeKuttaExport::evaluatePolynomial(), IntegratorLYAPUNOV::evaluateSensitivities(), IntegratorBDF::evaluateSensitivities(), IntegratorRK::evaluateSensitivities(), DiagonallyImplicitRKExport::formMatrix(), ImplicitRungeKuttaExport::formMatrix(), ImplicitRungeKuttaExport::generateOutput(), AdjointIRKExport::getCode(), ForwardIRKExport::getCode(), ExplicitRungeKuttaExport::getCode(), DiscreteTimeExport::getCode(), ImplicitRungeKuttaExport::getCode(), IntegratorExport::getIntegrationInterval(), PeriodicReferenceTrajectory::getReference(), StaticReferenceTrajectory::getReference(), OCP::getStartTime(), Curve::getTimeDomain(), Curve::isInTimeDomain(), ShootingMethod::logTrajectory(), VariablesGrid::merge(), MatrixVariablesGrid::merge(), DiagonallyImplicitRKExport::prepareInputSystem(), ImplicitRungeKuttaExport::prepareOutputEvaluation(), DiagonallyImplicitRKExport::prepareOutputSystem(), IntegratorBDF::relaxAlgebraic(), Process::run(), AdjointIRKExport::sensitivitiesOutputs(), ForwardIRKExport::sensitivitiesOutputs(), LogRecordItem::setAllValues(), ModelData::setIntegrationGrid(), LSQTerm::setReference(), ExplicitRungeKuttaExport::setup(), Sensor::step(), Process::step(), and Actuator::step().

uint Grid::getFloorIndex ( double  time) const
double Grid::getIntervalLength ( ) const [inline]
double Grid::getIntervalLength ( uint  pointIdx) const [inline]
Parameters:
[in]pointIdxIndex of grid point at beginning of interval.
Returns:
Interval length between given grid point and next one

References ACADOERROR, getLastIndex(), getNumPoints(), INFTY, RET_INDEX_OUT_OF_BOUNDS, and times.

uint Grid::getLastIndex ( ) const [inline]
double Grid::getLastTime ( ) const [inline]
Returns:
Time of last grid point

References ASSERT, nPoints, and times.

Referenced by Curve::add(), Actuator::addActuatorNoise(), MatrixVariablesGrid::addMatrix(), Sensor::addSensorNoise(), addTime(), VariablesGrid::appendTimes(), MatrixVariablesGrid::appendTimes(), OCPiterate::areGridsConsistent(), Actuator::checkInputConsistency(), Process::checkInputConsistency(), Actuator::delayActuatorInput(), Sensor::delaySensorOutput(), Curve::evaluate(), IntegratorBDF::evaluate(), IntegratorRK::evaluate(), IntegratorLYAPUNOV::evaluate(), ImplicitRungeKuttaExport::evaluateDerivedPolynomial(), ImplicitRungeKuttaExport::evaluatePolynomial(), IntegratorBDF::evaluateSensitivities(), DiagonallyImplicitRKExport::formMatrix(), ImplicitRungeKuttaExport::formMatrix(), ImplicitRungeKuttaExport::generateOutput(), ForwardIRKExport::getCode(), AdjointIRKExport::getCode(), ExplicitRungeKuttaExport::getCode(), DiscreteTimeExport::getCode(), ImplicitRungeKuttaExport::getCode(), PlotWindow::getDataGrids(), Actuator::getDelayedInputGrids(), Sensor::getDelayedOutputGrid(), OCP::getEndTime(), IntegratorExport::getIntegrationInterval(), PeriodicReferenceTrajectory::getReference(), StaticReferenceTrajectory::getReference(), getTime(), Curve::getTimeDomain(), Integrator::integrate(), Curve::isInTimeDomain(), ShootingMethod::logTrajectory(), merge(), VariablesGrid::merge(), MatrixVariablesGrid::merge(), DiagonallyImplicitRKExport::prepareInputSystem(), ImplicitRungeKuttaExport::prepareOutputEvaluation(), DiagonallyImplicitRKExport::prepareOutputSystem(), refineGrid(), IntegratorBDF::rk_start(), Process::run(), AdjointIRKExport::sensitivitiesOutputs(), ForwardIRKExport::sensitivitiesOutputs(), ModelData::setIntegrationGrid(), ExplicitRungeKuttaExport::setup(), IntegratorDiscretizedODE::step(), IntegratorBDF::step(), IntegratorLYAPUNOV::step(), IntegratorRK::step(), Sensor::step(), Process::step(), and Actuator::step().

uint Grid::getNumIntervals ( ) const [inline]
Returns:
Number of grid intervals

References getLastIndex(), and nPoints.

Referenced by ModelData::addOutput(), ShootingMethod::addStage(), coarsenGrid(), ShootingMethod::deleteAllSeeds(), ImplicitRungeKuttaExport::divideMeasurements(), ShootingMethod::evaluate(), DiagonallyImplicitRKExport::formMatrix(), ImplicitRungeKuttaExport::formMatrix(), ImplicitRungeKuttaExport::generateOutput(), AdjointIRKExport::getCode(), ForwardIRKExport::getCode(), ExplicitRungeKuttaExport::getCode(), DiscreteTimeExport::getCode(), ImplicitRungeKuttaExport::getCode(), ForwardIRKExport::getDataDeclarations(), AdjointIRKExport::getDataDeclarations(), VariablesGrid::getIntegral(), IntegratorExport::getIntegrationInterval(), DynamicDiscretization::getNumEvaluationPoints(), Curve::getTimeDomain(), isEquidistant(), OCP::OCP(), DiagonallyImplicitRKExport::prepareInputSystem(), ImplicitRungeKuttaExport::prepareOutputEvaluation(), DiagonallyImplicitRKExport::prepareOutputSystem(), refineGrid(), AdjointIRKExport::sensitivitiesInputSystem(), ForwardIRKExport::sensitivitiesInputSystem(), AdjointIRKExport::sensitivitiesOutputs(), ForwardIRKExport::sensitivitiesOutputs(), DiagonallyImplicitRKExport::sensitivitiesOutputSystem(), AdjointIRKExport::sensitivitiesOutputSystem(), ForwardIRKExport::sensitivitiesOutputSystem(), ModelData::setIntegrationGrid(), NARXExport::setup(), ExplicitRungeKuttaExport::setup(), DiscreteTimeExport::setup(), ForwardIRKExport::setup(), AdjointIRKExport::setup(), OCP::setupGrid(), MatrixVariablesGrid::shiftBackwards(), and ShootingMethod::unfreeze().

uint Grid::getNumPoints ( ) const [inline]
Returns:
Number of grid points

References nPoints.

Referenced by acadoPlot(), CoupledPathConstraint::add(), PathConstraint::add(), Curve::add(), Constraint::add(), MatrixVariablesGrid::addMatrix(), addTime(), VariablesGrid::appendTimes(), MatrixVariablesGrid::appendTimes(), VariablesGrid::appendValues(), MatrixVariablesGrid::appendValues(), BoxConstraint::BoxConstraint(), Actuator::checkInputConsistency(), Process::checkInputConsistency(), ClippingFunctionality::clipSignals(), Constraint::Constraint(), Constraint::deleteAll(), MatrixVariablesGrid::determineStringLength(), MatrixVariablesGrid::disableAutoInit(), Curve::discretize(), MatrixVariablesGrid::enableAutoInit(), ShootingMethod::evaluate(), LSQTerm::evaluate(), Constraint::evaluate(), BoxConstraint::evaluateBounds(), PointConstraint::evaluateSensitivities(), BoundaryConstraint::evaluateSensitivities(), CoupledPathConstraint::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), MayerTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), AlgebraicConsistencyConstraint::evaluateSensitivities(), Constraint::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), LSQEndTerm::evaluateSensitivitiesGN(), findFirstTime(), findLastTime(), findNextIndex(), TransferDevice::generateNoise(), MatrixVariablesGrid::getAutoInit(), Constraint::getBackwardSensitivities(), Constraint::getBlockDim(), Constraint::getBoundResiduum(), BoxConstraint::getBounds(), Constraint::getBounds(), MatrixVariablesGrid::getCoarsenedGrid(), Constraint::getConstraintResiduum(), PlotWindow::getDataGrids(), PathConstraint::getDim(), MatrixVariablesGrid::getDim(), MatrixVariablesGrid::getFirstMatrix(), VariablesGrid::getFirstVector(), Constraint::getForwardSensitivities(), MatrixVariablesGrid::getGrid(), getIntervalLength(), getLastIndex(), MatrixVariablesGrid::getLastMatrix(), VariablesGrid::getLastVector(), MatrixVariablesGrid::getLowerBound(), MatrixVariablesGrid::getLowerBounds(), MatrixVariablesGrid::getMatrix(), MatrixVariablesGrid::getMax(), MatrixVariablesGrid::getMean(), MatrixVariablesGrid::getMin(), MatrixVariablesGrid::getName(), PathConstraint::getNC(), Constraint::getNC(), Constraint::getNP(), Constraint::getNU(), Constraint::getNumberOfBlocks(), MatrixVariablesGrid::getNumCols(), OCPiterate::getNumPoints(), LogRecordItem::getNumPoints(), MatrixVariablesGrid::getNumRows(), MatrixVariablesGrid::getNumValues(), Constraint::getNW(), Constraint::getNX(), Constraint::getNXA(), SimulationEnvironment::getProcessAlgebraicStates(), SimulationEnvironment::getProcessDifferentialStates(), SimulationEnvironment::getProcessIntermediateStates(), MatrixVariablesGrid::getRefinedGrid(), SimulationEnvironment::getSampledProcessOutput(), MatrixVariablesGrid::getScaling(), getSubGrid(), VariablesGrid::getSum(), getTime(), VariablesGrid::getTimeSubGrid(), MatrixVariablesGrid::getTimeSubGrid(), MatrixVariablesGrid::getType(), MatrixVariablesGrid::getUnit(), MatrixVariablesGrid::getUpperBound(), MatrixVariablesGrid::getUpperBounds(), VariablesGrid::getValuesSubGrid(), MatrixVariablesGrid::getValuesSubGrid(), VariablesGrid::getVector(), Integrator::getX(), Integrator::getXA(), MatrixVariablesGrid::hasLowerBounds(), MatrixVariablesGrid::hasNames(), MatrixVariablesGrid::hasScaling(), MatrixVariablesGrid::hasUnits(), MatrixVariablesGrid::hasUpperBounds(), BoxConstraint::init(), Constraint::init(), PIDcontroller::init(), VariablesGrid::initializeFromBounds(), OptimizationAlgorithmBase::initializeOCPiterate(), Constraint::isAffine(), Constraint::isBoxConstraint(), isInInterval(), isInLowerHalfOpenInterval(), isInUpperHalfOpenInterval(), MatrixVariablesGrid::linearInterpolation(), ShootingMethod::logTrajectory(), LSQTerm::LSQTerm(), Matrix::Matrix(), merge(), VariablesGrid::merge(), MatrixVariablesGrid::merge(), OCP::OCP(), MatrixVariablesGrid::operator()(), VariablesGrid::operator()(), MatrixVariablesGrid::operator+(), MatrixVariablesGrid::operator+=(), MatrixVariablesGrid::operator-(), MatrixVariablesGrid::operator-=(), operator<(), BoxConstraint::operator=(), LSQTerm::operator=(), Constraint::operator=(), operator==(), VariablesGrid::operator==(), operator>(), MatrixVariablesGrid::operator[](), VariablesGrid::operator[](), print(), MatrixVariablesGrid::printToString(), Process::projectToComponents(), Process::run(), GnuplotWindow::sendDataToGnuplot(), MatrixVariablesGrid::setAll(), MatrixVariablesGrid::setAllMatrices(), LogRecordItem::setAllValues(), VariablesGrid::setAllVectors(), MatrixVariablesGrid::setAutoInit(), ExportNLPSolver::setConstraints(), Constraint::setForwardSeed(), LSQTerm::setGrid(), MatrixVariablesGrid::setLowerBound(), MatrixVariablesGrid::setMatrix(), MatrixVariablesGrid::setName(), LSQTerm::setReference(), MatrixVariablesGrid::setScaling(), setTime(), MatrixVariablesGrid::setType(), MatrixVariablesGrid::setUnit(), Constraint::setUnitBackwardSeed(), Constraint::setUnitForwardSeed(), ExportGaussNewtonForces::setupConstraintsEvaluation(), OptimizationAlgorithmBase::setupDifferentialEquation(), setupEquidistant(), MatrixVariablesGrid::setUpperBound(), MatrixVariablesGrid::setUpperBounds(), VariablesGrid::setVector(), MatrixVariablesGrid::setZero(), MatrixVariablesGrid::shiftBackwards(), Process::simulate(), MatrixVariablesGrid::sprintf(), LinearStateFeedback::step(), PIDcontroller::step(), Sensor::step(), UniformNoise::step(), GaussianNoise::step(), Process::step(), LogCollection::updateLogRecord(), and LSQTerm::~LSQTerm().

returnValue Grid::getSubGrid ( double  tStart,
double  tEnd,
Grid _subGrid 
) const
Parameters:
[in]tStartStart time of sub-grid.
[in]tEndEnd time of sub-grid.
[out]_subGridDesired sub-grid.
Returns:
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

References ACADOERROR, acadoIsGreater(), acadoIsSmaller(), BT_FALSE, BT_TRUE, getNumPoints(), getTime(), hasTime(), init(), isInInterval(), RET_INVALID_ARGUMENTS, setTime(), SUCCESSFUL_RETURN, and uint.

Referenced by ShootingMethod::evaluate(), and Curve::evaluate().

double Grid::getTime ( uint  pointIdx) const [inline]
BooleanType Grid::hasTime ( double  _time) const
Parameters:
[in]_timeTime point to be checked for existence.
Returns:
BT_TRUE iff grid contains given time point,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, and findTime().

Referenced by MatrixVariablesGrid::getRefinedGrid(), getSubGrid(), VariablesGrid::getTimeSubGrid(), and OCPiterate::update().

returnValue Grid::init ( uint  _nPoints = 0,
const double *const  _times = 0 
)
returnValue Grid::init ( const Vector times_)
Parameters:
[in]timesInitialization of times.
Returns:
SUCCESSFUL_RETURN

References VectorspaceElement::getDim(), nPoints, SUCCESSFUL_RETURN, times, and uint.

returnValue Grid::init ( double  _firstTime,
double  _lastTime,
uint  _nPoints = 2 
)
Parameters:
[in]_firstTimeTime of first grid point.
[in]_lastTimeTime of last grid point.
[in]_nPointsNumber of grid points.
Returns:
SUCCESSFUL_RETURN

References nPoints, setupEquidistant(), and times.

returnValue Grid::init ( const Grid rhs)
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

References operator=(), and SUCCESSFUL_RETURN.

BooleanType Grid::isEmpty ( ) const [inline]
BooleanType Grid::isEquidistant ( ) const [inline]
Returns:
BT_TRUE iff grid is equidistant,
BT_FALSE otherwise

References acadoIsEqual(), BT_FALSE, BT_TRUE, getIntervalLength(), getNumIntervals(), and uint.

Referenced by ModelData::setIntegrationGrid().

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

References acadoIsGreater(), acadoIsSmaller(), BT_FALSE, BT_TRUE, getLastIndex(), getTime(), and times.

Referenced by getSubGrid(), VariablesGrid::getTimeSubGrid(), merge(), VariablesGrid::merge(), and MatrixVariablesGrid::merge().

BooleanType Grid::isInInterval ( uint  pointIdx,
double  _time 
) const [inline]
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

References ACADOERROR, acadoIsGreater(), acadoIsSmaller(), BT_FALSE, BT_TRUE, getLastIndex(), getNumPoints(), getTime(), RET_INDEX_OUT_OF_BOUNDS, times, and uint.

BooleanType Grid::isInLowerHalfOpenInterval ( uint  pointIdx,
double  _time 
) const [inline]
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

References ACADOERROR, acadoIsGreater(), acadoIsStrictlySmaller(), BT_FALSE, BT_TRUE, getNumPoints(), getTime(), RET_INDEX_OUT_OF_BOUNDS, times, and uint.

Referenced by getCeilIndex().

BooleanType Grid::isInUpperHalfOpenInterval ( uint  pointIdx,
double  _time 
) const [inline]
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

References ACADOERROR, acadoIsSmaller(), acadoIsStrictlyGreater(), BT_FALSE, BT_TRUE, getLastIndex(), getNumPoints(), getTime(), RET_INDEX_OUT_OF_BOUNDS, times, and uint.

Referenced by getFloorIndex().

BooleanType Grid::isLast ( uint  pointIdx) const [inline]
Parameters:
[in]pointIdxIndex of grid point.
Returns:
BT_TRUE iff given index is the last one,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, and getLastIndex().

returnValue Grid::merge ( const Grid arg,
MergeMethod  _mergeMethod = MM_DUPLICATE,
BooleanType  keepOverlap = BT_TRUE 
)

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

References ACADOERROR, acadoIsEqual(), acadoIsStrictlyGreater(), acadoIsStrictlySmaller(), addTime(), BT_FALSE, BT_TRUE, getLastTime(), getNumPoints(), getTime(), isInInterval(), MM_DUPLICATE, MM_KEEP, MM_REPLACE, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, and uint.

Referenced by Sensor::addSensorNoise(), Sensor::getDelayedOutputGrid(), and operator&().

BooleanType Grid::operator!= ( const Grid arg) const [inline]
Parameters:
[in]rhsObject of comparison.
Returns:
BT_TRUE iff both objects are not equal (in the above-mentioned sense),
BT_FALSE otherwise

References BT_FALSE, and BT_TRUE.

Grid & Grid::operator& ( const Grid arg)
Parameters:
[in]argRight-hand side object.
Returns:
Set union of two grids

References BT_TRUE, merge(), and MM_KEEP.

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

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

References BT_FALSE, BT_TRUE, findTime(), getNumPoints(), times, and uint.

BooleanType Grid::operator<= ( const Grid arg) const [inline]

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

References BT_FALSE, and BT_TRUE.

Grid & Grid::operator= ( const Grid rhs)
Parameters:
[in]rhsRight-hand side object.

References nPoints, times, and uint.

Referenced by init().

BEGIN_NAMESPACE_ACADO BooleanType Grid::operator== ( const Grid arg) const [inline]

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

References acadoIsEqual(), BT_FALSE, BT_TRUE, getNumPoints(), getTime(), and uint.

BooleanType Grid::operator> ( const Grid arg) const [inline]

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

References BT_FALSE, BT_TRUE, findTime(), getNumPoints(), times, and uint.

BooleanType Grid::operator>= ( const Grid arg) const [inline]

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

References BT_FALSE, and BT_TRUE.

Returns:
SUCCESSFUL_RETURN

References acadoPrintf(), getNumPoints(), getTime(), SUCCESSFUL_RETURN, and uint.

Parameters:
[in]factorRefinement factor.
Returns:
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

References ACADOERROR, getIntervalLength(), getLastTime(), getNumIntervals(), getTime(), nPoints, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, times, and uint.

returnValue Grid::scaleTimes ( double  scaling)
Parameters:
[in]scalingPositive scaling factor.
Returns:
SUCCESSFUL_RETURN,
RET_INVALID_ARGUMENTS

References acadoIsStrictlyGreater(), ACADOWARNING, BT_FALSE, nPoints, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, times, and uint.

Referenced by ShootingMethod::rescale().

returnValue Grid::setTime ( double  _time)
returnValue Grid::setTime ( uint  pointIdx,
double  _time 
)
Parameters:
[in]pointIdxIndex of grid point.
[in]_timeNew time.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS

References ACADOERROR, getNumPoints(), RET_INDEX_OUT_OF_BOUNDS, SUCCESSFUL_RETURN, and times.

returnValue Grid::setupEquidistant ( double  _firstTime,
double  _lastTime 
) [protected]
Parameters:
[in]_firstTimeTime of first grid point.
[in]_lastTimeTime of last grid point.

References ACADOERROR, getNumPoints(), nPoints, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, times, and uint.

Referenced by init().

Grid & Grid::shiftTimes ( double  timeShift)
Parameters:
[in]timeShiftTime offset for shifting.
Returns:
Reference to object with shifted times

Reimplemented in MatrixVariablesGrid, and VariablesGrid.

References nPoints, times, and uint.

Referenced by TransferDevice::generateNoise(), Actuator::getDelayedInputGrids(), and Sensor::getDelayedOutputGrid().


Member Data Documentation

uint Grid::nPoints [protected]
double* Grid::times [protected]

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines