10 #ifndef ROL_SOLVER_DEF_HPP
11 #define ROL_SOLVER_DEF_HPP
15 template<
typename Real>
17 ParameterList &parlist,
19 : opt_(opt), problemType_(opt_->getProblemType()) {
21 case TYPE_U:
algoU_ = TypeU::AlgorithmFactory<Real>(parlist,secant);
break;
22 case TYPE_P:
algoP_ = TypeP::AlgorithmFactory<Real>(parlist,secant);
break;
23 case TYPE_B:
algoB_ = TypeB::AlgorithmFactory<Real>(parlist,secant);
break;
24 case TYPE_E:
algoE_ = TypeE::AlgorithmFactory<Real>(parlist,secant);
break;
25 case TYPE_EB:
algoG_ = TypeG::AlgorithmFactory<Real>(parlist,secant);
break;
27 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
28 "Error in Solver::solve() : Unsupported problem type");
32 template<
typename Real>
36 return solve(bhs,status,combineStatus);
39 template<
typename Real>
42 bool combineStatus ) {
43 switch (problemType_) {
45 if (status != nullPtr) algoU_->setStatusTest(status,combineStatus);
46 algoU_->run(*opt_,outStream);
49 if (status != nullPtr) algoP_->setStatusTest(status,combineStatus);
50 algoP_->run(*opt_,outStream);
53 if (status != nullPtr) algoB_->setStatusTest(status,combineStatus);
54 algoB_->run(*opt_,outStream);
57 if (status != nullPtr) algoE_->setStatusTest(status,combineStatus);
58 algoE_->run(*opt_,outStream);
61 if (status != nullPtr) algoG_->setStatusTest(status,combineStatus);
62 algoG_->run(*opt_,outStream);
65 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
66 "Error in Solver::solve() : Unsupported problem type");
75 template<
typename Real>
78 switch (problemType_) {
79 case TYPE_U:
return algoU_->getState();
80 case TYPE_P:
return algoP_->getState();
81 case TYPE_B:
return algoB_->getState();
82 case TYPE_E:
return algoE_->getState();
83 case TYPE_EB:
return algoG_->getState();
86 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
87 "Error in Solver::getAlgorithmState() : Unsupported problem type");
91 template<
typename Real>
93 switch (problemType_) {
94 case TYPE_U: algoU_->reset();
break;
95 case TYPE_P: algoP_->reset();
break;
96 case TYPE_B: algoB_->reset();
break;
97 case TYPE_E: algoE_->reset();
break;
98 case TYPE_EB: algoG_->reset();
break;
101 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
102 "Error in Solver::reset() : Unsupported problem type");
108 #endif // ROL_SOLVER_DEF_HPP
basic_nullstream< char, std::char_traits< char >> nullstream
Ptr< TypeP::Algorithm< Real > > algoP_
int solve(const Ptr< StatusTest< Real >> &status=nullPtr, bool combineStatus=true)
Solve optimization problem with no iteration output.
Ptr< TypeG::Algorithm< Real > > algoG_
Provides interface for and implements limited-memory secant operators.
Solver(const Ptr< Problem< Real >> &opt, ParameterList &list, const Ptr< Secant< Real >> &secant=nullPtr)
Constructor.
Ptr< TypeU::Algorithm< Real > > algoU_
Provides an interface to check status of optimization algorithms.
virtual void solve(Vector< Real > &c, Vector< Real > &u, const Vector< Real > &z) override
void reset()
Reset both Algorithm and Step.
const EProblem problemType_
Ptr< const AlgorithmState< Real > > getAlgorithmState() const
Return the AlgorithmState.
Ptr< TypeE::Algorithm< Real > > algoE_
Ptr< TypeB::Algorithm< Real > > algoB_