PaGMO  1.1.5
custom.cpp
1 /*****************************************************************************
2  * Copyright (C) 2004-2015 The PaGMO development team, *
3  * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4  * *
5  * https://github.com/esa/pagmo *
6  * *
7  * act@esa.int *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  *****************************************************************************/
24 
25 #include <boost/numeric/conversion/cast.hpp>
26 #include <string>
27 
28 #include "base.h"
29 #include "custom.h"
30 
31 namespace pagmo { namespace topology {
32 
34 
38 
40 
46 custom::custom(const base &t):base(t) {}
47 
49 
57 void custom::add_edge(int n, int m, double migr_probability)
58 {
59  base::add_edge(boost::numeric_cast<vertices_size_type>(n),boost::numeric_cast<vertices_size_type>(m));
60  base::set_weight(n, m, migr_probability);
61 }
62 
64 
71 void custom::remove_edge(int n, int m)
72 {
73  base::remove_edge(boost::numeric_cast<vertices_size_type>(n),boost::numeric_cast<vertices_size_type>(m));
74 }
75 
77 {}
78 
80 
84 {
86 }
87 
89 {
90  return base_ptr(new custom(*this));
91 }
92 
93 std::string custom::get_name() const
94 {
95  return "Custom";
96 }
97 
98 }} //namespaces
99 
100 BOOST_CLASS_EXPORT_IMPLEMENT(pagmo::topology::custom)
Root PaGMO namespace.
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base topology.
Definition: topology/base.h:47
Base topology class.
Definition: topology/base.h:75
void remove_all_edges()
Remove all edges.
Definition: custom.cpp:83
Custom topology.
Definition: custom.h:44
base_ptr clone() const
Clone method.
Definition: custom.cpp:88
void remove_edge(const vertices_size_type &, const vertices_size_type &)
Remove an edge.
void add_edge(int, int, double=1.0)
Add an edge.
Definition: custom.cpp:57
graph_type::vertices_size_type vertices_size_type
Vertices size type.
void remove_all_edges()
Remove all edges.
custom()
Default constructor.
Definition: custom.cpp:37
void connect(const vertices_size_type &)
Establish connections between islands during a push_back() operation.
Definition: custom.cpp:76
void remove_edge(int, int)
Remove an edge.
Definition: custom.cpp:71
std::string get_name() const
Get name of the topology.
Definition: custom.cpp:93
void add_edge(const vertices_size_type &, const vertices_size_type &)
Add an edge.
void set_weight(double)
Sets the migration probability.