Changeset 942:d3ea191c3412 in lemon for test/min_mean_cycle_test.cc
 Timestamp:
 03/13/10 22:01:38 (11 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/min_mean_cycle_test.cc
r816 r942 26 26 #include <lemon/concept_check.h> 27 27 28 #include <lemon/karp .h>29 #include <lemon/hartmann_orlin .h>30 #include <lemon/howard .h>28 #include <lemon/karp_mmc.h> 29 #include <lemon/hartmann_orlin_mmc.h> 30 #include <lemon/howard_mmc.h> 31 31 32 32 #include "test_tools.h" … … 64 64 65 65 // Check the interface of an MMC algorithm 66 template <typename GR, typename Value>66 template <typename GR, typename Cost> 67 67 struct MmcClassConcept 68 68 { … … 74 74 typedef typename MMC 75 75 ::template SetPath<ListPath<GR> > 76 ::template SetLarge Value<Value>76 ::template SetLargeCost<Cost> 77 77 ::Create MmcAlg; 78 MmcAlg mmc(me.g, me. length);78 MmcAlg mmc(me.g, me.cost); 79 79 const MmcAlg& const_mmc = mmc; 80 80 … … 83 83 84 84 b = mmc.cycle(p).run(); 85 b = mmc.find MinMean();85 b = mmc.findCycleMean(); 86 86 b = mmc.findCycle(); 87 87 88 v = const_mmc.cycle Length();89 i = const_mmc.cycle ArcNum();88 v = const_mmc.cycleCost(); 89 i = const_mmc.cycleSize(); 90 90 d = const_mmc.cycleMean(); 91 91 p = const_mmc.cycle(); 92 92 } 93 93 94 typedef concepts::ReadMap<typename GR::Arc, Value> LM;94 typedef concepts::ReadMap<typename GR::Arc, Cost> CM; 95 95 96 96 GR g; 97 LM length;97 CM cost; 98 98 ListPath<GR> p; 99 Valuev;99 Cost v; 100 100 int i; 101 101 double d; … … 109 109 const SmartDigraph::ArcMap<int>& lm, 110 110 const SmartDigraph::ArcMap<int>& cm, 111 int length, int size) {111 int cost, int size) { 112 112 MMC alg(gr, lm); 113 alg.find MinMean();114 check(alg.cycleMean() == static_cast<double>( length) / size,113 alg.findCycleMean(); 114 check(alg.cycleMean() == static_cast<double>(cost) / size, 115 115 "Wrong cycle mean"); 116 116 alg.findCycle(); 117 check(alg.cycle Length() == length && alg.cycleArcNum() == size,117 check(alg.cycleCost() == cost && alg.cycleSize() == size, 118 118 "Wrong path"); 119 119 SmartDigraph::ArcMap<int> cycle(gr, 0); … … 149 149 typedef concepts::Digraph GR; 150 150 151 // Karp 151 // KarpMmc 152 152 checkConcept< MmcClassConcept<GR, int>, 153 Karp <GR, concepts::ReadMap<GR::Arc, int> > >();153 KarpMmc<GR, concepts::ReadMap<GR::Arc, int> > >(); 154 154 checkConcept< MmcClassConcept<GR, float>, 155 Karp <GR, concepts::ReadMap<GR::Arc, float> > >();156 157 // HartmannOrlin 155 KarpMmc<GR, concepts::ReadMap<GR::Arc, float> > >(); 156 157 // HartmannOrlinMmc 158 158 checkConcept< MmcClassConcept<GR, int>, 159 HartmannOrlin <GR, concepts::ReadMap<GR::Arc, int> > >();159 HartmannOrlinMmc<GR, concepts::ReadMap<GR::Arc, int> > >(); 160 160 checkConcept< MmcClassConcept<GR, float>, 161 HartmannOrlin <GR, concepts::ReadMap<GR::Arc, float> > >();162 163 // Howard 161 HartmannOrlinMmc<GR, concepts::ReadMap<GR::Arc, float> > >(); 162 163 // HowardMmc 164 164 checkConcept< MmcClassConcept<GR, int>, 165 Howard <GR, concepts::ReadMap<GR::Arc, int> > >();165 HowardMmc<GR, concepts::ReadMap<GR::Arc, int> > >(); 166 166 checkConcept< MmcClassConcept<GR, float>, 167 Howard <GR, concepts::ReadMap<GR::Arc, float> > >();168 169 if (IsSameType<Howard<GR, concepts::ReadMap<GR::Arc, int> >::LargeValue,170 long_int>::result == 0) check(false, "Wrong LargeValuetype");171 if (IsSameType<Howard<GR, concepts::ReadMap<GR::Arc, float> >::LargeValue,172 double>::result == 0) check(false, "Wrong LargeValuetype");167 HowardMmc<GR, concepts::ReadMap<GR::Arc, float> > >(); 168 169 check((IsSameType<HowardMmc<GR, concepts::ReadMap<GR::Arc, int> > 170 ::LargeCost, long_int>::result == 1), "Wrong LargeCost type"); 171 check((IsSameType<HowardMmc<GR, concepts::ReadMap<GR::Arc, float> > 172 ::LargeCost, double>::result == 1), "Wrong LargeCost type"); 173 173 } 174 174 … … 195 195 196 196 // Karp 197 checkMmcAlg<Karp <GR, IntArcMap> >(gr, l1, c1, 6, 3);198 checkMmcAlg<Karp <GR, IntArcMap> >(gr, l2, c2, 5, 2);199 checkMmcAlg<Karp <GR, IntArcMap> >(gr, l3, c3, 0, 1);200 checkMmcAlg<Karp <GR, IntArcMap> >(gr, l4, c4, 1, 1);197 checkMmcAlg<KarpMmc<GR, IntArcMap> >(gr, l1, c1, 6, 3); 198 checkMmcAlg<KarpMmc<GR, IntArcMap> >(gr, l2, c2, 5, 2); 199 checkMmcAlg<KarpMmc<GR, IntArcMap> >(gr, l3, c3, 0, 1); 200 checkMmcAlg<KarpMmc<GR, IntArcMap> >(gr, l4, c4, 1, 1); 201 201 202 202 // HartmannOrlin 203 checkMmcAlg<HartmannOrlin <GR, IntArcMap> >(gr, l1, c1, 6, 3);204 checkMmcAlg<HartmannOrlin <GR, IntArcMap> >(gr, l2, c2, 5, 2);205 checkMmcAlg<HartmannOrlin <GR, IntArcMap> >(gr, l3, c3, 0, 1);206 checkMmcAlg<HartmannOrlin <GR, IntArcMap> >(gr, l4, c4, 1, 1);203 checkMmcAlg<HartmannOrlinMmc<GR, IntArcMap> >(gr, l1, c1, 6, 3); 204 checkMmcAlg<HartmannOrlinMmc<GR, IntArcMap> >(gr, l2, c2, 5, 2); 205 checkMmcAlg<HartmannOrlinMmc<GR, IntArcMap> >(gr, l3, c3, 0, 1); 206 checkMmcAlg<HartmannOrlinMmc<GR, IntArcMap> >(gr, l4, c4, 1, 1); 207 207 208 208 // Howard 209 checkMmcAlg<Howard <GR, IntArcMap> >(gr, l1, c1, 6, 3);210 checkMmcAlg<Howard <GR, IntArcMap> >(gr, l2, c2, 5, 2);211 checkMmcAlg<Howard <GR, IntArcMap> >(gr, l3, c3, 0, 1);212 checkMmcAlg<Howard <GR, IntArcMap> >(gr, l4, c4, 1, 1);209 checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l1, c1, 6, 3); 210 checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l2, c2, 5, 2); 211 checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l3, c3, 0, 1); 212 checkMmcAlg<HowardMmc<GR, IntArcMap> >(gr, l4, c4, 1, 1); 213 213 } 214 214
Note: See TracChangeset
for help on using the changeset viewer.