grid.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
33 #ifndef ACADO_TOOLKIT_GRID_HPP
34 #define ACADO_TOOLKIT_GRID_HPP
35 
36 
39 
40 
42 
43 
44 
58 class Grid
59 {
60  //
61  // PUBLIC MEMBER FUNCTIONS:
62  //
63  public:
64 
66  Grid( );
67 
75  Grid( uint nPoints_,
76  double* times_ = 0
77  );
78 
84  Grid( const DVector& times_
85  );
86 
95  Grid( double _firstTime,
96  double _lastTime,
97  uint _nPoints = 2
98  );
99 
104  Grid( const Grid& rhs
105  );
106 
109  ~Grid( );
110 
115  Grid& operator=( const Grid& rhs
116  );
117 
118 
127  returnValue init( uint _nPoints = 0,
128  const double* const _times = 0
129  );
130 
138  returnValue init( const DVector& times_
139  );
140 
151  returnValue init( double _firstTime,
152  double _lastTime,
153  uint _nPoints = 2
154  );
155 
165  returnValue init( const Grid& rhs
166  );
167 
168 
177  inline BooleanType operator==( const Grid& arg
178  ) const;
179 
188  inline BooleanType operator!=( const Grid& arg
189  ) const;
190 
200  inline BooleanType operator<( const Grid& arg
201  ) const;
202 
211  inline BooleanType operator<=( const Grid& arg
212  ) const;
213 
223  inline BooleanType operator>( const Grid& arg
224  ) const;
225 
234  inline BooleanType operator>=( const Grid& arg
235  ) const;
236 
237 
244  Grid& operator&( const Grid& arg
245  );
246 
247 
257  );
258 
259 
268  returnValue setTime( double _time
269  );
270 
279  returnValue setTime( uint pointIdx,
280  double _time
281  );
282 
290  returnValue addTime( double _time
291  );
292 
293 
307  returnValue merge( const Grid& arg,
308  MergeMethod _mergeMethod = MM_DUPLICATE,
309  BooleanType keepOverlap = BT_TRUE
310  );
311 
312 
318  inline BooleanType isEmpty( ) const;
319 
324  inline uint getNumPoints( ) const;
325 
330  inline uint getNumIntervals( ) const;
331 
332 
337  inline double getFirstTime( ) const;
338 
343  inline double getLastTime( ) const;
344 
351  inline double getTime( uint pointIdx
352  ) const;
353 
354 
361  Grid& shiftTimes( double timeShift
362  );
363 
364 
370  inline BooleanType isEquidistant( ) const;
371 
376  inline double getIntervalLength( ) const;
377 
384  inline double getIntervalLength( uint pointIdx
385  ) const;
386 
394  returnValue scaleTimes( double scaling
395  );
396 
397 
406  returnValue refineGrid( uint factor
407  );
408 
418  );
419 
420 
428  BooleanType hasTime( double _time
429  ) const;
430 
431 
441  int findTime( double _time,
442  uint startIdx = 0
443  ) const;
444 
454  int findFirstTime( double _time,
455  uint startIdx = 0
456  ) const;
457 
467  int findLastTime( double _time,
468  uint startIdx = 0
469  ) const;
470 
471 
479  uint getFloorIndex( double time
480  ) const;
481 
489  uint getCeilIndex ( double time
490  ) const;
491 
492 
497  inline uint getLastIndex ( ) const;
498 
499 
507  inline BooleanType isLast( uint pointIdx
508  ) const;
509 
510 
518  inline BooleanType isInInterval( double _time
519  ) const;
520 
530  inline BooleanType isInInterval( uint pointIdx,
531  double _time
532  ) const;
533 
543  inline BooleanType isInUpperHalfOpenInterval( uint pointIdx,
544  double _time
545  ) const;
546 
556  inline BooleanType isInLowerHalfOpenInterval( uint pointIdx,
557  double _time
558  ) const;
559 
560 
571  returnValue getSubGrid( double tStart,
572  double tEnd,
573  Grid& _subGrid
574  ) const;
575 
576 
581  returnValue print( ) const;
582 
583 
584 
585  //
586  // PROTECTED MEMBER FUNCTIONS:
587  //
588  protected:
589 
596  returnValue setupEquidistant( double _firstTime,
597  double _lastTime
598  );
599 
605  int findNextIndex( ) const;
606 
607 
608  //
609  // DATA MEMBERS:
610  //
611  protected:
612 
614  double* times;
615 };
616 
617 
619 
620 #include <acado/variables_grid/grid.ipp>
621 
622 #endif // ACADO_TOOLKIT_GRID_HPP
623 
624 /*
625  * end of file
626  */
returnValue setTime(double _time)
Definition: grid.cpp:307
BooleanType isInLowerHalfOpenInterval(uint pointIdx, double _time) const
int findLastTime(double _time, uint startIdx=0) const
Definition: grid.cpp:561
returnValue merge(const Grid &arg, MergeMethod _mergeMethod=MM_DUPLICATE, BooleanType keepOverlap=BT_TRUE)
Definition: grid.cpp:358
double getTime(uint pointIdx) const
BooleanType operator!=(const Grid &arg) const
int findTime(double _time, uint startIdx=0) const
Definition: grid.cpp:531
double getFirstTime() const
uint getCeilIndex(double time) const
Definition: grid.cpp:625
BooleanType operator<=(const Grid &arg) const
BooleanType isEquidistant() const
Allows to pass back messages to the calling function.
Grid()
Definition: grid.cpp:47
BEGIN_NAMESPACE_ACADO typedef unsigned int uint
Definition: acado_types.hpp:42
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
BooleanType isEmpty() const
BooleanType operator>(const Grid &arg) const
uint getLastIndex() const
#define CLOSE_NAMESPACE_ACADO
returnValue equalizeGrids(Grid &arg)
Definition: grid.cpp:293
BooleanType isInInterval(double _time) const
returnValue getSubGrid(double tStart, double tEnd, Grid &_subGrid) const
Definition: grid.cpp:655
returnValue print() const
Definition: grid.cpp:700
uint getFloorIndex(double time) const
Definition: grid.cpp:593
double * times
Definition: grid.hpp:614
BooleanType operator==(const Grid &arg) const
Grid & operator&(const Grid &arg)
Definition: grid.cpp:212
double getIntervalLength() const
BooleanType operator>=(const Grid &arg) const
uint nPoints
Definition: grid.hpp:613
returnValue coarsenGrid(uint factor)
Definition: grid.cpp:506
Grid & operator=(const Grid &rhs)
Definition: grid.cpp:185
returnValue refineGrid(uint factor)
Definition: grid.cpp:477
returnValue init(uint _nPoints=0, const double *const _times=0)
Definition: grid.cpp:107
void rhs(const real_t *x, real_t *f)
returnValue scaleTimes(double scaling)
Definition: grid.cpp:460
#define BT_TRUE
Definition: acado_types.hpp:47
returnValue setupEquidistant(double _firstTime, double _lastTime)
Definition: grid.cpp:715
Grid & shiftTimes(double timeShift)
Definition: grid.cpp:449
uint getNumIntervals() const
returnValue addTime(double _time)
Definition: grid.cpp:339
int findFirstTime(double _time, uint startIdx=0) const
Definition: grid.cpp:539
uint getNumPoints() const
BooleanType isLast(uint pointIdx) const
BooleanType hasTime(double _time) const
Definition: grid.cpp:520
double getLastTime() const
#define BEGIN_NAMESPACE_ACADO
BooleanType operator<(const Grid &arg) const
MergeMethod
BooleanType isInUpperHalfOpenInterval(uint pointIdx, double _time) const
~Grid()
Definition: grid.cpp:100
int findNextIndex() const
Definition: grid.cpp:741


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