returnValue ModelData::setModel( const DifferentialEquation& _f ) { if( rhs_name.empty() && NX2 == 0 ) { differentialEquation = _f; Expression rhs; differentialEquation.getExpression( rhs ); NXA = differentialEquation.getNXA(); NX2 = rhs.getDim() - NXA; if( NDX == 0 ) NDX = _f.getNDX(); // if( _f.getNDX() > 0 && _f.getNDX() != (int)NX2 ) { // TODO: this test returns an error for well-defined models when using a linear input subsystem! // std::cout << "nonlinear model of size " << NX2 << " depends on " << _f.getNDX() << " differential state derivatives!" << std::endl; // return ACADOERROR( RET_INVALID_OPTION ); // } if( NU == 0 ) NU = _f.getNU(); if( NP == 0 ) NP = _f.getNP(); if( NOD == 0 ) NOD = _f.getNOD(); export_rhs = BT_TRUE; } else { return ACADOERROR( RET_INVALID_OPTION ); } return SUCCESSFUL_RETURN; }
returnValue OCPexport::checkConsistency( ) const { // // Consistency checks: // Objective objective; ocp.getObjective( objective ); int hessianApproximation; get( HESSIAN_APPROXIMATION, hessianApproximation ); if ( ocp.hasObjective( ) == true && !((HessianApproximationMode)hessianApproximation == EXACT_HESSIAN && (objective.getNumMayerTerms() == 1 || objective.getNumLagrangeTerms() == 1)) ) { // for Exact Hessian RTI return ACADOERROR( RET_INVALID_OBJECTIVE_FOR_CODE_EXPORT ); } int sensitivityProp; get(DYNAMIC_SENSITIVITY, sensitivityProp); // if( (HessianApproximationMode)hessianApproximation == EXACT_HESSIAN && (ExportSensitivityType) sensitivityProp != THREE_SWEEPS ) { // return ACADOERROR( RET_INVALID_OPTION ); // } DifferentialEquation f; ocp.getModel( f ); // if ( f.isDiscretized( ) == BT_TRUE ) // return ACADOERROR( RET_NO_DISCRETE_ODE_FOR_CODE_EXPORT ); if ( f.getNUI( ) > 0 ) return ACADOERROR( RET_INVALID_ARGUMENTS ); if ( f.getNP( ) > 0 ) return ACADOERRORTEXT(RET_INVALID_ARGUMENTS, "Free parameters are not supported. For the old functionality use OnlineData class."); if ( (HessianApproximationMode)hessianApproximation != GAUSS_NEWTON && (HessianApproximationMode)hessianApproximation != EXACT_HESSIAN ) return ACADOERROR( RET_INVALID_OPTION ); int discretizationType; get( DISCRETIZATION_TYPE,discretizationType ); if ( ( (StateDiscretizationType)discretizationType != SINGLE_SHOOTING ) && ( (StateDiscretizationType)discretizationType != MULTIPLE_SHOOTING ) ) return ACADOERROR( RET_INVALID_OPTION ); return SUCCESSFUL_RETURN; }