Exemplo n.º 1
0
bool interpolator::update( const double currentTime, float& p )
{
    bool bContinue;
    if( currentTime >= _dDestTime )
    {
        p = _fDestValue;
        if( m_listParams.size () )
        {
            interpolatorParam& item = m_listParams.front();
            set(_fDestValue, item.fDestValue, item.type, item.dDuration );
            m_listParams.pop_front();

            bContinue = true;
        }
        else
        {
            bContinue = false;
        }
    }
    else
    {
        float t = (float)(currentTime - _dStartTime);
        float d = (float)(_dDestTime - _dStartTime);
        float b = _fStartValue;
        float c = _fDestValue - _fStartValue;
        p = getFormula(_type, t, b, d, c);

        bContinue = true;
    }
    return bContinue;
}
Exemplo n.º 2
0
  void Residue::setModification(const String & modification)
  {
    //modification_ = modification;

    ModificationsDB * mod_db = ModificationsDB::getInstance();
    ResidueModification mod = mod_db->getModification(one_letter_code_, modification, ResidueModification::ANYWHERE);

    modification_ = mod.getId();
    // update all the members
    if (mod.getAverageMass() != 0)
    {
      average_weight_ = mod.getAverageMass();
    }
    if (mod.getMonoMass() != 0)
    {
      mono_weight_ = mod.getMonoMass();
    }

    bool updated_formula(false);
    if (!mod.getDiffFormula().isEmpty())
    {
      updated_formula = true;
      setFormula(getFormula() + mod.getDiffFormula());
    }
    if (mod.getFormula() != "" && !updated_formula)
    {
      updated_formula = true;
      String formula = mod.getFormula();
      formula.removeWhitespaces();
      formula_ = EmpiricalFormula(formula);
    }

    if (updated_formula)
    {
      average_weight_ = formula_.getAverageWeight();
      mono_weight_ = formula_.getMonoWeight();
    }
    else
    {
      if (mod.getAverageMass() != 0)
      {
        average_weight_ = mod.getAverageMass();
      }
      if (mod.getMonoMass() != 0)
      {
        mono_weight_ = mod.getMonoMass();
      }
    }

    // neutral losses
    loss_formulas_.clear();
    loss_names_.clear();
    if (mod.hasNeutralLoss())
    {
      loss_formulas_.push_back(mod.getNeutralLossDiffFormula());
      loss_names_.push_back(mod.getNeutralLossDiffFormula().toString());
    }

    is_modified_ = true;
  }
Exemplo n.º 3
0
string itsProblem::getInformations()
{
  // separator used to format output
  string sep = ":\t";
  
  // put all in the stream
  stringstream msg;
  msg << "Key" << sep << getKey() << endl;
  msg << "Name" << sep << getName() << endl;
  msg << "Description" << sep << getDescription() << endl;
  msg << "Formula" << sep << getFormula() << endl;
  msg << "Dimension" << sep << getDimension() << (isDimensionFixed()?" (fixed)":" (not fixed)") << endl;
  

  if ( getOptima().size() <= 0 ) {
      msg << "Optimum Unknown" << endl;
  } else {
      // print vectors of the optimums
      for(unsigned int i=0;i<getOptima().size();i++) {
          if(getOptima().size()>1) {
              msg << "Optimum " << i << sep;
          } else {
              msg << "Optimum " << sep;
          }
          msg << "<"
          << print(getOptima()[i].getValues()," ");
          msg << "> @ <"
          << print(getOptima()[i].getSolution()," ");
          msg << ">";
          msg << endl;
      }
  }

  // print vectors of bounds
  msg << "Bounds" << sep << "[";
  for(unsigned int i=0;i<getBounds().size();i++) {
      msg << "["
      << print(getBounds()[i]," ");
      msg << "]";
  }
  msg << "]" << endl;

  msg << "Reference" << sep << getCitation() << endl;

  // return only the string
  return msg.str();  
}
Exemplo n.º 4
0
string itsProblem::getInformations_XML()
{
  // put all in the stream
  stringstream msg;
  
  msg << "<problem>" << endl;

  msg << "<key>" << getKey() << "</key>" << endl;
  msg << "<name>" << getName() << "</name>" << endl;
  msg << "<description>" << getDescription() << "</description>" << endl;
  msg << "<formula>" << getFormula() << "</formula>" << endl;
  msg << "<dimension>" << getDimension() << "</dimension>" << endl;
  msg << "<accuracy>" << getAccuracy() << "</accuracy>" << endl;
  

  msg << "<optimums>" << endl;
  if ( getOptima().size() <= 0 ) {
      msg << "Unknown";
  } else {
      // print vectors of the optimums
      for(unsigned int i=0;i<getOptima().size();i++) { 
          if(getOptima().size()>1) {
              msg << "<point id=\"" << i << "\">" << "<values>";
          } else {
              msg << "<point>" << "<values>";
          }
          
          msg << print(getOptima()[i].getValues()," ");
          msg << "</values>" << "<solution>";
          msg << print(getOptima()[i].getSolution()," ");
          msg << "</solution>" << "</point>" << endl;
      
      }
  }
  msg << "</optimums>" << endl;

  // print vectors of bounds
  msg << "<bounds>" << endl;

  msg << "<minimums>";
    msg << "<point>" << "<solution>";
    msg << print( getBoundsMinima(), " ");
    msg << "</solution>" << "</point>";
  msg << "</minimums>" << endl;

  msg << "<maximums>";
    msg << "<point>" << "<solution>";
    msg << print( getBoundsMaxima(), " ");
    msg << "</solution>" << "</point>";
  msg << "</maximums>" << endl;

  msg << "</bounds>" << endl;

  // references
  msg << "<reference>" << getCitation() << "</reference>" << endl;


  msg << "</problem>" << endl;

  // return only the string
  return msg.str();  
}