- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.5.1/Ipopt/src/Algorithm/IpFilter.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2006 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpFilter.hpp 735 2006-06-04 06:10:05Z andreasw $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
    00008
    00009 #ifndef __IPFILTER_HPP__
    00010 #define __IPFILTER_HPP__
    00011
    00012 #include "IpJournalist.hpp"
    00013 #include "IpDebug.hpp"
    00014 #include <list>
    00015 #include <vector>
    00016
    00017 namespace Ipopt
    00018 {
    00019
    00021   class FilterEntry
    00022   {
    00023   public:
    00027     FilterEntry(std::vector<Number> vals, Index iter);
    00028
    00030     ~FilterEntry();
    00032
    00036     bool Acceptable(std::vector<Number> vals) const
    00037     {
    00038       Index ncoor = (Index)vals_.size();
    00039       DBG_ASSERT((Index)vals.size() == ncoor);
    00040
    00041       // ToDo decide if we need Compare_le
    00042       bool retval = false;
    00043       for (Index i=0; i<ncoor; i++) {
    00044         if (vals[i] <= vals_[i]) {
    00045           retval = true;
    00046           break;
    00047         }
    00048       }
    00049
    00050       return retval;
    00051     }
    00052
    00056     bool Dominated(std::vector<Number> vals) const
    00057     {
    00058       Index ncoor = (Index)vals_.size();
    00059       DBG_ASSERT((Index)vals.size() == ncoor);
    00060
    00061       bool retval = true;
    00062       for (Index i=0; i<ncoor; i++) {
    00063         if (vals[i] > vals_[i]) {
    00064           retval = false;
    00065           break;
    00066         }
    00067       }
    00068
    00069       return retval;
    00070     }
    00071
    00074     Number val(Index i) const
    00075     {
    00076       return vals_[i];
    00077     }
    00078     Index iter() const
    00079     {
    00080       return iter_;
    00081     }
    00083
    00084   private:
    00094     FilterEntry();
    00096     FilterEntry(const FilterEntry&);
    00097
    00099     void operator=(const FilterEntry&);
    00101
    00103     std::vector<Number> vals_;
    00105     const Index iter_;
    00106   };
    00107
    00111   class Filter
    00112   {
    00113   public:
    00117     Filter(Index dim);
    00119     ~Filter()
    00120     {
    00121       //ToDo figure out if that here is necessary
    00122       Clear();
    00123     }
    00125
    00129     bool Acceptable(std::vector<Number> vals) const;
    00130
    00133     void AddEntry(std::vector<Number> vals, Index iteration);
    00134
    00137     bool Acceptable(Number val1, Number val2) const
    00138     {
    00139       std::vector<Number> vals(2);
    00140       vals[0] = val1;
    00141       vals[1] = val2;
    00142
    00143       return Acceptable(vals);
    00144     }
    00145
    00146     void AddEntry(Number val1, Number val2, Index iteration)
    00147     {
    00148       std::vector<Number> vals(2);
    00149       vals[0] = val1;
    00150       vals[1] = val2;
    00151
    00152       AddEntry(vals, iteration);
    00153     }
    00155
    00157     void Clear();
    00158
    00160     void Print(const Journalist& jnlst);
    00161
    00162   private:
    00172     Filter();
    00174     Filter(const Filter&);
    00175
    00177     void operator=(const Filter&);
    00179
    00181     Index dim_;
    00182
    00184     mutable std::list<FilterEntry*> filter_list_;
    00185   };
    00186
    00187 } // namespace Ipopt
    00188
    00189 #endif