1 //                                               -*- C++ -*-
2 /**
3  *  @brief NearestPointProblem allows to describe an optimization problem
4  *
5  *  Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6  *
7  *  This library is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #ifndef OPENTURNS_NEARESTPOINTPROBLEM_HXX
22 #define OPENTURNS_NEARESTPOINTPROBLEM_HXX
23 
24 #include "openturns/OptimizationProblemImplementation.hxx"
25 
26 BEGIN_NAMESPACE_OPENTURNS
27 
28 /**
29  * @class NearestPointProblem
30  * NearestPointProblem allows to describe an optimization problem
31  */
32 
33 class OT_API NearestPointProblem
34   : public OptimizationProblemImplementation
35 {
36 
37   CLASSNAME
38 
39 public:
40 
41   /** Default constructor */
42   NearestPointProblem();
43 
44   /** Constructor with parameters */
45   NearestPointProblem(const Function & levelFunction,
46                       Scalar levelValue);
47 
48   /** Virtual constructor */
49   NearestPointProblem * clone() const override;
50 
51   /** Level function accessor */
52   Function getLevelFunction() const override;
53   void setLevelFunction(const Function & levelFunction) override;
54   Bool hasLevelFunction() const override;
55 
56   /** Level value accessor */
57   Scalar getLevelValue() const override;
58   void setLevelValue(Scalar levelValue) override;
59 
60   /** String converter */
61   String __repr__() const override;
62 
63   /** Method save() stores the object through the StorageManager */
64   void save(Advocate & adv) const override;
65 
66   /** Method load() reloads the object from the StorageManager */
67   void load(Advocate & adv) override;
68 
69 private:
70   void clearLevelFunction();
71   void setNearestPointConstraints();
72 
73   // The level function, for nearest point problems
74   Function levelFunction_;
75 
76   // The level value, for nearest point problems
77   Scalar levelValue_;
78 
79 } ; /* class NearestPointProblem */
80 
81 
82 END_NAMESPACE_OPENTURNS
83 
84 #endif /* OPENTURNS_NEARESTPOINTPROBLEM_HXX */
85