Completed
Push — master ( 1a2f6f...14214b )
by Andrei
01:29
created

pyclustering.tsp.antcolony.process()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 8
rs 9.4285
1
"""!
2
3
@brief TSP algorithm: ant colony based
4
@details Based on article description:
5
         - M.Dorigo, L.M.Gambardella. Ant colonies for the traveling salesman problem. 1996.
6
         - J.Yang, X.Shi, M.Marchese, Y.Liang. An ant colony optimization method for generalized TSP problem. 2008.
7
8
@authors Alexey Kukushkin ([email protected])
9
@date 2014-2016
10
@copyright GNU Public License
11
12
@cond GNU_PUBLIC_LICENSE
13
    PyClustering is free software: you can redistribute it and/or modify
14
    it under the terms of the GNU General Public License as published by
15
    the Free Software Foundation, either version 3 of the License, or
16
    (at your option) any later version.
17
    
18
    PyClustering is distributed in the hope that it will be useful,
19
    but WITHOUT ANY WARRANTY; without even the implied warranty of
20
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
    GNU General Public License for more details.
22
    
23
    You should have received a copy of the GNU General Public License
24
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
@endcond
26
27
"""
28
29
import pyclustering.core.antcolony_tsp_wrapper as wrapper;
30
31
32
class antcolony_parameters:
33
    """!
34
    @brief Describes parameters of ant colony based algorithm for TSP problem.
35
    
36
    @see antcolony
37
    
38
    """  
39
    q                   = 1.5;
40
    ro                  = 0.7;
41
    alpha               = 1.0;
42
    beta                = 1.0;
43
    gamma               = 2.0;
44
    qinit_pheramone     = 0.1;
45
    ants_per_iteration  = 10;
46
    iterations          = 50;
47
48
49
class antcolony:
50
    """!
51
    @brief Simulates ant colony to solve travelling salesman problem (TSP).
52
    
53
    @details Ants of the artificial colony are able to generate successively shorter feasible tours by using information accumulated 
54
             in the form of a pheromone trail deposited on the edges of the TSP graph.
55
    
56
    @warning Solution is performed only via CCORE library (C/C++ implementation of the library).
57
    
58
    Example:
59
    @code
60
        
61
    @endcode
62
    
63
    """  
64
    
65
    __parameters = None;
66
    __result_tsp = None;
67
    
68
    
69
    def __init__(self, parameters):
70
        """!
71
        @brief Constructor of ant colony based algorithm for travelling salesman problem.
72
        
73
        @param[in] parameters (antcolony_parameters): Parameters of the ant colony algorithm.
74
        
75
        """
76
        self.__parameters = parameters;
77
    
78
    
79
    def process(self, object_locations):
80
        """!
81
        @brief Perform simulation of ant colony to solve travelling salesman problem.
82
        
83
        @param[in] object_locations (list): Coordinates of objects that should be visited.
84
        
85
        """
86
        self.__result_tsp = wrapper.antcolony_tsp_process(object_locations);
0 ignored issues
show
Bug introduced by
It seems like a value for argument params is missing in the function call.
Loading history...
87