44 #ifndef ROL_ALGORITHM_H 45 #define ROL_ALGORITHM_H 72 Teuchos::RCP<Step<Real> >
step_;
74 Teuchos::RCP<AlgorithmState<Real> >
state_;
86 bool printHeader =
false ) {
90 printHeader_ = printHeader;
99 bool printHeader =
false ) {
103 printHeader_ = printHeader;
111 Teuchos::ParameterList &parlist,
112 bool printHeader =
false) {
115 std::invalid_argument,
116 "Invalid step name in algorithm constructor!");
119 step_ = stepFactory.
getStep(stepname,parlist);
122 printHeader_ = printHeader;
131 std::ostream &outStream = std::cout ) {
134 return run(x,x.
dual(),obj,con,print,outStream);
145 std::ostream &outStream = std::cout ) {
148 return run(x,g,obj,con,print,outStream);
158 std::ostream &outStream = std::cout ) {
159 return run(x,x.
dual(),obj,con,print,outStream);
171 std::ostream &outStream = std::cout ) {
172 std::vector<std::string> output;
175 if ( state_->iterateVec == Teuchos::null ) {
176 state_->iterateVec = x.
clone();
178 state_->iterateVec->set(x);
181 Teuchos::RCP<Vector<Real> > s = x.
clone();
184 step_->initialize(x, g, obj, con, *state_);
185 output.push_back(step_->print(*state_,
true));
187 outStream << step_->print(*state_,
true);
191 if ( state_->minIterVec == Teuchos::null ) {
192 state_->minIterVec = x.
clone();
194 state_->minIterVec->set(x);
195 state_->minIter = state_->iter;
196 state_->minValue = state_->value;
199 while (status_->check(*state_)) {
200 step_->compute(*s, x, obj, con, *state_);
201 step_->update(x, *s, obj, con, *state_);
203 if ( state_->minValue > state_->value ) {
204 state_->minIterVec->set(*(state_->iterateVec));
205 state_->minValue = state_->value;
206 state_->minIter = state_->iter;
209 output.push_back(step_->print(*state_,printHeader_));
211 outStream << step_->print(*state_,printHeader_);
226 std::ostream &outStream = std::cout ) {
228 return run(x, x.
dual(), l, l.
dual(), obj, con, print, outStream);
244 std::ostream &outStream = std::cout ) {
245 std::vector<std::string> output;
248 if ( state_->iterateVec == Teuchos::null ) {
249 state_->iterateVec = x.
clone();
251 state_->iterateVec->set(x);
254 if ( state_->lagmultVec == Teuchos::null ) {
255 state_->lagmultVec = l.
clone();
257 state_->lagmultVec->set(l);
260 Teuchos::RCP<Vector<Real> > s = x.
clone();
263 step_->initialize(x, g, l, c, obj, con, *state_);
264 output.push_back(step_->print(*state_,
true));
266 outStream << step_->print(*state_,
true);
270 if ( state_->minIterVec == Teuchos::null ) {
271 state_->minIterVec = x.
clone();
273 state_->minIterVec->set(x);
274 state_->minIter = state_->iter;
275 state_->minValue = state_->value;
278 while (status_->check(*state_)) {
279 step_->compute(*s, x, l, obj, con, *state_);
280 step_->update(x, l, *s, obj, con, *state_);
281 output.push_back(step_->print(*state_,printHeader_));
283 outStream << step_->print(*state_,printHeader_);
298 std::ostream &outStream = std::cout ) {
299 return run(x,x.
dual(),l,l.
dual(),obj,con,bnd,print,outStream);
314 std::ostream &outStream = std::cout ) {
315 std::vector<std::string> output;
318 if ( state_->iterateVec == Teuchos::null ) {
319 state_->iterateVec = x.
clone();
321 state_->iterateVec->set(x);
324 if ( state_->lagmultVec == Teuchos::null ) {
325 state_->lagmultVec = l.
clone();
327 state_->lagmultVec->set(l);
330 Teuchos::RCP<Vector<Real> > s = x.
clone();
333 step_->initialize(x, g, l, c, obj, con, bnd, *state_);
334 output.push_back(step_->print(*state_,
true));
336 outStream << step_->print(*state_,
true);
340 if ( state_->minIterVec == Teuchos::null ) {
341 state_->minIterVec = x.
clone();
343 state_->minIterVec->set(x);
344 state_->minIter = state_->iter;
345 state_->minValue = state_->value;
348 while (status_->check(*state_)) {
349 step_->compute(*s, x, l, obj, con, bnd, *state_);
350 step_->update(x, l, *s, obj, con, bnd, *state_);
351 output.push_back(step_->print(*state_,printHeader_));
353 outStream << step_->print(*state_,printHeader_);
360 return step_->printHeader();
364 return step_->print(*state_,withHeader);
367 Teuchos::RCP<const AlgorithmState<Real> >
getState(
void)
const {
Provides the interface to evaluate objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
EStep StringToEStep(std::string s)
void stepFactory(Teuchos::ParameterList &parlist, Teuchos::RCP< ROL::Step< Real > > &step)
A minimalist step factory which specializes the Step Type depending on whether a Trust-Region or Line...
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &con, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on bound constrained problems (Type-B). This is the primary Type-B interface.
Provides the interface to compute optimization steps.
Contains definitions of custom data types in ROL.
Teuchos::RCP< const AlgorithmState< Real > > getState(void) const
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Defines the linear algebra or vector space interface.
Teuchos::RCP< AlgorithmState< Real > > state_
State for algorithm class. Will be used for restarts.
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on bound constrained problems (Type-B). This general interface supports the use of dual...
Defines the equality constraint operator interface.
virtual std::vector< std::string > run(Vector< Real > &x, Vector< Real > &l, Objective< Real > &obj, EqualityConstraint< Real > &con, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on equality constrained problems (Type-E). This is the primary Type-E interface...
Provides an interface to run optimization algorithms.
Provides an interface to check status of optimization algorithms.
Algorithm(const Teuchos::RCP< Step< Real > > &step, const Teuchos::RCP< StatusTest< Real > > &status, const Teuchos::RCP< AlgorithmState< Real > > &state, bool printHeader=false)
Constructor, given a step, a status test, and a previously defined algorithm state.
Provides the interface to apply upper and lower bound constraints.
int isValidStep(EStep ls)
Verifies validity of a TrustRegion enum.
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Vector< Real > &l, const Vector< Real > &c, Objective< Real > &obj, EqualityConstraint< Real > &con, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on equality constrained problems (Type-E). This general interface supports the use of d...
Teuchos::RCP< StatusTest< Real > > status_
Teuchos::RCP< StatusTest< Real > > getStatusTest(const std::string step, Teuchos::ParameterList &parlist)
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
Teuchos::RCP< Step< Real > > step_
Algorithm(const Teuchos::RCP< Step< Real > > &step, const Teuchos::RCP< StatusTest< Real > > &status, bool printHeader=false)
Constructor, given a step and a status test.
std::string getIterInfo(bool withHeader=false)
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Vector< Real > &l, const Vector< Real > &c, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on equality and bound constrained problems (Type-EB). This general interface supports t...
void deactivate(void)
Turn off bounds.
EStep
Enumeration of step types.
virtual std::vector< std::string > run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This general interface supports the use of dual opt...
virtual std::vector< std::string > run(Vector< Real > &x, Vector< Real > &l, Objective< Real > &obj, EqualityConstraint< Real > &con, BoundConstraint< Real > &bnd, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on equality and bound constrained problems (Type-EB). This is the primary Type-EB inter...
Teuchos::RCP< Step< Real > > getStep(const std::string &type, Teuchos::ParameterList &parlist) const
Algorithm(const std::string &stepname, Teuchos::ParameterList &parlist, bool printHeader=false)
Constructor, given a string, for the step, and a parameter list of various options. The status test is determined based on the step string.
std::string getIterHeader(void)