Ejemplo n.º 1
0
///////////////////////////////////////////////////////////////////
//
// Function Name:	updateQFactorStats
// Description:		Updates the Q Factor stats
//
///////////////////////////////////////////////////////////////////
void Edge::updateQFactorStats(size_t ci, long long int wavelength) {
  ResourceManager *rm = threadZero->getResourceManager();

#ifndef NO_ALLEGRO
  thdIndx = ci;  // TODO: put this in a location where it isn't repeated.
#endif

  double time = threads[ci]->getGlobalTime();

  for (std::list<void *>::iterator iter = establishedConnections.begin();
       iter != establishedConnections.end(); ++iter) {
    EstablishedConnection *ec = static_cast<EstablishedConnection *>(*iter);

    if (abs(ec->wavelength - int(wavelength)) <=
        threadZero->getQualityParams().nonlinear_halfwin) {
      if (ec->QTimes->size() == 0) {
        double xpm = 0.0;
        double fwm = 0.0;
        double ase = 0.0;

        ec->QFactors->push_back(
            double(rm->estimate_Q(ec->wavelength, ec->connectionPath,
                                  ec->connectionLength, &xpm, &fwm, &ase, ci)));

        ec->QTimes->push_back(time);

        ec->initQFactor = double(ec->QFactors->at(0));
      } else if (ec->QTimes->back() != time) {
        double xpm = 0.0;
        double fwm = 0.0;
        double ase = 0.0;

        ec->QFactors->push_back(
            double(rm->estimate_Q(ec->wavelength, ec->connectionPath,
                                  ec->connectionLength, &xpm, &fwm, &ase, ci)));

        ec->QTimes->push_back(time);
      }
    }
  }
}
Ejemplo n.º 2
0
///////////////////////////////////////////////////////////////////
//
// Function Name:	updateQMDegredation
// Description:		Updates the usage of the edges
//
///////////////////////////////////////////////////////////////////
void Edge::updateQMDegredation(size_t ci, long long int wavelength) {
  ResourceManager *rm = threadZero->getResourceManager();

#ifndef NO_ALLEGRO
  thdIndx = ci;
#endif

  double time = threads[ci]->getGlobalTime();

  for (std::list<void *>::iterator iter = establishedConnections.begin();
       iter != establishedConnections.end(); ++iter) {
    EstablishedConnection *ec = static_cast<EstablishedConnection *>(*iter);

    for (size_t p = 0; p < ec->connectionLength; ++p) {
      if (ec->connectionPath[p] == this &&
          abs(ec->wavelength - int(wavelength)) <=
              threadZero->getQualityParams().nonlinear_halfwin) {
        double xpm = 0.0;
        double fwm = 0.0;
        double ase = 0.0;

        double source_noise = 0.0;
        double source_Q = 0.0;

        double dest_noise = 0.0;
        double dest_Q = 0.0;

        if (p == 0) {
          source_noise =
              threadZero->getQualityParams()
                  .ASE_perEDFA[threadZero->getQualityParams().halfwavelength];
        } else {
          source_Q = rm->estimate_Q(ec->wavelength, ec->connectionPath, p, &xpm,
                                    &fwm, &ase, ci);

          source_noise = pow(threadZero->getQualityParams().channel_power /
                                 pow(10.0, source_Q / 10.0),
                             2.0);
        }

        dest_Q = rm->estimate_Q(ec->wavelength, ec->connectionPath, p + 1, &xpm,
                                &fwm, &ase, ci);

        dest_noise = pow(threadZero->getQualityParams().channel_power /
                             pow(10.0, dest_Q / 10.0),
                         2.0);

        degredation[ec->wavelength] =
            10.0 * log10(sqrt(dest_noise) / sqrt(source_noise));

        if (threadZero->getQualityParams().q_factor_stats == true &&
            p == ec->connectionLength - 1) {
          if (ec->QFactors->size() == 0) ec->initQFactor = double(dest_Q);

          ec->QFactors->push_back(double(dest_Q));
          ec->QTimes->push_back(time);
        }

        break;
      }
    }
  }

  size_t activeLightpaths = 0;
  double cumulativeDegradation = 0.0;

  for (size_t w = 0; w < threadZero->getNumberOfWavelengths(); ++w) {
    if (degredation[w] != 0.0) {
      cumulativeDegradation += degredation[w];
      ++activeLightpaths;
    }
  }

  if (activeLightpaths == threadZero->getNumberOfWavelengths())
    QMDegredation = std::numeric_limits<double>::infinity();
  else if (activeLightpaths == 0)
    QMDegredation = 2.0;
  else if (activeLightpaths > 0)
    QMDegredation = double(cumulativeDegradation) / double(activeLightpaths);
}