COIN-OR::LEMON - Graph Library

Changeset 864:d3ea191c3412 in lemon-1.2 for test


Ignore:
Timestamp:
03/13/10 22:01:38 (9 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Rename min mean cycle classes and their members (#179)
with respect to the possible introduction of min ratio
cycle algorithms in the future.

The renamed classes:

The renamed members:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/min_mean_cycle_test.cc

    r769 r864  
    2626#include <lemon/concept_check.h>
    2727
    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>
    3131
    3232#include "test_tools.h"
     
    6464                       
    6565// Check the interface of an MMC algorithm
    66 template <typename GR, typename Value>
     66template <typename GR, typename Cost>
    6767struct MmcClassConcept
    6868{
     
    7474      typedef typename MMC
    7575        ::template SetPath<ListPath<GR> >
    76         ::template SetLargeValue<Value>
     76        ::template SetLargeCost<Cost>
    7777        ::Create MmcAlg;
    78       MmcAlg mmc(me.g, me.length);
     78      MmcAlg mmc(me.g, me.cost);
    7979      const MmcAlg& const_mmc = mmc;
    8080     
     
    8383     
    8484      b = mmc.cycle(p).run();
    85       b = mmc.findMinMean();
     85      b = mmc.findCycleMean();
    8686      b = mmc.findCycle();
    8787
    88       v = const_mmc.cycleLength();
    89       i = const_mmc.cycleArcNum();
     88      v = const_mmc.cycleCost();
     89      i = const_mmc.cycleSize();
    9090      d = const_mmc.cycleMean();
    9191      p = const_mmc.cycle();
    9292    }
    9393
    94     typedef concepts::ReadMap<typename GR::Arc, Value> LM;
     94    typedef concepts::ReadMap<typename GR::Arc, Cost> CM;
    9595 
    9696    GR g;
    97     LM length;
     97    CM cost;
    9898    ListPath<GR> p;
    99     Value v;
     99    Cost v;
    100100    int i;
    101101    double d;
     
    109109                 const SmartDigraph::ArcMap<int>& lm,
    110110                 const SmartDigraph::ArcMap<int>& cm,
    111                  int length, int size) {
     111                 int cost, int size) {
    112112  MMC alg(gr, lm);
    113   alg.findMinMean();
    114   check(alg.cycleMean() == static_cast<double>(length) / size,
     113  alg.findCycleMean();
     114  check(alg.cycleMean() == static_cast<double>(cost) / size,
    115115        "Wrong cycle mean");
    116116  alg.findCycle();
    117   check(alg.cycleLength() == length && alg.cycleArcNum() == size,
     117  check(alg.cycleCost() == cost && alg.cycleSize() == size,
    118118        "Wrong path");
    119119  SmartDigraph::ArcMap<int> cycle(gr, 0);
     
    149149    typedef concepts::Digraph GR;
    150150
    151     // Karp
     151    // KarpMmc
    152152    checkConcept< MmcClassConcept<GR, int>,
    153                   Karp<GR, concepts::ReadMap<GR::Arc, int> > >();
     153                  KarpMmc<GR, concepts::ReadMap<GR::Arc, int> > >();
    154154    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
    158158    checkConcept< MmcClassConcept<GR, int>,
    159                   HartmannOrlin<GR, concepts::ReadMap<GR::Arc, int> > >();
     159                  HartmannOrlinMmc<GR, concepts::ReadMap<GR::Arc, int> > >();
    160160    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
    164164    checkConcept< MmcClassConcept<GR, int>,
    165                   Howard<GR, concepts::ReadMap<GR::Arc, int> > >();
     165                  HowardMmc<GR, concepts::ReadMap<GR::Arc, int> > >();
    166166    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 LargeValue type");
    171     if (IsSameType<Howard<GR, concepts::ReadMap<GR::Arc, float> >::LargeValue,
    172           double>::result == 0) check(false, "Wrong LargeValue type");
     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");
    173173  }
    174174
     
    195195
    196196    // 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);
    201201
    202202    // 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);
    207207
    208208    // 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);
    213213  }
    214214
Note: See TracChangeset for help on using the changeset viewer.