test/min_mean_cycle_test.cc
changeset 1254 c5cd8960df74
parent 956 141f9c0db4a3
child 1270 dceba191c00d
equal deleted inserted replaced
6:15e9263d61ff 7:100ef1225f1a
   108 void checkMmcAlg(const SmartDigraph& gr,
   108 void checkMmcAlg(const SmartDigraph& gr,
   109                  const SmartDigraph::ArcMap<int>& lm,
   109                  const SmartDigraph::ArcMap<int>& lm,
   110                  const SmartDigraph::ArcMap<int>& cm,
   110                  const SmartDigraph::ArcMap<int>& cm,
   111                  int cost, int size) {
   111                  int cost, int size) {
   112   MMC alg(gr, lm);
   112   MMC alg(gr, lm);
   113   alg.findCycleMean();
   113   check(alg.findCycleMean(), "Wrong result");
   114   check(alg.cycleMean() == static_cast<double>(cost) / size,
   114   check(alg.cycleMean() == static_cast<double>(cost) / size,
   115         "Wrong cycle mean");
   115         "Wrong cycle mean");
   116   alg.findCycle();
   116   alg.findCycle();
   117   check(alg.cycleCost() == cost && alg.cycleSize() == size,
   117   check(alg.cycleCost() == cost && alg.cycleSize() == size,
   118         "Wrong path");
   118         "Wrong path");
   208     // Howard
   208     // Howard
   209     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l1, c1,  6, 3);
   209     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l1, c1,  6, 3);
   210     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l2, c2,  5, 2);
   210     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l2, c2,  5, 2);
   211     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l3, c3,  0, 1);
   211     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l3, c3,  0, 1);
   212     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l4, c4, -1, 1);
   212     checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l4, c4, -1, 1);
       
   213     
       
   214     // Howard with iteration limit
       
   215     HowardMmc<GR, IntArcMap> mmc(gr, l1);
       
   216     check((mmc.findCycleMean(2) == HowardMmc<GR, IntArcMap>::ITERATION_LIMIT),
       
   217       "Wrong termination cause");
       
   218     check((mmc.findCycleMean(4) == HowardMmc<GR, IntArcMap>::OPTIMAL),
       
   219       "Wrong termination cause");
   213   }
   220   }
   214 
   221 
   215   return 0;
   222   return 0;
   216 }
   223 }