@@ -12,22 +12,22 @@ namespace repelling
1212{
1313 namespace distance
1414 {
15- Float manhattan (const Vector & u, const Vector & v);
16- Float euclidian (const Vector & u, const Vector & v);
17- Float mahanolobis (const Vector & u, const Vector & v, const Matrix & C_inv);
15+ Float manhattan (const Vector& u, const Vector& v);
16+ Float euclidian (const Vector& u, const Vector& v);
17+ Float mahanolobis (const Vector& u, const Vector& v, const Matrix& C_inv);
1818
1919 bool hill_valley_test (
20- const Solution & u,
21- const Solution & v,
22- FunctionType & f,
20+ const Solution& u,
21+ const Solution& v,
22+ FunctionType& f,
2323 const size_t n_evals);
2424
2525 bool hill_valley_test_p (
26- const Solution & u,
27- const Solution & v,
28- FunctionType & f,
26+ const Solution& u,
27+ const Solution& v,
28+ FunctionType& f,
2929 const size_t n_evals,
30- parameters::Parameters & p);
30+ parameters::Parameters& p);
3131 }
3232
3333 struct TabooPoint
@@ -37,20 +37,17 @@ namespace repelling
3737 Float shrinkage;
3838 int n_rep;
3939 Float criticality;
40- // Matrix C;
41- // Matrix C_inv;
4240
4341 TabooPoint (
44- const Solution &s,
45- const Float radius/* ,
46- const Matrix& C, const Matrix& C_inv*/ ) : solution(s),
47- radius (radius),
48- shrinkage(std::pow(0.99 , 1 . / static_cast <Float>(s.x.size()))),
49- n_rep(1 ),
50- criticality(0.0 ) {}
51- /* ,
52- C(C),
53- C_inv(C_inv) {}*/
42+ const Solution& s,
43+ const Float radius) :
44+ solution (s),
45+ radius (radius),
46+ shrinkage (std::pow(0.99 , 1 . / static_cast <Float>(s.x.size()))),
47+ n_rep (1 ),
48+ criticality (0.0 )
49+ {}
50+
5451
5552 /* *
5653 * \brief Rejection rule for a taboo point for a given xi
@@ -59,20 +56,18 @@ namespace repelling
5956 * \param attempts determines the amount of shrinkage applied; radius = pow(shrinkage, attempts) * radius
6057 * \return
6158 */
62- bool rejects (const Vector & xi, const parameters::Parameters & p, const int attempts) const ;
59+ bool rejects (const Vector& xi, const parameters::Parameters& p, const int attempts) const ;
6360
64- bool shares_basin (FunctionType & objective, const Solution & sol, parameters::Parameters & p) const ;
61+ bool shares_basin (FunctionType& objective, const Solution& sol, parameters::Parameters& p) const ;
6562
66- void calculate_criticality (const parameters::Parameters & p);
63+ void calculate_criticality (const parameters::Parameters& p);
6764 };
6865
6966 struct Repelling
7067 {
7168 std::vector<TabooPoint> archive;
7269 int attempts = 0 ;
7370 Float coverage = 20.0 ;
74- // Matrix C;
75- Matrix C_inv;
7671
7772 virtual ~Repelling () = default ;
7873
@@ -83,38 +78,36 @@ namespace repelling
8378 * \param p
8479 * \return
8580 */
86- virtual bool is_rejected (const Vector & xi, parameters::Parameters & p);
81+ virtual bool is_rejected (const Vector& xi, parameters::Parameters& p);
8782
8883 /* *
8984 * \brief Update the archive of points
9085 * \param p
9186 */
92- virtual void update_archive (FunctionType & objective, parameters::Parameters & p);
87+ virtual void update_archive (FunctionType& objective, parameters::Parameters& p);
9388
9489 /* *
9590 * \brief Hook before sampling starts
9691 */
97- virtual void prepare_sampling (const parameters::Parameters & p);
92+ virtual void prepare_sampling (const parameters::Parameters& p);
9893 };
9994
10095 struct NoRepelling final : Repelling
10196 {
10297
103- bool is_rejected (const Vector & xi, parameters::Parameters & p) override
98+ bool is_rejected (const Vector& xi, parameters::Parameters& p) override
10499 {
105100 return false ;
106101 }
107102
108- void update_archive (FunctionType &objective, parameters::Parameters &p) override
109- {
110- }
103+ void update_archive (FunctionType& objective, parameters::Parameters& p) override
104+ {}
111105
112- void prepare_sampling (const parameters::Parameters &p) override
113- {
114- }
106+ void prepare_sampling (const parameters::Parameters& p) override
107+ {}
115108 };
116109
117- inline std::shared_ptr<Repelling> get (const parameters::Modules & m)
110+ inline std::shared_ptr<Repelling> get (const parameters::Modules& m)
118111 {
119112 if (m.repelling_restart )
120113 return std::make_shared<Repelling>();
0 commit comments