Example #1
0
 shared_ptr<Option0> Options::get(string aName) {
   _optionMap::const_iterator it = this->optionMap.find(aName);
   if ( it == this->optionMap.end()) {
     throw aException(Options, "Option " + aName + " is not defined.");
   }
   return it->second;
 }
Example #2
0
//------------------------------------------------------------------------------
Real ImpulsiveBurn::SetRealParameter(const Integer id, const Real value)
{
   switch (id)
   {
      // Isp Coefficients
      case ISP:
         if (value >= 0)
            isp = value;
         else
         { 
            BurnException aException(wxT(""));
            aException.SetDetails(errorMessageFormat.c_str(),
                        GmatStringUtil::ToString(value, 16).c_str(),
                        PARAMETER_TEXT[id-DECREMENT_MASS].c_str(), wxT("Real Number >= 0"));
            throw aException;
         }
         return isp;
      case GRAVITATIONAL_ACCELERATION:
         gravityAccel = value;
         return gravityAccel;
      case DELTA_TANK_MASS:
         deltaTankMass = value;
         return deltaTankMass;
      default:
         break;   // Default just drops through
   }
   
   return Burn::SetRealParameter(id, value);
}
Example #3
0
//------------------------------------------------------------------------------
bool ImpulsiveBurn::Initialize()
{
   #ifdef DEBUG_IMPBURN_INIT
   MessageInterface::ShowMessage
      ("ImpulsiveBurn::Initialize() '%s' entered, localCoordSystem=<%p>, "
       "decrementMass=%d, tankNames.size()=%d\n", GetName().c_str(),
       localCoordSystem, decrementMass, tankNames.size());
   #endif
   
   if (!Burn::Initialize())
   {
      #ifdef DEBUG_IMPBURN_INIT
      MessageInterface::ShowMessage
         ("ImpulsiveBurn::Initialize() '%s' returning false\n", GetName().c_str());
      #endif
      return false;
   }
   
   bool retval = false;
   
   if (decrementMass)
   {
      if (!tankNames.empty())
         retval = SetTankFromSpacecraft();
      else
      {
         BurnException aException("");
         aException.SetDetails(errorMessageFormat.c_str(), "",
                     PARAMETER_TEXT[FUEL_TANK-BurnParamCount].c_str(),
                     "Named Fuel Tank");
         throw aException;
      }
   }
   
   if (localCoordSystem == NULL)
      retval = retval | false;
   
   #ifdef DEBUG_IMPBURN_INIT
   MessageInterface::ShowMessage
      ("ImpulsiveBurn::Initialize() '%s' returning %d\n", GetName().c_str(), retval);
   #endif
   
   return retval;
}
Example #4
0
Real BodyFixedPoint::SetRealParameter(const Integer id,
                                      const Real value)
{
   if (id == EPOCH_PARAM)  // from SpacePoint
   {
      A1Mjd a1(value);
      GetMJ2000State(a1);
      return lastStateTime.Get();
   }
   #ifdef DEBUG_BODYFIXED_SET_REAL
      MessageInterface::ShowMessage("Entering BFP::SetRealParameter with id = %d (%s) and value = %12.10f\n",
            id, (GetParameterText(id)).c_str(), value);
//      MessageInterface::ShowMessage("stateType = %s and horizon = %s\n",
//            stateType.c_str(), horizon.c_str());
   #endif
   if (((id == LOCATION_1) || (id == LOCATION_2)) && stateType == "Spherical")
   {
      // if Spherical statetype, then check if Latitude/Longitude are in the correct range
      if (id == LOCATION_1) // latitude
      {
         if ((value >= -90.0) && (value <= 90))
            location[id-LOCATION_1] = value * GmatMathConstants::RAD_PER_DEG;
         else
         {
            AssetException aException("");
            aException.SetDetails(errorMessageFormat.c_str(),
                        GmatStringUtil::ToString(value, 16).c_str(),
                        GetStringParameter(id-LOCATION_1+LOCATION_LABEL_1).c_str(), "Real Number >= -90.0 and <= 90.0");
            throw aException;
         }
      }
      else // longitude (0-360)
         location[id-LOCATION_1] = (GmatMathUtil::Mod(value,360)) * GmatMathConstants::RAD_PER_DEG;
      return location[id-LOCATION_1];
   }
   else if ((id >= LOCATION_1) && (id <= LOCATION_3)) // not Spherical
   {
      location[id-LOCATION_1] = value;
      return location[id-LOCATION_1];
   }

   return SpacePoint::SetRealParameter(id, value);
}
Example #5
0
    shared_ptr<tnmmatrix<TYPE> >  tOLS<TYPE>::GetB()
    {
      if (B) {
	return B;
      }
      
      this->misc.clear();
      TYPE minDeterminant = _typeOpt::read(this->options.get(), "minDeterminant");
      bool _DB_PRINT_DET = _boolOpt::read(this->options.get(), "_DB_PRINT_DET");
      bool _DB_PRINT_XTX = _boolOpt::read(this->options.get(), "_DB_PRINT_XTX");
      
      int MM = this->GetX()->GetCols();
      int NN = this->GetX()->GetRows();
      int KK = this->GetK();
      TYPE rcond;
      TYPE det;
      
      _m Xtrp(MM,NN);
      _m Qinv(MM,MM);
      _m Xtrpyvec(MM,KK);
      _m I(NN,NN);
      B.reset(new _m(MM,KK));
      _mVec bCov;
      _m matrixM(NN,NN);
      _m e(NN,KK);
      _m eTrp(KK,NN);
      _m s2(KK,KK);
      TYPE cond = 0;
      
      I.I();
      if ( MM > 0 )
	{
	  //	tMathTools<TYPE>::PrintMatrix( std::cout , X , 6 , "" , "" , "X: " );
	  //	std::cout << std::flush;
	  
	this->GetX()->Trp( &Xtrp );
	Qinv.Mul( Xtrp , *this->GetX() ); 
	if (_DB_PRINT_XTX)
	  tMathTools<TYPE>::PrintMatrix( std::cout , Qinv , 6 , "" , "" , "X'X: " );

	try {
	  if ( minDeterminant >= 0 ) {
	    det = Qinv.Det();
	    if (_DB_PRINT_DET )
	      std::cout << "|X'X| = " << det << std::endl << std::flush;
	    if ( det <= minDeterminant )
	      throw aException(tOLS<TYPE>, "X'X is singular.");
	  }
	  Qinv.Inv( &rcond );
	} catch ( ... ) {
	  throw aException(tOLS<TYPE>, "Inversion failed!");
	};
	assert( rcond != 0.0 );
	cond = 1.0 / rcond;
	Xtrpyvec.Mul( Xtrp , *this->GetY() );
	B->Mul(Qinv , Xtrpyvec);

	matrixM = I - (*this->GetX()) * Qinv * Xtrp;
	e = matrixM * (*this->GetY());
	e.Trp( &eTrp );
	s2 = (TYPE)( 1.0 / ( NN - MM ) ) * eTrp * e;
	for ( int col = 1 ; col <= KK ; col++ ) {
	  bCov.emplace_back(s2(col,col) * Qinv);
	}
      } else
      B->Cpy(0.0);
    
    
    //Relay non standard fit data to owner
    this->misc["e"] = _mVec(1, e);
    this->misc["s2"] = _mVec(1, s2);
    this->misc["determinant"] = _mVec(1, _m(1,1,det));
    this->misc["conditionNumber"] = _mVec(1, _m(1,1,cond));
    this->misc["bCov"] = _mVec(bCov);
    return B;  
  }
