1 /*-------------------------------------------------------------------------------------*/
2 /*  NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2      */
3 /*                                                                                     */
4 /*  Copyright (C) 2001-2015  Mark Abramson        - the Boeing Company, Seattle        */
5 /*                           Charles Audet        - Ecole Polytechnique, Montreal      */
6 /*                           Gilles Couture       - Ecole Polytechnique, Montreal      */
7 /*                           John Dennis          - Rice University, Houston           */
8 /*                           Sebastien Le Digabel - Ecole Polytechnique, Montreal      */
9 /*                           Christophe Tribes    - Ecole Polytechnique, Montreal      */
10 /*                                                                                     */
11 /*  funded in part by AFOSR and Exxon Mobil                                            */
12 /*                                                                                     */
13 /*  Author: Sebastien Le Digabel                                                       */
14 /*                                                                                     */
15 /*  Contact information:                                                               */
16 /*    Ecole Polytechnique de Montreal - GERAD                                          */
17 /*    C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada                  */
18 /*    e-mail: nomad@gerad.ca                                                           */
19 /*    phone : 1-514-340-6053 #6928                                                     */
20 /*    fax   : 1-514-340-5665                                                           */
21 /*                                                                                     */
22 /*  This program is free software: you can redistribute it and/or modify it under the  */
23 /*  terms of the GNU Lesser General Public License as published by the Free Software   */
24 /*  Foundation, either version 3 of the License, or (at your option) any later         */
25 /*  version.                                                                           */
26 /*                                                                                     */
27 /*  This program is distributed in the hope that it will be useful, but WITHOUT ANY    */
28 /*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A    */
29 /*  PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.   */
30 /*                                                                                     */
31 /*  You should have received a copy of the GNU Lesser General Public License along     */
32 /*  with this program. If not, see <http://www.gnu.org/licenses/>.                     */
33 /*                                                                                     */
34 /*  You can find information on the NOMAD software at www.gerad.ca/nomad               */
35 /*-------------------------------------------------------------------------------------*/
36 /**
37   \file   Pareto_Front.hpp
38   \brief  Pareto front (headers)
39   \author Sebastien Le Digabel
40   \date   2010-04-09
41   \see    Pareto_Front.cpp
42 */
43 #ifndef __PARETO_FRONT__
44 #define __PARETO_FRONT__
45 
46 #include "Pareto_Point.hpp"
47 
48 namespace NOMAD {
49 
50   /// Pareto front for two objective functions.
51   /**
52      Browse the front with the following instructions:
53      \code
54      const Eval_Point * cur = pareto_front.begin();
55      while ( cur ) {
56        ...
57        cur = pareto_front.next();
58      }
59      \endcode
60   */
61   class Pareto_Front : private NOMAD::Uncopyable {
62 
63   private:
64 
65     /// The set of Pareto points.
66     std::set<NOMAD::Pareto_Point> _pareto_pts;
67 
68     /// Iterator to browse the front with begin() and next().
69     mutable std::set<NOMAD::Pareto_Point>::const_iterator _it;
70 
71   public:
72 
73     /// Constructor.
Pareto_Front(void)74     Pareto_Front ( void ) {}
75 
76     /// Destructor.
~Pareto_Front(void)77     virtual ~Pareto_Front ( void ) {}
78 
79     /// Access to the first Pareto point.
80     /**
81        Used to initialize a loop on the Pareto points.
82        \return A pointer to the first Pareto point and \c NULL if the front
83                is empty.
84     */
85     const NOMAD::Eval_Point * begin ( void ) const;
86 
87     /// Access to the next Pareto point.
88     /**
89        Used to increment a loop on the Pareto points.
90        \return A pointer to the next Pareto point and \c NULL if
91                the current point is the last point in the front.
92     */
93     const NOMAD::Eval_Point * next  ( void ) const;
94 
95     /// Access to the number of Pareto points.
96     /**
97        \return The number of Pareto points.
98     */
size(void) const99     int size ( void ) const { return static_cast<int>(_pareto_pts.size()); }
100 
101     /// Check if the front is empty.
102     /**
103        \return A boolean equal to \c true if the front is empty.
104     */
empty(void) const105     bool empty ( void ) const { return _pareto_pts.empty(); }
106 
107     /// Computation and access to the reference point.
108     /**
109        \param xj      A pointer to the reference point; Is equal to \c NULL if
110                       no reference exists -- \b OUT.
111        \param delta_j The \c delta stats measuring the front repartition -- \b OUT.
112        \return A pointer to the reference point and
113                \c NULL if there is no reference point.
114     */
115     NOMAD::Point * get_ref ( const NOMAD::Pareto_Point *& xj      ,
116 			     NOMAD::Double              & delta_j   ) const;
117 
118     /// Access to the Pareto point minimizing f2(x).
119     /**
120        \return A pointer to the Pareto point minimizing f2 and
121                \c NULL if such a point does not exist.
122     */
123     const NOMAD::Eval_Point * get_best_f2 ( void ) const;
124 
125     /// Compute the stats \c delta and \c surf.
126     /**
127        - \c delta measures the front repartition (lower is best).
128        - \c surf measures the front quality (lower is best).
129        \param delta_j   The \c delta stat -- \b OUT.
130        \param surf      The \c surf stat  -- \b OUT.
131        \param f_bounds  NOMAD::Point with 4 values (f1_min, f1_max, f2_min, and f2_max)
132                         defining bounds for f1 and f2 for the computation
133 			of the \c surf stat -- \b IN.
134     */
135     void get_delta_surf ( NOMAD::Double      & delta_j ,
136 			  NOMAD::Double      & surf    ,
137 			  const NOMAD::Point & f_bounds  ) const;
138 
139     /// Insertion of a point in the Pareto front.
140     /**
141        \param x The point to be inserted -- \b IN.
142        \return A boolean equal to \c true if the point is a new Pareto point.
143     */
144     bool insert ( const NOMAD::Eval_Point & x );
145 
146     /// Display the Pareto points.
147     /**
148        \param out The NOMAD::Display object -- \b IN.
149     */
150     void display ( const NOMAD::Display & out ) const;
151   };
152 
153   /// Display a NOMAD::Pareto_Front object.
154   /**
155      \param out The NOMAD::Display object -- \b IN.
156      \param pf  The NOMAD::Pareto_Front object to be displayed -- \b IN.
157      \return    The NOMAD::Display object.
158   */
operator <<(const NOMAD::Display & out,const NOMAD::Pareto_Front & pf)159   inline const NOMAD::Display & operator << ( const NOMAD::Display      & out ,
160 					      const NOMAD::Pareto_Front & pf    ) {
161     pf.display ( out );
162     return out;
163   }
164 }
165 
166 #endif
167