|
GlobiPack Package Browser (Single Doxygen Collection) Version of the Day
|
00001 /* 00002 // @HEADER 00003 // *********************************************************************** 00004 // 00005 // GlobiPack: Collection of Scalar 1D globalizaton utilities 00006 // Copyright (2009) Sandia Corporation 00007 // 00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00009 // license for use of this work by or on behalf of the U.S. Government. 00010 // 00011 // This library is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Lesser General Public License as 00013 // published by the Free Software Foundation; either version 2.1 of the 00014 // License, or (at your option) any later version. 00015 // 00016 // This library is distributed in the hope that it will be useful, but 00017 // WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 // Lesser General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License along with this library; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00024 // USA 00025 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00026 // 00027 // *********************************************************************** 00028 // @HEADER 00029 */ 00030 00031 00032 #include "GlobiPack_TestLagrPolyMeritFunc1D.hpp" 00033 #include "Teuchos_Tuple.hpp" 00034 00035 00036 namespace { 00037 00038 00039 using GlobiPack::TestLagrPolyMeritFunc1D; 00040 using GlobiPack::testLagrPolyMeritFunc1D; 00041 using GlobiPack::PointEval1D; 00042 using Teuchos::RCP; 00043 using Teuchos::Array; 00044 using Teuchos::tuple; 00045 00046 00047 template<class Scalar> 00048 inline Scalar sqr(const Scalar &x) { return x*x; } 00049 00050 00051 template<class Scalar> 00052 inline Scalar cube(const Scalar &x) { return x*x*x; } 00053 00054 00055 // 00056 // Set up a quadratic merit function with minimizer at alpha=2.0, phi=3.0. 00057 // 00058 00059 template<class Scalar> 00060 const RCP<TestLagrPolyMeritFunc1D<Scalar> > quadPhi() 00061 { 00062 typedef Teuchos::ScalarTraits<Scalar> ST; 00063 typedef typename ST::magnitudeType ScalarMag; 00064 Array<Scalar> alphaPoints = tuple<Scalar>(0.0, 2.0, 4.0); 00065 Array<ScalarMag> phiPoints = tuple<ScalarMag>(6.0, 3.0, 6.0); 00066 return testLagrPolyMeritFunc1D<Scalar>(alphaPoints, phiPoints); 00067 } 00068 00069 00070 // 00071 // Set up a cubic merit function with minimizer at alpha=2.0, phi=3.0; 00072 // 00073 // The function being represented approximated is: 00074 // 00075 // phi(alpha) = (alpha - 2.0)^2 + 1e-3 * (alpha - 2.0)^3 + 3.0 00076 // 00077 // This function has the first and second derivatives derivatives: 00078 // 00079 // Dphi(alpha) = 2.0 * (alpha - 2.0) + 3e-3 * (alpha - 2.0)^2 00080 // 00081 // D2phi(alpha) = 2.0 + 6e-3 * (alpha - 2.0) 00082 // 00083 // At alpha=2.0, the function has Dphi=0.0 and D2phi = 2.0 and therefore, this 00084 // is a local minimum. 00085 // 00086 00087 00088 const double cubicMut = 1e-3; 00089 00090 00091 template<class Scalar> 00092 inline Scalar cubicPhiVal(const Scalar &alpha) 00093 { return sqr(alpha - 2.0) + cubicMut * cube(alpha - 2.0) + 3.0; } 00094 00095 00096 template<class Scalar> 00097 const RCP<TestLagrPolyMeritFunc1D<Scalar> > cubicPhi() 00098 { 00099 typedef Teuchos::ScalarTraits<Scalar> ST; 00100 typedef typename ST::magnitudeType ScalarMag; 00101 Array<Scalar> alphaPoints = 00102 tuple<Scalar>(0.0, 1.0, 3.0, 4.0); 00103 Array<ScalarMag> phiPoints = 00104 tuple<ScalarMag>( 00105 cubicPhiVal(alphaPoints[0]), 00106 cubicPhiVal(alphaPoints[1]), 00107 cubicPhiVal(alphaPoints[2]), 00108 cubicPhiVal(alphaPoints[3]) 00109 ); 00110 return testLagrPolyMeritFunc1D<Scalar>(alphaPoints, phiPoints); 00111 } 00112 00113 00114 } // namespace
1.7.4