Example #6
0
  TYPE tIntegral<TYPE>::y( const tnmmatrix<TYPE> &x  ) const
  {
    //    _DB( x.PrintTrp( std::cout , "x: \t" ) );
    TYPE res; 
#ifdef _SAFE
    if ( ! DimOk( x.GetRows() ) )
      {
	_DBTHROW( "x dimension not ok." ); 
      }
#endif
    //    _DB( std::cout << "x.GetRows() = " << x.GetRows() << std::endl; );
 
   int actdim = x.GetRows() + 1;


#ifdef _SAFE
    if ( ! f->DimOk( actdim ) )
      _DBTHROW( "! f->DimOk( actdim )" ); 
#endif

    //    this->Dump( std::cout , "* * * " );

    activex->Resize( actdim , 1 );
    for ( int i = 1 ; i <= x.GetRows()  ; i++ )
      activex->Set( i , 1 , x.Get(i,1) );
    
    //    _DB( activex->PrintTrp( std::cout , "x*: \t" ) );

    /*
    _DB( f->Dump( std::cout , "f:\t " ); ); 
    _DB( lb->Dump( std::cout , "lb:\t " ); ); 
    _DB( ub->Dump( std::cout , "ub:\t " ); );
    */

    TYPE lb0,ub0;
    lb0 = lb->y( x );
    ub0 = ub->y( x );

    //    _DB( std::cout << "*lb = " << lb0 << ", *ub = " << ub0 << std::endl; );


    if ( tMathTools<TYPE>::Abs( ub0 - lb0 ) < tFunction0<TYPE>::Epsilon() )
      return 0;
    TYPE abserr;



    // Since throwing inside a catch invokes terminate(), store error message, then throw error 
    string error = "";
    try {
      res = tSlatecTools<TYPE>::QAG( integrand , (void *)this , 
				     (TYPE)lb0 , (TYPE)ub0 , 
				     (TYPE)maxabsoluteerror, 
				     (TYPE)maxrelativeerror, 
				     maxintervals , 
				     abserr ); 
    } 
    catch ( tSlatecError<TYPE> sle )
      {
	error = "Error computing integral.";
	//	sle.Print( std::cerr );
      }
    catch ( ... )
      {
	error = "Error computing integral.";
      }

    if ( error != (string)"" )
      throw aException( tIntegral<TYPE>, error );
    
    return res;
    
  }