Ipopt Documentation  
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPFILTER_HPP__
8 #define __IPFILTER_HPP__
9 
10 #include "IpJournalist.hpp"
11 #include "IpDebug.hpp"
12 #include <list>
13 #include <vector>
14 
15 namespace Ipopt
16 {
17 
20 {
21 public:
26  std::vector<Number> vals,
27  Index iter
28  );
29 
31  ~FilterEntry();
33 
39  bool Acceptable(
40  std::vector<Number> vals
41  ) const
42  {
43  Index ncoor = (Index) vals_.size();
44  DBG_ASSERT((Index)vals.size() == ncoor);
45 
46  // ToDo decide if we need Compare_le
47  bool retval = false;
48  for( Index i = 0; i < ncoor; i++ )
49  {
50  if( vals[i] <= vals_[i] )
51  {
52  retval = true;
53  break;
54  }
55  }
56 
57  return retval;
58  }
59 
64  bool Dominated(
65  std::vector<Number> vals
66  ) const
67  {
68  Index ncoor = (Index) vals_.size();
69  DBG_ASSERT((Index)vals.size() == ncoor);
70 
71  bool retval = true;
72  for( Index i = 0; i < ncoor; i++ )
73  {
74  if( vals[i] > vals_[i] )
75  {
76  retval = false;
77  break;
78  }
79  }
80 
81  return retval;
82  }
83 
87  Index i
88  ) const
89  {
90  return vals_[i];
91  }
92  Index iter() const
93  {
94  return iter_;
95  }
97 
98 private:
110  FilterEntry();
112  FilterEntry(
113  const FilterEntry&
114  );
115 
117  void operator=(
118  const FilterEntry&
119  );
121 
123  std::vector<Number> vals_;
125  const Index iter_;
126 };
127 
134 class Filter
135 {
136 public:
140  Filter(
141  Index dim
142  );
145  {
146  //ToDo figure out if that here is necessary
147  Clear();
148  }
150 
156  bool Acceptable(
157  std::vector<Number> vals
158  ) const;
159 
165  void AddEntry(
166  std::vector<Number> vals,
167  Index iteration
168  );
169 
173  Number val1,
174  Number val2
175  ) const
176  {
177  std::vector<Number> vals(2);
178  vals[0] = val1;
179  vals[1] = val2;
180 
181  return Acceptable(vals);
182  }
183 
184  void AddEntry(
185  Number val1,
186  Number val2,
187  Index iteration
188  )
189  {
190  std::vector<Number> vals(2);
191  vals[0] = val1;
192  vals[1] = val2;
193 
194  AddEntry(vals, iteration);
195  }
197 
199  void Clear();
200 
202  void Print(
203  const Journalist& jnlst
204  );
205 
206 private:
218  Filter();
220  Filter(
221  const Filter&
222  );
223 
225  void operator=(
226  const Filter&
227  );
229 
232 
234  mutable std::list<FilterEntry*> filter_list_;
235 };
236 
237 } // namespace Ipopt
238 
239 #endif
bool Acceptable(std::vector< Number > vals) const
Check acceptability of pair (phi,theta) with respect to this filter entry.
Definition: IpFilter.hpp:39
void AddEntry(Number val1, Number val2, Index iteration)
Definition: IpFilter.hpp:184
Number val(Index i) const
Definition: IpFilter.hpp:86
FilterEntry()
Default Constructor.
Filter()
Default Constructor.
std::list< FilterEntry * > filter_list_
List storing the filter entries.
Definition: IpFilter.hpp:234
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
bool Acceptable(std::vector< Number > vals) const
Check acceptability of given coordinates with respect to the filter.
~FilterEntry()
Destructor.
bool Acceptable(Number val1, Number val2) const
Definition: IpFilter.hpp:172
Index dim_
Dimension of the filter (number of coordinates per entry)
Definition: IpFilter.hpp:231
void Clear()
Delete all filter entries.
void Print(const Journalist &jnlst)
Print current filter entries.
Index iter() const
Definition: IpFilter.hpp:92
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:28
bool Dominated(std::vector< Number > vals) const
Check if this entry is dominated by given coordinates.
Definition: IpFilter.hpp:64
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:125
Class for one filter entry.
Definition: IpFilter.hpp:19
~Filter()
Destructor.
Definition: IpFilter.hpp:144
Class responsible for all message output.
Class for the filter.
Definition: IpFilter.hpp:134
void operator=(const FilterEntry &)
Default Assignment Operator.
std::vector< Number > vals_
values defining the coordinates of the entry
Definition: IpFilter.hpp:123
void operator=(const Filter &)
Default Assignment Operator.