lemon/howard_mmc.h
changeset 1162 259e3a90ad97
parent 1076 97d978243703
child 1093 fb1c7da561ce
equal deleted inserted replaced
6:7dd090b5006d 7:97defd682d53
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2010
     5  * Copyright (C) 2003-2013
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
   153     ///
   153     ///
   154     /// Enum type containing constants for the different causes of search
   154     /// Enum type containing constants for the different causes of search
   155     /// termination. The \ref findCycleMean() function returns one of
   155     /// termination. The \ref findCycleMean() function returns one of
   156     /// these values.
   156     /// these values.
   157     enum TerminationCause {
   157     enum TerminationCause {
   158       
   158 
   159       /// No directed cycle can be found in the digraph.
   159       /// No directed cycle can be found in the digraph.
   160       NO_CYCLE = 0,
   160       NO_CYCLE = 0,
   161     
   161 
   162       /// Optimal solution (minimum cycle mean) is found.
   162       /// Optimal solution (minimum cycle mean) is found.
   163       OPTIMAL = 1,
   163       OPTIMAL = 1,
   164 
   164 
   165       /// The iteration count limit is reached.
   165       /// The iteration count limit is reached.
   166       ITERATION_LIMIT
   166       ITERATION_LIMIT
   354     /// approximate solution is provided, which corresponds to a directed
   354     /// approximate solution is provided, which corresponds to a directed
   355     /// cycle whose mean cost is relatively small, but not necessarily
   355     /// cycle whose mean cost is relatively small, but not necessarily
   356     /// minimal.
   356     /// minimal.
   357     ///
   357     ///
   358     /// \param limit  The maximum allowed number of iterations during
   358     /// \param limit  The maximum allowed number of iterations during
   359     /// the search process. Its default value implies that the algorithm 
   359     /// the search process. Its default value implies that the algorithm
   360     /// runs until it finds the exact optimal solution.
   360     /// runs until it finds the exact optimal solution.
   361     ///
   361     ///
   362     /// \return The termination cause of the search process.
   362     /// \return The termination cause of the search process.
   363     /// For more information, see \ref TerminationCause. 
   363     /// For more information, see \ref TerminationCause.
   364     TerminationCause findCycleMean(int limit = std::numeric_limits<int>::max()) {
   364     TerminationCause findCycleMean(int limit = std::numeric_limits<int>::max()) {
   365       // Initialize and find strongly connected components
   365       // Initialize and find strongly connected components
   366       init();
   366       init();
   367       findComponents();
   367       findComponents();
   368 
   368 
   387           _best_found = true;
   387           _best_found = true;
   388           _best_cost = _curr_cost;
   388           _best_cost = _curr_cost;
   389           _best_size = _curr_size;
   389           _best_size = _curr_size;
   390           _best_node = _curr_node;
   390           _best_node = _curr_node;
   391         }
   391         }
   392         
   392 
   393         if (iter_limit_reached) break;
   393         if (iter_limit_reached) break;
   394       }
   394       }
   395 
   395 
   396       if (iter_limit_reached) {
   396       if (iter_limit_reached) {
   397         return ITERATION_LIMIT;
   397         return ITERATION_LIMIT;