59 init( nPoints_,times_ );
77 init( _firstTime,_lastTime,_nPoints );
88 times = (
double*) calloc( nPoints,
sizeof(
double) );
90 for(
uint i=0; i<nPoints; ++i )
91 times[i] = rhs.
times[i];
108 const double*
const _times
117 times = (
double*) calloc( nPoints,
sizeof(
double) );
123 for(
uint i=0; i<nPoints; ++i )
124 times[i] = _times[i];
128 for(
uint i=0; i<nPoints; ++i )
139 nPoints = times_.
getDim();
145 times = (
double*) calloc( nPoints,
sizeof(
double) );
149 for(
uint i=0; i<nPoints; ++i )
150 times[i] = times_(i);
167 times = (
double*) calloc( nPoints,
sizeof(
double) );
171 return setupEquidistant( _firstTime,_lastTime );
195 if ( rhs.
times != 0 )
197 times = (
double*) calloc( nPoints,
sizeof(
double) );
199 for(
uint i=0; i<nPoints; ++i )
200 times[i] = rhs.
times[i];
310 int idx = findNextIndex( );
330 if ( pointIdx >= getNumPoints( ) )
333 times[pointIdx] = _time;
350 times = (
double*) realloc( times,nPoints*
sizeof(
double) );
351 times[nPoints-1] = _time;
370 if ( getNumPoints( ) == 0 )
382 for(
uint i=0; i<getNumPoints( ); ++i )
404 switch ( _mergeMethod )
407 mergedGrid.
addTime( getTime( i ) );
415 mergedGrid.
addTime( getTime( i ) );
427 mergedGrid.
addTime( getTime( i ) );
452 for(
uint i=0; i<nPoints; ++i )
453 times[i] += timeShift;
469 for(
uint i=0; i<nPoints; ++i )
484 if ( ( factor == 1 ) || ( getNumIntervals( ) == 0 ) )
488 double* newTimes = (
double*) calloc( getNumIntervals( )*factor+1,
sizeof(double) );
490 for(
uint i=0; i<getNumIntervals( ); ++i )
491 for(
uint j=0; j<factor; ++j )
492 newTimes[i*factor + j] = getTime( i ) + ((double) j) / ((double) factor) * getIntervalLength( i );
493 newTimes[ getNumIntervals( )*factor ] = getLastTime( );
496 nPoints = getNumIntervals( )*factor + 1;
513 if ( ( factor == 1 ) || ( getNumIntervals( ) == 0 ) )
523 if ( findTime( _time ) < 0 )
535 return findFirstTime( _time,startIdx );
546 for(
uint i=startIdx; i<getNumPoints( ); ++i )
552 if ( times[i] > _time )
568 for(
uint i=startIdx; i<getNumPoints( ); ++i )
583 if ( times[i] > _time )
597 uint upperIdx = getLastIndex( );
608 while ( lowerIdx < upperIdx )
610 idx = (
uint)floor( 0.5*( (
double)(upperIdx + lowerIdx) ) );
612 if ( isInUpperHalfOpenInterval( idx,time_ ) ==
BT_TRUE )
628 uint upperIdx = getLastIndex( );
639 while ( lowerIdx < upperIdx )
641 idx = (
uint)ceil(0.5*( (
double)( upperIdx + lowerIdx) ) );
643 if ( isInLowerHalfOpenInterval( idx,time_ ) ==
BT_TRUE )
660 if ( ( isInInterval( tStart ) ==
BT_FALSE ) ||
661 ( isInInterval( tEnd ) ==
BT_FALSE ) )
668 if ( hasTime( tStart ) ==
BT_FALSE )
671 for(
uint i=0; i<getNumPoints( ); ++i )
681 _subGrid.
init( nSubPoints );
683 if ( hasTime( tStart ) ==
BT_FALSE )
686 for(
uint i=0; i<getNumPoints( ); ++i )
690 _subGrid.
setTime( getTime( i ) );
702 for (
unsigned t = 0; t < getNumPoints(); t++)
703 cout << setprecision( 8 ) << getTime( t ) <<
" ";
719 if ( getNumPoints( ) == 0 )
722 if ( getNumPoints( ) == 1 )
724 times[0] = _firstTime;
728 if ( _firstTime > _lastTime )
732 double horizon = _lastTime - _firstTime;
734 for(
uint i=0; i<nPoints; ++i )
735 times[i] = _firstTime + ((
double) i) / ((double) getNumPoints( )-1) * horizon;
746 for(
uint i=0; i<getNumPoints( ); ++i )
747 if ( times[i] < -
INFTY+1.0 )
returnValue setTime(double _time)
int findLastTime(double _time, uint startIdx=0) const
returnValue merge(const Grid &arg, MergeMethod _mergeMethod=MM_DUPLICATE, BooleanType keepOverlap=BT_TRUE)
double getTime(uint pointIdx) const
int findTime(double _time, uint startIdx=0) const
BooleanType acadoIsEqual(double x, double y, double TOL)
uint getCeilIndex(double time) const
Allows to pass back messages to the calling function.
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Allows to conveniently handle (one-dimensional) grids consisting of time points.
BooleanType acadoIsGreater(double x, double y, double TOL)
#define CLOSE_NAMESPACE_ACADO
returnValue equalizeGrids(Grid &arg)
BooleanType isInInterval(double _time) const
returnValue getSubGrid(double tStart, double tEnd, Grid &_subGrid) const
returnValue print() const
uint getFloorIndex(double time) const
BooleanType acadoIsStrictlySmaller(double x, double y, double TOL)
Grid & operator&(const Grid &arg)
returnValue coarsenGrid(uint factor)
Grid & operator=(const Grid &rhs)
returnValue refineGrid(uint factor)
returnValue init(uint _nPoints=0, const double *const _times=0)
BooleanType acadoIsSmaller(double x, double y, double TOL)
void rhs(const real_t *x, real_t *f)
returnValue scaleTimes(double scaling)
returnValue setupEquidistant(double _firstTime, double _lastTime)
Grid & shiftTimes(double timeShift)
returnValue addTime(double _time)
int findFirstTime(double _time, uint startIdx=0) const
uint getNumPoints() const
BooleanType hasTime(double _time) const
#define ACADOWARNING(retval)
#define BEGIN_NAMESPACE_ACADO
BooleanType acadoIsStrictlyGreater(double x, double y, double TOL)
void init(int nV, int nC, SymmetricMatrix *H, real_t *g, Matrix *A, const real_t *const lb, const real_t *const ub, const real_t *const lbA, const real_t *const ubA, int nWSR, const real_t *const x0, Options *options, int nOutputs, mxArray *plhs[])
#define ACADOERROR(retval)
int findNextIndex() const