Sandia Home Sandia Home
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

APPSPACK_Point.cpp

Go to the documentation of this file.
00001 // $Id: APPSPACK_Point.cpp,v 1.8 2004/04/12 17:42:49 tgkolda Exp $ 00002 // $Source: /space/CVS-Acro/acro/packages/appspack/appspack/src/APPSPACK_Point.cpp,v $ 00003 00004 //@HEADER 00005 // ************************************************************************ 00006 // 00007 // APPSPACK: Asynchronous Parallel Pattern Search 00008 // Copyright (2003) Sandia Corporation 00009 // 00010 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00011 // license for use of this work by or on behalf of the U.S. Government. 00012 // 00013 // This library is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU Lesser General Public License as 00015 // published by the Free Software Foundation; either version 2.1 of the 00016 // License, or (at your option) any later version. 00017 // 00018 // This library is distributed in the hope that it will be useful, but 00019 // WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 // Lesser General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU Lesser General Public 00024 // License along with this library; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00026 // USA. . 00027 // 00028 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov) 00029 // 00030 // ************************************************************************ 00031 //@HEADER 00032 00038 #include "APPSPACK_Point.hpp" 00039 #include "APPSPACK_Print.hpp" 00040 00041 int APPSPACK::Point::staticCount = 0; 00042 00043 APPSPACK::Point::Point(const Vector& x_in, const Value& f_in, double step_in, double alpha_in) : 00044 x(x_in), 00045 f(f_in), 00046 tag(staticCount), 00047 step(step_in), 00048 parentTag(-1), 00049 idx(-1), 00050 parentValue(), 00051 alpha(alpha_in), 00052 rho(0), 00053 state(Evaluated), 00054 msg("(Initial Point)") 00055 { 00056 staticCount ++; 00057 } 00058 00059 APPSPACK::Point::Point(const Vector& x_in, double step_in, 00060 const Point& parent, int idx_in) : 00061 x(x_in), 00062 f(), 00063 tag(staticCount), 00064 step(step_in), 00065 parentTag(parent.tag), 00066 idx(idx_in), 00067 parentValue(parent.f), 00068 alpha(parent.alpha), 00069 rho(alpha * step * step), 00070 state(Unevaluated), 00071 msg() 00072 { 00073 staticCount ++; 00074 } 00075 00076 APPSPACK::Point::~Point() 00077 { 00078 } 00079 00080 const APPSPACK::Vector& APPSPACK::Point::getX() const 00081 { 00082 return x; 00083 } 00084 00085 const APPSPACK::Value& APPSPACK::Point::getF() const 00086 { 00087 return f; 00088 } 00089 int APPSPACK::Point::getTag() const 00090 { 00091 return tag; 00092 } 00093 00094 int APPSPACK::Point::getParentTag() const 00095 { 00096 return parentTag; 00097 } 00098 00099 int APPSPACK::Point::getIndex() const 00100 { 00101 return idx; 00102 } 00103 00104 double APPSPACK::Point::getStep() const 00105 { 00106 return step; 00107 } 00108 00109 void APPSPACK::Point::setCachedFunctionValue(const Value& f_in, const string& msg_in) 00110 { 00111 f = f_in; 00112 msg = msg_in; 00113 state = (isSufficientDecrease()) ? Cached : CachedInsufficientDecrease; 00114 } 00115 00116 void APPSPACK::Point::setEvaluatedFunctionValue(const Value& f_in, const string& msg_in) 00117 { 00118 f = f_in; 00119 msg = msg_in; 00120 state = (isSufficientDecrease()) ? Evaluated : EvaluatedInsufficientDecrease; 00121 } 00122 00123 void APPSPACK::Point::setInfeasible() 00124 { 00125 state = Infeasible; 00126 } 00127 00128 bool APPSPACK::Point::operator<(const Point& other) const 00129 { 00130 // Case I: Equal tags 00131 if (tag == other.tag) 00132 return false; 00133 00134 // Case II: This point does not have a valid function value 00135 if ((state != Cached) && (state != Evaluated)) 00136 return false; 00137 00138 // Case III: The other point does not have a valid function value 00139 if ((other.state != Cached) && (other.state != Evaluated)) 00140 return true; 00141 00142 // Case IV: f(x) < f(y) 00143 if (f < other.f) 00144 return true; 00145 00146 // Case III: f(x) > f(y) 00147 if (f > other.f) 00148 return false; 00149 00150 // Case IV: f(x) = f(y) 00151 return (tag < other.tag); 00152 } 00153 00154 // PRIVATE 00155 bool APPSPACK::Point::isSufficientDecrease() const 00156 { 00157 // No sufficient decrease criteria imposed 00158 if (rho <= 0) 00159 return true; 00160 00161 return f.isSufficientDecrease(parentValue, rho); 00162 } 00163 00164 00165 ostream& APPSPACK::Point::leftshift(ostream& stream) const 00166 { 00167 // Print point to the given stream. 00168 00169 stream << "f=" << f; 00170 stream << " x=" << x; 00171 stream << " step=" << APPSPACK::Print::formatPositiveDouble(step); 00172 stream << " tag=" << tag; 00173 stream << " state=" << state; 00174 stream << " " << msg; 00175 return stream; 00176 } 00177 00178 ostream& operator<<(ostream& stream, const APPSPACK::Point& point) 00179 { 00180 return point.leftshift(stream); 00181 } 00182 00183 ostream& operator<<(ostream& stream, APPSPACK::Point::State state) 00184 { 00185 switch(state) 00186 { 00187 case APPSPACK::Point::Unevaluated: 00188 stream << "Unevaluated"; 00189 break; 00190 case APPSPACK::Point::Infeasible: 00191 stream << "Infeasible"; 00192 break; 00193 case APPSPACK::Point::CachedInsufficientDecrease: 00194 stream << "CachedInsufficientDecrease"; 00195 break; 00196 case APPSPACK::Point::Cached: 00197 stream << "Cached"; 00198 break; 00199 case APPSPACK::Point::EvaluatedInsufficientDecrease: 00200 stream << "EvaluatedInsufficientDecrease"; 00201 break; 00202 case APPSPACK::Point::Evaluated: 00203 stream << "Evaluated"; 00204 break; 00205 } 00206 00207 return stream; 00208 }

 

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Wed Dec 14 18:41:04 2005 for APPSPACK 4.0.2 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2002