1 /* Copyright 2017-2021 PaGMO development team
2 
3 This file is part of the PaGMO library.
4 
5 The PaGMO library is free software; you can redistribute it and/or modify
6 it under the terms of either:
7 
8   * the GNU Lesser General Public License as published by the Free
9     Software Foundation; either version 3 of the License, or (at your
10     option) any later version.
11 
12 or
13 
14   * the GNU General Public License as published by the Free Software
15     Foundation; either version 3 of the License, or (at your option) any
16     later version.
17 
18 or both in parallel, as here.
19 
20 The PaGMO library is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23 for more details.
24 
25 You should have received copies of the GNU General Public License and the
26 GNU Lesser General Public License along with the PaGMO library.  If not,
27 see https://www.gnu.org/licenses/. */
28 
29 #ifndef PAGMO_PROBLEMS_HOCK_SCHITTKOWSKY_71_HPP
30 #define PAGMO_PROBLEMS_HOCK_SCHITTKOWSKY_71_HPP
31 
32 #include <string>
33 #include <utility>
34 #include <vector>
35 
36 #include <pagmo/detail/visibility.hpp>
37 #include <pagmo/problem.hpp>
38 #include <pagmo/s11n.hpp>
39 #include <pagmo/types.hpp>
40 
41 namespace pagmo
42 {
43 
44 /// Problem No.71 from the Hock Schittkowsky suite
45 /**
46  * Mainly used for testing and debugging during PaGMO development, this
47  * struct implements the problem No.71 from the Hock Schittkowsky suite:
48  *
49  * \f[
50  *    \begin{array}{rl}
51  *    \mbox{find: } & 1 \le \mathbf x \le 5 \\
52  *    \mbox{to minimize: } & x_1x_4(x_1+x_2+x_3) + x_3 \\
53  *    \mbox{subject to: } & x_1^2+x_2^2+x_3^2+x_4^2 - 40 = 0 \\
54  *                        & 25 - x_1 x_2 x_3 x_4 \le 0
55  *    \end{array}
56  * \f]
57  *
58  * See: W. Hock and K. Schittkowski. Test examples for nonlinear programming codes.
59  * Lecture Notes in Economics and Mathematical Systems, 187, 1981. doi: 10.1007/978-3-642-48320-2.
60  *
61  */
62 struct PAGMO_DLL_PUBLIC hock_schittkowsky_71 {
63     // Fitness computation
64     vector_double fitness(const vector_double &) const;
65 
66     /// Equality constraint dimension
67     /**
68      *
69      * It returns the number of equality constraints
70      *
71      * @return the number of equality constraints
72      */
get_necpagmo::hock_schittkowsky_7173     vector_double::size_type get_nec() const
74     {
75         return 1u;
76     }
77 
78     /// Inequality constraint dimension
79     /**
80      *
81      * It returns the number of inequality constraints
82      *
83      * @return the number of inequality constraints
84      */
get_nicpagmo::hock_schittkowsky_7185     vector_double::size_type get_nic() const
86     {
87         return 1u;
88     }
89 
90     // Box-bounds
91     std::pair<vector_double, vector_double> get_bounds() const;
92 
93     // Gradients
94     vector_double gradient(const vector_double &) const;
95 
96     // Hessians
97     std::vector<vector_double> hessians(const vector_double &) const;
98 
99     // Hessians sparsity (only the diagonal elements are non zero)
100     std::vector<sparsity_pattern> hessians_sparsity() const;
101 
102     /// Problem name
103     /**
104      * @return a string containing the problem name
105      */
get_namepagmo::hock_schittkowsky_71106     std::string get_name() const
107     {
108         return "Hock Schittkowsky 71";
109     }
110 
111     /// Extra info
112     /**
113      * @return a string containing extra info on the problem
114      */
get_extra_infopagmo::hock_schittkowsky_71115     std::string get_extra_info() const
116     {
117         return "\tProblem number 71 from the Hock-Schittkowsky test suite";
118     }
119 
120     // Optimal solution
121     vector_double best_known() const;
122 
123 private:
124     // Object serialization
125     friend class boost::serialization::access;
126     template <typename Archive>
127     void serialize(Archive &, unsigned);
128 };
129 } // namespace pagmo
130 
131 PAGMO_S11N_PROBLEM_EXPORT_KEY(pagmo::hock_schittkowsky_71)
132 
133 #endif
134