Ipopt  3.12.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpFilter.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2006 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpFilter.hpp 1861 2010-12-21 21:34:47Z andreasw $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IPFILTER_HPP__
10 #define __IPFILTER_HPP__
11 
12 #include "IpJournalist.hpp"
13 #include "IpDebug.hpp"
14 #include <list>
15 #include <vector>
16 
17 namespace Ipopt
18 {
19 
22  {
23  public:
27  FilterEntry(std::vector<Number> vals, Index iter);
28 
30  ~FilterEntry();
32 
36  bool Acceptable(std::vector<Number> vals) const
37  {
38  Index ncoor = (Index)vals_.size();
39  DBG_ASSERT((Index)vals.size() == ncoor);
40 
41  // ToDo decide if we need Compare_le
42  bool retval = false;
43  for (Index i=0; i<ncoor; i++) {
44  if (vals[i] <= vals_[i]) {
45  retval = true;
46  break;
47  }
48  }
49 
50  return retval;
51  }
52 
56  bool Dominated(std::vector<Number> vals) const
57  {
58  Index ncoor = (Index)vals_.size();
59  DBG_ASSERT((Index)vals.size() == ncoor);
60 
61  bool retval = true;
62  for (Index i=0; i<ncoor; i++) {
63  if (vals[i] > vals_[i]) {
64  retval = false;
65  break;
66  }
67  }
68 
69  return retval;
70  }
71 
74  Number val(Index i) const
75  {
76  return vals_[i];
77  }
78  Index iter() const
79  {
80  return iter_;
81  }
83 
84  private:
94  FilterEntry();
96  FilterEntry(const FilterEntry&);
97 
99  void operator=(const FilterEntry&);
101 
103  std::vector<Number> vals_;
105  const Index iter_;
106  };
107 
111  class Filter
112  {
113  public:
117  Filter(Index dim);
120  {
121  //ToDo figure out if that here is necessary
122  Clear();
123  }
125 
129  bool Acceptable(std::vector<Number> vals) const;
130 
133  void AddEntry(std::vector<Number> vals, Index iteration);
134 
137  bool Acceptable(Number val1, Number val2) const
138  {
139  std::vector<Number> vals(2);
140  vals[0] = val1;
141  vals[1] = val2;
142 
143  return Acceptable(vals);
144  }
145 
146  void AddEntry(Number val1, Number val2, Index iteration)
147  {
148  std::vector<Number> vals(2);
149  vals[0] = val1;
150  vals[1] = val2;
151 
152  AddEntry(vals, iteration);
153  }
155 
157  void Clear();
158 
160  void Print(const Journalist& jnlst);
161 
162  private:
172  Filter();
174  Filter(const Filter&);
175 
177  void operator=(const Filter&);
179 
182 
184  mutable std::list<FilterEntry*> filter_list_;
185  };
186 
187 } // namespace Ipopt
188 
189 #endif
bool Acceptable(std::vector< Number > vals) const
Check acceptability of pair (phi,theta) with respect to this filter entry.
Definition: IpFilter.hpp:36
void AddEntry(Number val1, Number val2, Index iteration)
Definition: IpFilter.hpp:146
Number val(Index i) const
Definition: IpFilter.hpp:74
FilterEntry()
Default Constructor.
Filter()
Default Constructor.
std::list< FilterEntry * > filter_list_
List storing the filter entries.
Definition: IpFilter.hpp:184
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
bool Acceptable(std::vector< Number > vals) const
Check acceptability of given coordinates with respect to the filter.
~FilterEntry()
Default Destructor.
bool Acceptable(Number val1, Number val2) const
Definition: IpFilter.hpp:137
Index dim_
Dimension of the filter (number of coordinates per entry)
Definition: IpFilter.hpp:181
void Clear()
Delete all filter entries.
void Print(const Journalist &jnlst)
Print current filter entries.
Index iter() const
Definition: IpFilter.hpp:78
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
bool Dominated(std::vector< Number > vals) const
Check if this entry is dominated by given coordinates.
Definition: IpFilter.hpp:56
void AddEntry(std::vector< Number > vals, Index iteration)
Add filter entry for given coordinates.
const Index iter_
iteration number in which this entry was added to filter
Definition: IpFilter.hpp:105
Class for one filter entry.
Definition: IpFilter.hpp:21
~Filter()
Default Destructor.
Definition: IpFilter.hpp:119
Class responsible for all message output.
Class for the filter.
Definition: IpFilter.hpp:111
void operator=(const FilterEntry &)
Overloaded Equals Operator.
std::vector< Number > vals_
values defining the coordinates of the entry
Definition: IpFilter.hpp:103
void operator=(const Filter &)
Overloaded Equals Operator.