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_B:
algoB_ = TypeB::AlgorithmFactory<Real>(parlist,secant);
break;
23 case TYPE_E:
algoE_ = TypeE::AlgorithmFactory<Real>(parlist,secant);
break;
24 case TYPE_EB:
algoG_ = TypeG::AlgorithmFactory<Real>(parlist,secant);
break;
26 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
27 "Error in Solver::solve() : Unsupported problem type");
31 template<
typename Real>
35 return solve(bhs,status,combineStatus);
38 template<
typename Real>
41 bool combineStatus ) {
42 switch (problemType_) {
44 if (status != nullPtr) algoU_->setStatusTest(status,combineStatus);
45 algoU_->run(*opt_,outStream);
48 if (status != nullPtr) algoB_->setStatusTest(status,combineStatus);
49 algoB_->run(*opt_,outStream);
52 if (status != nullPtr) algoE_->setStatusTest(status,combineStatus);
53 algoE_->run(*opt_,outStream);
56 if (status != nullPtr) algoG_->setStatusTest(status,combineStatus);
57 algoG_->run(*opt_,outStream);
60 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
61 "Error in Solver::solve() : Unsupported problem type");
70 template<
typename Real>
73 switch (problemType_) {
74 case TYPE_U:
return algoU_->getState();
75 case TYPE_B:
return algoB_->getState();
76 case TYPE_E:
return algoE_->getState();
77 case TYPE_EB:
return algoG_->getState();
80 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
81 "Error in Solver::getAlgorithmState() : Unsupported problem type");
85 template<
typename Real>
87 switch (problemType_) {
88 case TYPE_U: algoU_->reset();
break;
89 case TYPE_B: algoB_->reset();
break;
90 case TYPE_E: algoE_->reset();
break;
91 case TYPE_EB: algoG_->reset();
break;
94 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
95 "Error in Solver::reset() : Unsupported problem type");
101 #endif // ROL_SOLVER_DEF_HPP
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.
basic_nullstream< char, char_traits< char >> nullstream
Ptr< TypeE::Algorithm< Real > > algoE_
Ptr< TypeB::Algorithm< Real > > algoB_