COIN-OR::LEMON - Graph Library

Changeset 918:8583fb74238c in lemon-main for test


Ignore:
Timestamp:
01/08/11 15:52:07 (14 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Various search limits for the max clique alg (#405)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/max_clique_test.cc

    r904 r918  
    5959// Check with general graphs
    6060template <typename Param>
    61 void checkMaxCliqueGeneral(int max_sel, Param rule) {
     61void checkMaxCliqueGeneral(Param rule) {
    6262  typedef ListGraph GR;
    6363  typedef GrossoLocatelliPullanMc<GR> McAlg;
     
    6969    GR::NodeMap<bool> map(g);
    7070    McAlg mc(g);
    71     check(mc.run(max_sel, rule) == 0, "Wrong clique size");
     71    mc.iterationLimit(50);
     72    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    7273    check(mc.cliqueSize() == 0, "Wrong clique size");
    7374    check(CliqueIt(mc) == INVALID, "Wrong CliqueNodeIt");
    7475
    7576    GR::Node u = g.addNode();
    76     check(mc.run(max_sel, rule) == 1, "Wrong clique size");
     77    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    7778    check(mc.cliqueSize() == 1, "Wrong clique size");
    7879    mc.cliqueMap(map);
     
    8384   
    8485    GR::Node v = g.addNode();
    85     check(mc.run(max_sel, rule) == 1, "Wrong clique size");
     86    check(mc.run(rule) == McAlg::ITERATION_LIMIT, "Wrong termination cause");
    8687    check(mc.cliqueSize() == 1, "Wrong clique size");
    8788    mc.cliqueMap(map);
     
    9192
    9293    g.addEdge(u, v);
    93     check(mc.run(max_sel, rule) == 2, "Wrong clique size");
     94    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    9495    check(mc.cliqueSize() == 2, "Wrong clique size");
    9596    mc.cliqueMap(map);
     
    111112   
    112113    McAlg mc(g);
    113     check(mc.run(max_sel, rule) == 4, "Wrong clique size");
     114    mc.iterationLimit(50);
     115    check(mc.run(rule) == McAlg::ITERATION_LIMIT, "Wrong termination cause");
    114116    check(mc.cliqueSize() == 4, "Wrong clique size");
    115117    mc.cliqueMap(map);
     
    128130// Check with full graphs
    129131template <typename Param>
    130 void checkMaxCliqueFullGraph(int max_sel, Param rule) {
     132void checkMaxCliqueFullGraph(Param rule) {
    131133  typedef FullGraph GR;
    132134  typedef GrossoLocatelliPullanMc<FullGraph> McAlg;
     
    137139    GR::NodeMap<bool> map(g);
    138140    McAlg mc(g);
    139     check(mc.run(max_sel, rule) == size, "Wrong clique size");
     141    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    140142    check(mc.cliqueSize() == size, "Wrong clique size");
    141143    mc.cliqueMap(map);
     
    151153// Check with grid graphs
    152154template <typename Param>
    153 void checkMaxCliqueGridGraph(int max_sel, Param rule) {
     155void checkMaxCliqueGridGraph(Param rule) {
    154156  GridGraph g(5, 7);
    155157  GridGraph::NodeMap<char> map(g);
    156158  GrossoLocatelliPullanMc<GridGraph> mc(g);
    157   check(mc.run(max_sel, rule) == 2, "Wrong clique size");
     159 
     160  mc.iterationLimit(100);
     161  check(mc.run(rule) == mc.ITERATION_LIMIT, "Wrong termination cause");
     162  check(mc.cliqueSize() == 2, "Wrong clique size");
     163
     164  mc.stepLimit(100);
     165  check(mc.run(rule) == mc.STEP_LIMIT, "Wrong termination cause");
     166  check(mc.cliqueSize() == 2, "Wrong clique size");
     167
     168  mc.sizeLimit(2);
     169  check(mc.run(rule) == mc.SIZE_LIMIT, "Wrong termination cause");
    158170  check(mc.cliqueSize() == 2, "Wrong clique size");
    159171}
     
    161173
    162174int main() {
    163   checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc<ListGraph>::RANDOM);
    164   checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc<ListGraph>::DEGREE_BASED);
    165   checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc<ListGraph>::PENALTY_BASED);
     175  checkMaxCliqueGeneral(GrossoLocatelliPullanMc<ListGraph>::RANDOM);
     176  checkMaxCliqueGeneral(GrossoLocatelliPullanMc<ListGraph>::DEGREE_BASED);
     177  checkMaxCliqueGeneral(GrossoLocatelliPullanMc<ListGraph>::PENALTY_BASED);
    166178
    167   checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc<FullGraph>::RANDOM);
    168   checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc<FullGraph>::DEGREE_BASED);
    169   checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc<FullGraph>::PENALTY_BASED);
     179  checkMaxCliqueFullGraph(GrossoLocatelliPullanMc<FullGraph>::RANDOM);
     180  checkMaxCliqueFullGraph(GrossoLocatelliPullanMc<FullGraph>::DEGREE_BASED);
     181  checkMaxCliqueFullGraph(GrossoLocatelliPullanMc<FullGraph>::PENALTY_BASED);
    170182                       
    171   checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc<GridGraph>::RANDOM);
    172   checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc<GridGraph>::DEGREE_BASED);
    173   checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc<GridGraph>::PENALTY_BASED);
     183  checkMaxCliqueGridGraph(GrossoLocatelliPullanMc<GridGraph>::RANDOM);
     184  checkMaxCliqueGridGraph(GrossoLocatelliPullanMc<GridGraph>::DEGREE_BASED);
     185  checkMaxCliqueGridGraph(GrossoLocatelliPullanMc<GridGraph>::PENALTY_BASED);
    174186                       
    175187  return 0;
Note: See TracChangeset for help on using the changeset viewer.