PaGMO  1.1.5
tens_comp_string.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/math/constants/constants.hpp>
26 
27 #include "../exceptions.h"
28 #include "../types.h"
29 #include "base.h"
30 #include "tens_comp_string.h"
31 
32 static const std::vector<double> __constraint_tolerances__(int c_dimension, int ic_dimension)
33 {
34  std::vector<double> constraint_tolerances(c_dimension);
35  // equality constraints
36  for(int i=0; i<c_dimension-ic_dimension; i++) {
37  constraint_tolerances[i] = 0.0001;
38  }
39  // inequality constraints
40  for(int i=c_dimension-ic_dimension; i<c_dimension; i++) {
41  constraint_tolerances[i] = 0.;
42  }
43  return constraint_tolerances;
44 }
45 
46 namespace pagmo { namespace problem {
47 
49 
53 tens_comp_string::tens_comp_string():base(3,0,1,4,4,__constraint_tolerances__(4,4))
54 {
55  // initialize best solution
56  initialize_best();
57 
58  // set the bounds for the current problem
59  const double lb[] = {0.05,0.25,2.};
60  const double ub[] = {2.,1.3,15.};
61  set_bounds(lb,ub);
62 }
63 
66 {
67  return base_ptr(new tens_comp_string(*this));
68 }
69 
72 {
73  /* objective function */
74  f[0] = x[0]*x[0] * x[1] * (x[2] + 2.);
75 }
76 
79 {
80  c[0] = 1. - (x[1]*x[1]*x[1] * x[2]) / (71785. * x[0]*x[0]*x[0]*x[0]);
81  c[1] = (4. * x[1]*x[1] - x[0] * x[1]) /
82  ( 12566. * x[0]*x[0]*x[0] * (x[1] - x[0]) ) +
83  1./(5108. * x[0]*x[0]) - 1.;
84  c[2] = 1. - 140.45 * x[0] / (x[2] * x[1]*x[1]);
85  c[3] = (x[0] + x[1]) / 1.5 - 1.;
86 }
87 
88 std::string tens_comp_string::get_name() const
89 {
90  std::string retval("Tension compression string");
91  return retval;
92 }
93 
94 void tens_comp_string::initialize_best(void)
95 {
96  std::vector<decision_vector> best_x;
97 
98  int x_dimension = 3;
99  // He and Wang
100  const double x_vector[] = {0.051728, 0.357644, 11.244543};
101 
102  decision_vector x(x_dimension);
103  std::copy(x_vector,x_vector + x_dimension,x.begin());
104  best_x.push_back(x);
105 
106  set_best_x(best_x);
107 }
108 
109 }} //namespaces
110 
111 BOOST_CLASS_EXPORT_IMPLEMENT(pagmo::problem::tens_comp_string)
Root PaGMO namespace.
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
Definition: problem/base.h:62
std::vector< double > decision_vector
Decision vector type.
Definition: types.h:40
void set_best_x(const std::vector< decision_vector > &)
Sets the best known decision vectors.
Base problem class.
Definition: problem/base.h:148
void compute_constraints_impl(constraint_vector &, const decision_vector &) const
Implementation of the constraint function.
base_ptr clone() const
Clone method.
std::string get_name() const
Get problem's name.
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
std::vector< double > constraint_vector
Constraint vector type.
Definition: types.h:44
The tension compression string design problem: Constrained Real-Parameter Optimization.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.