Auxiliary class for coord calculation.
More...
#include <Nps.h>
Detailed Description
Auxiliary class for coord calculation.
Definition at line 62 of file Nps.h.
Constructor & Destructor Documentation
CoordCalcFunction::CoordCalcFunction |
( |
const std::vector< LandmarkDataEntry > |
myLandmarks | ) |
|
|
inline |
Definition at line 71 of file Nps.h.
Member Function Documentation
Definition at line 711 of file Nps.cc.
Referenced by f().
{
double sum_of_squares = 0.0;
for (
int i = 0; i < nodeCoordinates.
size(); i++) {
sum_of_squares += pow(landmark.
coordinates[i] - nodeCoordinates[i], 2);
}
double result = sqrt(sum_of_squares);
return result;
}
double CoordCalcFunction::f |
( |
const Vec_DP & |
initCoordinates | ) |
const |
Definition at line 691 of file Nps.cc.
Referenced by simplex_min().
{
double sum = 0;
double rel_diff = 0;
for (uint i = 0; i <
landmarks.size(); i++) {
double diff = SIMTIME_DBL(
landmarks[i].rtt) / 2 * 1000 -
rel_diff = diff / (SIMTIME_DBL(
landmarks[i].rtt) / 2 * 1000);
} else {
opp_error("[CBR] RTT == 0. Node is landmark? This shouldn't happen.");
}
sum += rel_diff * rel_diff;
}
return sum;
}
Definition at line 620 of file Nps.cc.
Referenced by Nps::computeOwnCoordinates().
{
double accf = 0.0000001;
double accx = 0.0000001;
uint32_t nmax = 30001;
uint8_t dim = init.
size();
int ihi;
double vhi;
double vre;
double vlo, diff;
uint32_t count;
spx.functionObject = functionObject;
spx[0] = init;
for (uint8_t i = 0; i < dim; i++) {
tmp[i] = 1;
spx[i+1] = init + tmp;
tmp[i] = 0;
}
for (count = 1; count <= nmax; count++) {
ihi = spx.high(&vhi);
phi = spx[ihi];
spx.reflect();
vre = functionObject->
f(spx[ihi]);
if (vre < functionObject->
f(spx[spx.low()])) {
spx[ihi] = phi;
spx.reflect_exp();
vre = functionObject->
f(spx[ihi]);
if (vre > functionObject->
f(spx[spx.low()])) {
spx[ihi] = phi;
spx.reflect();
}
} else if (vre >= vhi) {
spx[ihi] = phi;
spx.contract();
if (functionObject->
f(spx[ihi]) > vhi) {
spx[ihi] = phi;
spx.reduce();
}
}
spx.high(&vhi);
spx.low(&vlo);
diff = vhi - vlo;
if (diff < accf)
if (spx.size() < accx)
break;
}
init = spx[spx.low()];
return vlo;
}
Member Data Documentation
Definition at line 65 of file Nps.h.
Referenced by f().
The documentation for this class was generated from the following files: