19 #ifndef GawronCalculator_h
20 #define GawronCalculator_h
39 template<
class R,
class E,
class V>
48 void setCosts(R* route,
const double costs,
const bool isActive =
false)
const {
50 route->setCosts(costs);
52 route->setCosts(
myBeta * costs + ((
double) 1.0 -
myBeta) * route->getCosts());
58 for (
typename std::vector<R*>::iterator i = alternatives.begin(); i != alternatives.end() - 1; i++) {
60 for (
typename std::vector<R*>::iterator j = i + 1; j != alternatives.end(); j++) {
64 (pS->getCosts() - pR->getCosts()) /
65 (pS->getCosts() + pR->getCosts());
67 double newPR =
gawronF(pR->getProbability(), pS->getProbability(), delta);
68 double newPS = pR->getProbability() + pS->getProbability() - newPR;
70 newPR = pS->getCosts() > pR->getCosts()
72 newPS = pS->getCosts() > pR->getCosts()
75 newPR =
MIN2((
double)
MAX2(newPR, (
double) 0), (
double) 1);
76 newPS =
MIN2((
double)
MAX2(newPS, (
double) 0), (
double) 1);
77 pR->setProbability(newPR);
78 pS->setProbability(newPS);
86 double gawronF(
const double pdr,
const double pds,
const double x)
const {
88 return std::numeric_limits<double>::max();
96 double gawronG(
const double a,
const double x)
const {
97 if (((1.0 - (x * x)) == 0)) {
98 return std::numeric_limits<double>::max();
100 return (
double) exp((a * x) / (1.0 - (x * x)));