44 #ifndef ROL_SOLVER_DEF_HPP
45 #define ROL_SOLVER_DEF_HPP
49 template<
typename Real>
51 ParameterList &parlist,
53 : opt_(opt), problemType_(opt_->getProblemType()) {
55 case TYPE_U:
algoU_ = TypeU::AlgorithmFactory<Real>(parlist,secant);
break;
56 case TYPE_B:
algoB_ = TypeB::AlgorithmFactory<Real>(parlist,secant);
break;
57 case TYPE_E:
algoE_ = TypeE::AlgorithmFactory<Real>(parlist,secant);
break;
58 case TYPE_EB:
algoG_ = TypeG::AlgorithmFactory<Real>(parlist,secant);
break;
60 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
61 "Error in Solver::solve() : Unsupported problem type");
65 template<
typename Real>
69 return solve(bhs,status,combineStatus);
72 template<
typename Real>
75 bool combineStatus ) {
76 switch (problemType_) {
78 if (status != nullPtr) algoU_->setStatusTest(status,combineStatus);
79 algoU_->run(*opt_,outStream);
82 if (status != nullPtr) algoB_->setStatusTest(status,combineStatus);
83 algoB_->run(*opt_,outStream);
86 if (status != nullPtr) algoE_->setStatusTest(status,combineStatus);
87 algoE_->run(*opt_,outStream);
90 if (status != nullPtr) algoG_->setStatusTest(status,combineStatus);
91 algoG_->run(*opt_,outStream);
94 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
95 "Error in Solver::solve() : Unsupported problem type");
104 template<
typename Real>
107 switch (problemType_) {
108 case TYPE_U:
return algoU_->getState();
109 case TYPE_B:
return algoB_->getState();
110 case TYPE_E:
return algoE_->getState();
111 case TYPE_EB:
return algoG_->getState();
114 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
115 "Error in Solver::getAlgorithmState() : Unsupported problem type");
119 template<
typename Real>
121 switch (problemType_) {
122 case TYPE_U: algoU_->reset();
break;
123 case TYPE_B: algoB_->reset();
break;
124 case TYPE_E: algoE_->reset();
break;
125 case TYPE_EB: algoG_->reset();
break;
128 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
129 "Error in Solver::reset() : Unsupported problem type");
135 #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_