本文整理汇总了C++中VariablesGrid类的典型用法代码示例。如果您正苦于以下问题:C++ VariablesGrid类的具体用法?C++ VariablesGrid怎么用?C++ VariablesGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VariablesGrid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getCeilIndex
VariablesGrid VariablesGrid::getTimeSubGrid( double startTime,
double endTime
) const
{
uint startIdx = getCeilIndex( startTime );
uint endIdx = getFloorIndex( endTime );
VariablesGrid newVariablesGrid;
if ( ( isInInterval( startTime ) == BT_FALSE ) || ( isInInterval( endTime ) == BT_FALSE ) )
return newVariablesGrid;
if ( ( startIdx >= getNumPoints( ) ) || ( endIdx >= getNumPoints( ) ) )
return newVariablesGrid;
// if ( startIdx > endIdx )
// return newVariablesGrid;
// add all matrices in interval (constant interpolation)
if ( ( hasTime( startTime ) == BT_FALSE ) && ( startIdx > 0 ) )
newVariablesGrid.addMatrix( *(values[ startIdx-1 ]),startTime );
for( uint i=startIdx; i<=endIdx; ++i )
newVariablesGrid.addMatrix( *(values[i]),getTime( i ) );
if ( hasTime( endTime ) == BT_FALSE )
newVariablesGrid.addMatrix( *(values[ endIdx ]),endTime );
return newVariablesGrid;
}
开发者ID:rtkg,项目名称:acado,代码行数:30,代码来源:variables_grid.cpp
示例2: getCurrentReference
returnValue Controller::getCurrentReference( double tStart,
VariablesGrid& _yRef
) const
{
double tEnd = tStart + controlLaw->getLengthPredictionHorizon( );
// if no external reference trajectory is given, evaluate internal one
if ( _yRef.isEmpty( ) == BT_TRUE )
{
if ( referenceTrajectory != 0 )
referenceTrajectory->getReference( tStart,tEnd, _yRef );
}
// if prediction shall not be used, only use first value
int useReferencePrediction = 0;
get( USE_REFERENCE_PREDICTION,useReferencePrediction );
if ( (BooleanType)useReferencePrediction == BT_FALSE )
{
Vector firstVector = _yRef.getFirstVector( );
Grid predictionGrid( tStart,tEnd );
_yRef.init( firstVector,predictionGrid );
}
return SUCCESSFUL_RETURN;
}
开发者ID:rtkg,项目名称:acado,代码行数:26,代码来源:controller.cpp
示例3: ACADOERROR
returnValue PeriodicReferenceTrajectory::getReference( double tStart,
double tEnd,
VariablesGrid& _yRef
) const
{
if ( acadoIsStrictlyGreater( tStart,tEnd ) == BT_TRUE )
return ACADOERROR( RET_INVALID_ARGUMENTS );
double T = yRef.getLastTime() - yRef.getFirstTime(); // cycle duration
int nStart = (int)floor( (double) (tStart/T+100.0*EPS) ); // cycle number at start
int nEnd = (int)floor( (double) (tEnd /T-100.0*EPS) ); // cycle number at end
if ( nStart == nEnd )
{
_yRef = (yRef.getTimeSubGrid( tStart-T*(double)nStart,tEnd-T*(double)nStart )).shiftTimes( T*(double)nStart );
}
else
{
_yRef = (yRef.getTimeSubGrid( tStart-T*(double)nStart,yRef.getLastTime() )).shiftTimes( T*(double)nStart );
for( int i=nStart+1; i<nEnd; ++i )
_yRef.appendTimes( VariablesGrid(yRef).shiftTimes( T*(double)i ),MM_KEEP );
_yRef.appendTimes( (yRef.getTimeSubGrid( yRef.getFirstTime(),tEnd-T*(double)nEnd )).shiftTimes( T*(double)nEnd ) );
}
return SUCCESSFUL_RETURN;
}
开发者ID:OspreyX,项目名称:acado,代码行数:28,代码来源:periodic_reference_trajectory.cpp
示例4: main
/* >>> start tutorial code >>> */
int main( ){
USING_NAMESPACE_ACADO
// DEFINE A RIGHT-HAND-SIDE:
// -------------------------
DifferentialState x;
AlgebraicState z;
Parameter p,q;
DifferentialEquation f;
f << dot(x) == -p*x*x*z ;
f << 0 == q*q - z*z;
// DEFINE AN INTEGRATOR:
// ---------------------
IntegratorBDF integrator(f);
integrator.set( INTEGRATOR_PRINTLEVEL, HIGH );
// DEFINE INITIAL VALUES:
// ----------------------
double x0 = 1.0;
double z0 = 1.000000;
double pp[2] = { 1.0, 1.0 };
double t0 = 0.0 ;
double tend = 0.2 ;
// START THE INTEGRATION:
// ----------------------
//integrator.freezeAll();
integrator.integrate( t0, tend, &x0, &z0, pp );
// GET THE RESULTS
// ---------------
VariablesGrid differentialStates;
VariablesGrid algebraicStates ;
integrator.getX ( differentialStates );
integrator.getXA( algebraicStates );
differentialStates.print( "x" );
algebraicStates.print( "z" );
return 0;
}
开发者ID:OspreyX,项目名称:acado,代码行数:59,代码来源:simple_dae.cpp
示例5: fopen
returnValue OptimizationAlgorithmBase::initializeDisturbances( const char* fileName)
{
VariablesGrid tmp = fopen( fileName,"r" );
if ( tmp.isEmpty() == BT_TRUE )
return RET_FILE_CAN_NOT_BE_OPENED;
return initializeDisturbances(tmp);
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:9,代码来源:optimization_algorithm_base.cpp
示例6: tmp_ub
returnValue Constraint::add( const int index_, const ConstraintComponent& component ) {
Vector tmp_ub(grid.getNumPoints());
Vector tmp_lb(grid.getNumPoints());
ASSERT_RETURN( index_ < (int) grid.getNumPoints() ).addMessage("\n >>> The constraint component can not be set as the associated discretization point is not in the time horizon. <<< \n\n");
uint run1;
if( component.hasLBgrid() == 0 ) {
for( run1 = 0; run1 < grid.getNumPoints(); run1++ ) {
if( (component.getLB()).getDim() == 1 )
tmp_lb(run1) = (component.getLB()).operator()(0);
else {
if( (component.getLB()).getDim() <= run1 )
return ACADOWARNING(RET_INFEASIBLE_CONSTRAINT);
tmp_lb(run1) = (component.getLB()).operator()(run1);
}
}
}
else {
VariablesGrid LBgrid = component.getLBgrid();
for( run1 = 0; run1 < grid.getNumPoints(); run1++ ) {
Vector tmp = LBgrid.linearInterpolation( grid.getTime(run1) );
tmp_lb(run1) = tmp(0);
}
}
if( component.hasUBgrid() == 0 ) {
for( run1 = 0; run1 < grid.getNumPoints(); run1++ ) {
if( (component.getUB()).getDim() == 1 )
tmp_ub(run1) = (component.getUB()).operator()(0);
else {
if( (component.getUB()).getDim() <= run1 )
return ACADOWARNING(RET_INFEASIBLE_CONSTRAINT);
tmp_ub(run1) = (component.getUB()).operator()(run1);
}
}
}
else {
VariablesGrid UBgrid = component.getUBgrid();
for( run1 = 0; run1 < grid.getNumPoints(); run1++ ) {
Vector tmp = UBgrid.linearInterpolation( grid.getTime(run1) );
tmp_ub(run1) = tmp(0);
}
}
ACADO_TRY( add( index_, tmp_lb(index_), component.getExpression(), tmp_ub(index_) ) );
return SUCCESSFUL_RETURN;
}
开发者ID:rtkg,项目名称:acado,代码行数:57,代码来源:constraint.cpp
示例7: fopen
returnValue SimulationEnvironment::initializeAlgebraicStates( const char* fileName )
{
VariablesGrid tmp = fopen( fileName,"r" );
if ( tmp.isEmpty( ) == BT_TRUE )
return ACADOERROR( RET_FILE_CAN_NOT_BE_OPENED );
return initializeAlgebraicStates( tmp );
}
开发者ID:rtkg,项目名称:acado,代码行数:9,代码来源:simulation_environment.cpp
示例8: readFromFile
returnValue OCP::minimizeLSQ( const Function &h,
const char* rFilename ){
VariablesGrid r = readFromFile( rFilename );
if( r.isEmpty() == BT_TRUE )
return ACADOERROR( RET_FILE_CAN_NOT_BE_OPENED );
return minimizeLSQ( h,r );
}
开发者ID:rtkg,项目名称:acado,代码行数:10,代码来源:ocp.cpp
示例9: checkInputConsistency
/* identitical to same function within the class Process! */
returnValue Actuator::checkInputConsistency( const VariablesGrid& _u,
const VariablesGrid& _p
) const
{
if ( _u.getNumPoints( ) < 2 )
return ACADOERROR( RET_INVALID_ARGUMENTS );
if ( _u.getNumRows( ) != getNU( ) )
return ACADOERROR( RET_CONTROL_DIMENSION_MISMATCH );
if ( _p.isEmpty( ) == BT_TRUE )
{
if ( getNP( ) > 0 )
return ACADOERROR( RET_PARAMETER_DIMENSION_MISMATCH );
}
else
{
if ( _p.getNumPoints( ) < 2 )
return ACADOERROR( RET_INVALID_ARGUMENTS );
if ( _p.getNumRows( ) != getNP( ) )
return ACADOERROR( RET_PARAMETER_DIMENSION_MISMATCH );
if ( acadoIsEqual( _u.getFirstTime( ),_p.getFirstTime( ) ) == BT_FALSE )
return ACADOERROR( RET_INVALID_ARGUMENTS );
if ( acadoIsEqual( _u.getLastTime( ),_p.getLastTime( ) ) == BT_FALSE )
return ACADOERROR( RET_INVALID_ARGUMENTS );
}
return SUCCESSFUL_RETURN;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:33,代码来源:actuator.cpp
示例10: addSensorNoise
returnValue Sensor::addSensorNoise( VariablesGrid& _y
) const
{
if ( hasNoise( ) == BT_FALSE )
return SUCCESSFUL_RETURN;
// generate current noise
VariablesGrid currentNoise;
if ( generateNoise( _y.getFirstTime(),_y.getLastTime(),currentNoise ) != SUCCESSFUL_RETURN )
return ACADOERROR( RET_GENERATING_NOISE_FAILED );
// determine common grid
Grid commonGrid, tmpGrid;
_y.getGrid( commonGrid );
currentNoise.getGrid( tmpGrid );
commonGrid.merge( tmpGrid,MM_KEEP );
// adapt input grids and add noise
_y.refineGrid( commonGrid );
currentNoise.refineGrid( commonGrid );
_y += currentNoise.getValuesSubGrid( 0,getNY()-1 );
return SUCCESSFUL_RETURN;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:25,代码来源:sensor.cpp
示例11: deadTimes
returnValue Sensor::getDelayedOutputGrid( const VariablesGrid& _y,
VariablesGrid& _yDelayed
) const
{
// determine common time grid for delayed outputs:
Grid delayedOutputTimeGrid = lastSignal.getTimePoints( );
// make sure that last time instant of horizon lies within the grid
if ( acadoIsEqual( lastSignal.getLastTime(),_y.getLastTime( ) ) == BT_FALSE )
delayedOutputTimeGrid.addTime( _y.getLastTime( ) );
// add grids of all delayed output components
for( uint i=0; i<getNY( ); ++i )
delayedOutputTimeGrid.merge( _y.getTimePoints( ).shiftTimes( deadTimes(i) ),MM_REPLACE );
VariablesGrid tmp;
// setup common variables grid for delayed inputs
_yDelayed.init( );
for( uint i=0; i<getNY( ); ++i )
{
tmp = lastSignal( i );
tmp.merge( _y( i ).shiftTimes( deadTimes(i) ),MM_REPLACE,BT_FALSE );
tmp.refineGrid( delayedOutputTimeGrid );
_yDelayed.appendValues( tmp );
}
return SUCCESSFUL_RETURN;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:31,代码来源:sensor.cpp
示例12: getParameters
returnValue OptimizationAlgorithmBase::getParameters( Vector &p_ ) const
{
if( nlpSolver == 0 ) return ACADOWARNING( RET_MEMBER_NOT_INITIALISED );
VariablesGrid tmp;
returnValue returnvalue = nlpSolver->getParameters( tmp );
if ( returnvalue != SUCCESSFUL_RETURN )
return returnvalue;
p_ = tmp.getVector( 0 );
return SUCCESSFUL_RETURN;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:14,代码来源:optimization_algorithm_base.cpp
示例13: ASSERT
VariablesGrid VariablesGrid::operator[]( const uint pointIdx
) const
{
ASSERT( values != 0 );
if ( pointIdx >= getNumPoints( ) )
{
ACADOERROR( RET_INVALID_ARGUMENTS );
return VariablesGrid();
}
VariablesGrid pointGrid;
pointGrid.addMatrix( *(values[pointIdx]),getTime( pointIdx ) );
return pointGrid;
}
开发者ID:rtkg,项目名称:acado,代码行数:15,代码来源:variables_grid.cpp
示例14: step
returnValue PIDcontroller::step( double currentTime,
const Vector& _x,
const Vector& _p,
const VariablesGrid& _yRef
)
{
if ( getStatus( ) != BS_READY )
return ACADOERROR( RET_BLOCK_NOT_READY );
if ( _x.getDim( ) != getNumInputs( ) )
return ACADOERROR( RET_VECTOR_DIMENSION_MISMATCH );
/* 1) Use reference trajectory if it is defined */
// set default reference to zero
Vector xRef( _x.getDim() );
if ( _yRef.getNumPoints( ) > 0 )
{
if ( _yRef.getNumValues( ) != getNumInputs( ) )
return ACADOERROR( RET_VECTOR_DIMENSION_MISMATCH );
xRef = _yRef.getVector( 0 );
}
else
{
xRef.setZero( );
}
/* 2) Determine PID control action. */
if ( getNumOutputs( ) > 0 )
{
if ( determineControlAction( xRef-_x,u ) != SUCCESSFUL_RETURN )
return ACADOERROR( RET_CONTROLLAW_STEP_FAILED );
}
else
u.init();
p = _p;
/* 3) Call output transformator. */
if ( clipSignals( u,p ) != SUCCESSFUL_RETURN )
return ACADOERROR( RET_OUTPUTTRANSFORMATOR_STEP_FAILED );
return SUCCESSFUL_RETURN;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:48,代码来源:pid_controller.cpp
示例15: discretize
returnValue Curve::discretize( const Grid &discretizationGrid, VariablesGrid &result ) const{
uint run1 ;
returnValue returnvalue;
Vector tmp ;
result.init( dim, discretizationGrid );
for( run1 = 0; run1 < discretizationGrid.getNumPoints(); run1++ ){
returnvalue = evaluate( discretizationGrid.getTime(run1), tmp );
if( returnvalue != SUCCESSFUL_RETURN )
return returnvalue;
result.setVector(run1,tmp);
}
return SUCCESSFUL_RETURN;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:16,代码来源:curve.cpp
示例16: delayActuatorInput
returnValue Actuator::delayActuatorInput( VariablesGrid& _u,
VariablesGrid& _p
)
{
if ( hasDeadTime( ) == BT_FALSE )
{
// store last signal
Vector tmp = _u.getLastVector( );
if ( _p.isEmpty( ) == BT_FALSE )
tmp.append( _p.getLastVector( ) );
lastSignal.init( tmp );
lastSignal.setTime( 0,_u.getLastTime( ) );
return SUCCESSFUL_RETURN;
}
else
{
double startTime = _u.getFirstTime( );
double endTime = _u.getLastTime( );
// determine variables grid of delayed input
VariablesGrid uDelayed, pDelayed;
if ( getDelayedInputGrids( _u,_p, uDelayed,pDelayed ) != SUCCESSFUL_RETURN )
return ACADOERROR( RET_DELAYING_INPUTS_FAILED );
// store last signal
lastSignal = uDelayed.getTimeSubGrid( uDelayed.getFloorIndex( endTime ),uDelayed.getLastIndex( ) );
if ( _p.isEmpty( ) == BT_FALSE )
lastSignal.appendValues( pDelayed.getTimeSubGrid( pDelayed.getFloorIndex( endTime ),pDelayed.getLastIndex( ) ) );
/* printf("u:\n");
_u.print();
printf("p:\n");
_p.print();
printf("uDelayed:\n");
uDelayed.print();
printf("pDelayed:\n");
pDelayed.print();*/
//
// printf("last:\n");
// lastSignal.print();
// crop delayed signal to current horizon
_u = uDelayed.getTimeSubGrid( uDelayed.getFloorIndex( startTime ),uDelayed.getFloorIndex( endTime ) );
if ( _p.isEmpty( ) == BT_FALSE )
_p = pDelayed.getTimeSubGrid( pDelayed.getFloorIndex( startTime ),pDelayed.getFloorIndex( endTime ) );
// printf("u:\n");
// _u.print();
// printf("p:\n");
// _p.print();
return SUCCESSFUL_RETURN;
}
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:57,代码来源:actuator.cpp
示例17: initializeAlgebraicStates
returnValue Controller::initializeAlgebraicStates( const VariablesGrid& _xa_init
)
{
if ( controlLaw != 0 )
controlLaw->initializeAlgebraicStates( _xa_init.getVector(0) );
return SUCCESSFUL_RETURN;
}
开发者ID:rtkg,项目名称:acado,代码行数:8,代码来源:controller.cpp
示例18: getTimeSubGrid
VariablesGrid VariablesGrid::getTimeSubGrid( uint startIdx,
uint endIdx
) const
{
VariablesGrid newVariablesGrid;
if ( ( startIdx >= getNumPoints( ) ) || ( endIdx >= getNumPoints( ) ) )
return newVariablesGrid;
if ( startIdx > endIdx )
return newVariablesGrid;
for( uint i=startIdx; i<=endIdx; ++i )
newVariablesGrid.addMatrix( *(values[i]),getTime( i ) );
return newVariablesGrid;
}
开发者ID:rtkg,项目名称:acado,代码行数:17,代码来源:variables_grid.cpp
示例19: getValuesSubGrid
VariablesGrid VariablesGrid::getValuesSubGrid( uint startIdx,
uint endIdx
) const
{
VariablesGrid newVariablesGrid;
if ( ( startIdx >= getNumValues( ) ) || ( endIdx >= getNumValues( ) ) )
return newVariablesGrid;
if ( startIdx > endIdx )
return newVariablesGrid;
for( uint i=0; i<getNumPoints( ); ++i )
newVariablesGrid.addMatrix( values[i]->getRows( startIdx,endIdx ),getTime( i ) );
return newVariablesGrid;
}
开发者ID:rtkg,项目名称:acado,代码行数:17,代码来源:variables_grid.cpp
示例20: appendTimes
returnValue VariablesGrid::appendTimes( const VariablesGrid& arg,
MergeMethod _mergeMethod
)
{
// nothing to do for empty grids
if ( arg.getNumPoints( ) == 0 )
return SUCCESSFUL_RETURN;
if ( getNumPoints( ) == 0 )
{
*this = arg;
return SUCCESSFUL_RETURN;
}
// consistency check
if ( acadoIsGreater( arg.getFirstTime( ),getLastTime( ) ) == BT_FALSE )
return ACADOERROR( RET_INVALID_ARGUMENTS );
if ( acadoIsEqual( getLastTime( ),arg.getFirstTime( ) ) == BT_FALSE )
{
// simply append
for( uint i=0; i<arg.getNumPoints( ); ++i )
addMatrix( *(arg.values[i]),arg.getTime( i ) );
}
else
{
// if last and first time point coincide, merge as specified
switch ( _mergeMethod )
{
case MM_KEEP:
break;
case MM_REPLACE:
setVector( getLastIndex(),arg.getFirstVector( ) );
break;
case MM_DUPLICATE:
addMatrix( *(arg.values[0]),arg.getTime( 0 ) );
break;
}
// simply append all remaining points
for( uint i=1; i<arg.getNumPoints( ); ++i )
addMatrix( *(arg.values[i]),arg.getTime( i ) );
}
return SUCCESSFUL_RETURN;
}
开发者ID:rtkg,项目名称:acado,代码行数:48,代码来源:variables_grid.cpp
注:本文中的VariablesGrid类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论