44#ifndef ROL_SOLVER_DEF_HPP
45#define ROL_SOLVER_DEF_HPP
49template<
typename Real>
51 ParameterList &parlist )
52 : opt_(opt), problemType_(opt_->getProblemType()) {
54 case TYPE_U:
algoU_ = TypeU::AlgorithmFactory<Real>(parlist);
break;
55 case TYPE_B:
algoB_ = TypeB::AlgorithmFactory<Real>(parlist);
break;
56 case TYPE_E:
algoE_ = TypeE::AlgorithmFactory<Real>(parlist);
break;
57 case TYPE_EB:
algoG_ = TypeG::AlgorithmFactory<Real>(parlist);
break;
59 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
60 "Error in Solver::solve() : Unsupported problem type");
64template<
typename Real>
68 return solve(bhs,status,combineStatus);
71template<
typename Real>
74 bool combineStatus ) {
75 switch (problemType_) {
77 if (status != nullPtr) algoU_->setStatusTest(status,combineStatus);
78 algoU_->run(*opt_,outStream);
81 if (status != nullPtr) algoB_->setStatusTest(status,combineStatus);
82 algoB_->run(*opt_,outStream);
85 if (status != nullPtr) algoE_->setStatusTest(status,combineStatus);
86 algoE_->run(*opt_,outStream);
89 if (status != nullPtr) algoG_->setStatusTest(status,combineStatus);
90 algoG_->run(*opt_,outStream);
93 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
94 "Error in Solver::solve() : Unsupported problem type");
103template<
typename Real>
106 switch (problemType_) {
107 case TYPE_U:
return algoU_->getState();
108 case TYPE_B:
return algoB_->getState();
109 case TYPE_E:
return algoE_->getState();
110 case TYPE_EB:
return algoG_->getState();
113 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
114 "Error in Solver::getAlgorithmState() : Unsupported problem type");
118template<
typename Real>
120 switch (problemType_) {
121 case TYPE_U: algoU_->reset();
break;
122 case TYPE_B: algoB_->reset();
break;
123 case TYPE_E: algoE_->reset();
break;
124 case TYPE_EB: algoG_->reset();
break;
127 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
128 "Error in Solver::reset() : Unsupported problem type");
Solver(const Ptr< Problem< Real > > &opt, ParameterList &list)
Constructor.
Ptr< TypeG::Algorithm< Real > > algoG_
void reset()
Reset both Algorithm and Step.
Ptr< TypeB::Algorithm< Real > > algoB_
Ptr< TypeE::Algorithm< Real > > algoE_
Ptr< const AlgorithmState< Real > > getAlgorithmState() const
Return the AlgorithmState.
int solve(const Ptr< StatusTest< Real > > &status=nullPtr, bool combineStatus=true)
Solve optimization problem with no iteration output.
const EProblem problemType_
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