ROL
ROL_SecantFactory.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Rapid Optimization Library (ROL) Package
4//
5// Copyright 2014 NTESS and the ROL contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef ROL_SECANTFACTORY_H
11#define ROL_SECANTFACTORY_H
12
13#include "ROL_Types.hpp"
14
15#include "ROL_ParameterList.hpp"
16#include "ROL_Ptr.hpp"
17
18#include "ROL_Secant.hpp"
19#include "ROL_lBFGS.hpp"
20#include "ROL_lDFP.hpp"
21#include "ROL_lSR1.hpp"
23
24namespace ROL {
25 template<class Real>
26 inline ROL::Ptr<Secant<Real> > getSecant( ESecant esec = SECANT_LBFGS, int L = 10, int BBtype = 1 ) {
27 switch (esec) {
28 case SECANT_LBFGS: return ROL::makePtr<lBFGS<Real>>(L);
29 case SECANT_LDFP: return ROL::makePtr<lDFP<Real>>(L);
30 case SECANT_LSR1: return ROL::makePtr<lSR1<Real>>(L);
31 case SECANT_BARZILAIBORWEIN: return ROL::makePtr<BarzilaiBorwein<Real>>(BBtype);
32 default: return ROL::nullPtr;
33 }
34 }
35
36 template<class Real>
37 inline ROL::Ptr<Secant<Real> > SecantFactory( ROL::ParameterList &parlist, ESecantMode mode = SECANTMODE_BOTH ) {
38 std::string secantName = parlist.sublist("General").sublist("Secant").get("Type","Limited-Memory BFGS");
39 ESecant esec = StringToESecant(secantName);
40 int L = parlist.sublist("General").sublist("Secant").get("Maximum Storage",10);
41 int BB = parlist.sublist("General").sublist("Secant").get("Barzilai-Borwein",1);
42 bool uds = parlist.sublist("General").sublist("Secant").get("Use Default Scaling",true);
43 Real s = parlist.sublist("General").sublist("Secant").get("Initial Hessian Scale",1.0);
44 switch (esec) {
45 case SECANT_LBFGS: return ROL::makePtr<lBFGS<Real>>(L,uds,s);
46 case SECANT_LDFP: return ROL::makePtr<lDFP<Real>>(L,uds,s);
47 case SECANT_LSR1: return ROL::makePtr<lSR1<Real>>(L,uds,s,mode);
48 case SECANT_BARZILAIBORWEIN: return ROL::makePtr<BarzilaiBorwein<Real>>(BB);
49 default: return ROL::nullPtr;
50 }
51 }
52}
53
54#endif
Contains definitions of custom data types in ROL.
ESecant StringToESecant(std::string s)
@ SECANT_LSR1
@ SECANT_LDFP
@ SECANT_LBFGS
@ SECANT_BARZILAIBORWEIN
ESecantMode
@ SECANTMODE_BOTH
ROL::Ptr< Secant< Real > > SecantFactory(ROL::ParameterList &parlist, ESecantMode mode=SECANTMODE_BOTH)
ROL::Ptr< Secant< Real > > getSecant(ESecant esec=SECANT_LBFGS, int L=10, int BBtype=1)