Skip to content

Commit

Permalink
Merge rol/src fixes requested by PyROL (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
aj463 authored Nov 15, 2023
1 parent a5c7f67 commit 17b0453
Show file tree
Hide file tree
Showing 36 changed files with 58 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/rol/src/algorithm/TypeB/ROL_TypeB_Algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class Algorithm {

/** \brief Print iterate status.
*/
virtual void writeOutput( std::ostream& os, bool write_header = false ) const;
virtual void writeOutput( std::ostream& os, const bool write_header = false ) const;

virtual void writeExitStatus( std::ostream& os ) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ColemanLiAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

private:
void initialize(Vector<Real> &x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class GradientAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

}; // class ROL::TypeB::GradientAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class InteriorPointAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

}; // class ROL::TypeB::InteriorPointAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class KelleySachsAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

private:
void initialize(Vector<Real> &x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class LSecantBAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

private:
void initialize(Vector<Real> &x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class LinMoreAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

private:
void initialize(Vector<Real> &x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class MoreauYosidaAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

}; // class ROL::TypeB::MoreauYosidaAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class NewtonKrylovAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

}; // class ROL::TypeB::NewtonKrylovAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class PrimalDualActiveSetAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

}; // class ROL::TypeB::PrimalDualActiveSetAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class QuasiNewtonAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream &os, bool write_header = false ) const override;
void writeOutput( std::ostream &os, const bool write_header = false ) const override;

}; // class ROL::TypeB::QuasiNewtonAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SpectralGradientAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream &os ) const override;

void writeOutput( std::ostream &os, bool write_header = false ) const override;
void writeOutput( std::ostream &os, const bool write_header = false ) const override;

}; // class ROL::TypeB::SpectralGradientAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class TrustRegionSPGAlgorithm : public TypeB::Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool write_header = false ) const override;
void writeOutput( std::ostream& os, const bool write_header = false ) const override;

private:
void initialize(Vector<Real> &x,
Expand Down
2 changes: 1 addition & 1 deletion packages/rol/src/algorithm/TypeE/ROL_TypeE_Algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Algorithm {

/** \brief Print iterate status.
*/
virtual void writeOutput( std::ostream& os, bool write_header = false ) const;
virtual void writeOutput( std::ostream& os, const bool write_header = false ) const;

virtual void writeExitStatus( std::ostream& os ) const;

Expand Down
2 changes: 1 addition & 1 deletion packages/rol/src/algorithm/TypeG/ROL_TypeG_Algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class Algorithm {

/** \brief Print iterate status.
*/
virtual void writeOutput( std::ostream& os, bool write_header = false ) const;
virtual void writeOutput( std::ostream& os, const bool write_header = false ) const;

virtual void writeExitStatus( std::ostream& os ) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "ROL_Types.hpp"
#include "ROL_Ptr.hpp"
#include "ROL_ScalarController.hpp"
#include "ROL_ParameterList.hpp"
#include <iostream>

/** @ingroup func_group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ template<typename Real>
Ptr<const Vector<Real>> FletcherObjectiveBase<Real>::getGradient(const Vector<Real>& x) {
// TODO: Figure out reasonable tolerance
Real tol = static_cast<Real>(1e-12);
gradient(*xdual_, x, tol);
this->gradient(*xdual_, x, tol);
return xdual_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "ROL_Types.hpp"
#include "ROL_Ptr.hpp"
#include "ROL_ScalarController.hpp"
#include "ROL_ParameterList.hpp"
#include <iostream>

/** @ingroup func_group
Expand Down
2 changes: 1 addition & 1 deletion packages/rol/src/algorithm/TypeU/ROL_TypeU_Algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Algorithm {

/** \brief Print iterate status.
*/
virtual void writeOutput( std::ostream& os, bool write_header = false ) const;
virtual void writeOutput( std::ostream& os, const bool write_header = false ) const;

virtual void writeExitStatus( std::ostream& os ) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class BundleAlgorithm : public Algorithm<Real> {

void writeName( std::ostream& os) const override;

void writeOutput( std::ostream& os, bool print_header = false ) const override;
void writeOutput( std::ostream& os, const bool print_header = false ) const override;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class LineSearchAlgorithm : public Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool print_header = false ) const override;
void writeOutput( std::ostream& os, const bool print_header = false ) const override;

}; // class ROL::TypeU::LineSearchAlgorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class TrustRegionAlgorithm : public Algorithm<Real> {

void writeName( std::ostream& os ) const override;

void writeOutput( std::ostream& os, bool print_header = false ) const override;
void writeOutput( std::ostream& os, const bool print_header = false ) const override;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "ROL_NonlinearCG_U.hpp"
#include "ROL_Newton_U.hpp"
#include "ROL_NewtonKrylov_U.hpp"
#include "ROL_LineSearch_U_Types.hpp"

namespace ROL {
template<typename Real>
Expand Down
5 changes: 5 additions & 0 deletions packages/rol/src/elementwise/ROL_Elementwise_Function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
// ************************************************************************
// @HEADER

#ifndef ROL_VECTOR_H
#include "ROL_Vector.hpp"
#else

#ifndef ROL_ELEMENTWISE_FUNCTION_H
#define ROL_ELEMENTWISE_FUNCTION_H

Expand Down Expand Up @@ -132,3 +136,4 @@ void applyBinaryInPlace(ROL::Vector<Real> &x, const ROL::Vector<Real> &y, Func f
#include <ROL_BinaryFunctions.hpp>

#endif
#endif
5 changes: 5 additions & 0 deletions packages/rol/src/elementwise/ROL_Elementwise_Reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
// ************************************************************************
// @HEADER

#ifndef ROL_VECTOR_H
#include "ROL_Vector.hpp"
#else

#ifndef ROL_ELEMENTWISE_REDUCE_H
#define ROL_ELEMENTWISE_REDUCE_H

Expand Down Expand Up @@ -190,3 +194,4 @@ class EuclideanNormSquared : public ReductionOp<Real> {
} // namespace ROL

#endif
#endif
8 changes: 4 additions & 4 deletions packages/rol/src/function/ROL_ConstraintAssembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ namespace ROL {

template<typename Real>
struct ConstraintData {
const Ptr<Constraint<Real>> constraint;
const Ptr<Vector<Real>> multiplier;
const Ptr<Vector<Real>> residual;
const Ptr<BoundConstraint<Real>> bounds;
Ptr<Constraint<Real>> constraint;
Ptr<Vector<Real>> multiplier;
Ptr<Vector<Real>> residual;
Ptr<BoundConstraint<Real>> bounds;

ConstraintData(const Ptr<Constraint<Real>> &con,
const Ptr<Vector<Real>> &mul,
Expand Down
1 change: 1 addition & 0 deletions packages/rol/src/function/ROL_UpdateType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define ROL_UPDATE_TYPE_HPP

#include <cstdint>
#include <string>

namespace ROL {

Expand Down
2 changes: 2 additions & 0 deletions packages/rol/src/function/ROL_VectorController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

#include "ROL_Vector.hpp"
#include "ROL_UpdateType.hpp"
#include <map>
#include <vector>

namespace ROL {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ class BoundConstraint_Partitioned : public BoundConstraint<Real> {
}

void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) {
const PV &xpv = dynamic_cast<const PV&>(x);
for( uint k=0; k<dim_; ++k ) {
if( bnd_[k]->isActivated() ) {
bnd_[k]->update(*(xpv.get(k)),flag,iter);
}
}
}

void project( Vector<Real> &x ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "ROL_Objective.hpp"
#include "ROL_Vector.hpp"
#include "ROL_Ptr.hpp"
#include "ROL_LinearOperator.hpp"

/** @ingroup func_group
\class ROL::QuadraticObjective
Expand Down
6 changes: 6 additions & 0 deletions packages/rol/src/step/secant/ROL_BarzilaiBorwein.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
// ************************************************************************
// @HEADER


#ifndef ROL_SECANTFACTORY_H
#include "ROL_SecantFactory.hpp"
#else

#ifndef ROL_BARZILAIBORWEIN_H
#define ROL_BARZILAIBORWEIN_H

Expand Down Expand Up @@ -101,3 +106,4 @@ class BarzilaiBorwein : public Secant<Real> {
}

#endif
#endif
5 changes: 5 additions & 0 deletions packages/rol/src/step/trustregion/ROL_CauchyPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
// ************************************************************************
// @HEADER

#ifndef ROL_TRUSTREGIONFACTORY_H
#include "ROL_TrustRegionFactory.hpp"
#else

#ifndef ROL_CAUCHYPOINT_H
#define ROL_CAUCHYPOINT_H

Expand Down Expand Up @@ -277,3 +281,4 @@ class CauchyPoint : public TrustRegion<Real> {
}

#endif
#endif
2 changes: 1 addition & 1 deletion packages/rol/src/step/trustregion/ROL_DogLeg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
\brief Provides interface for dog leg trust-region subproblem solver.
*/

#include "ROL_TrustRegion.hpp"
#include "ROL_CauchyPoint.hpp"
#include "ROL_Types.hpp"

namespace ROL {
Expand Down
2 changes: 2 additions & 0 deletions packages/rol/src/step/trustregion/ROL_TrustRegionTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#ifndef ROL_TRUSTREGIONTYPES_HPP
#define ROL_TRUSTREGIONTYPES_HPP

#include "ROL_Types.hpp"

namespace ROL {

/** \enum ROL::ETrustRegion
Expand Down
4 changes: 2 additions & 2 deletions packages/rol/src/vector/ROL_Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ class Vector
virtual void applyUnary( const Elementwise::UnaryFunction<Real> &f ) {
ROL_UNUSED(f);
ROL_TEST_FOR_EXCEPTION( true, std::logic_error,
"The method applyUnary wass called, but not implemented" << std::endl);
"The method applyUnary was called, but not implemented" << std::endl);
}

virtual void applyBinary( const Elementwise::BinaryFunction<Real> &f, const Vector &x ) {
ROL_UNUSED(f);
ROL_UNUSED(x);
ROL_TEST_FOR_EXCEPTION( true, std::logic_error,
"The method applyBinary wass called, but not implemented" << std::endl);
"The method applyBinary was called, but not implemented" << std::endl);
}

virtual Real reduce( const Elementwise::ReductionOp<Real> &r ) const {
Expand Down
1 change: 1 addition & 0 deletions packages/rol/src/zoo/ROL_ScalarTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#define ROL_SCALARTRAITS_HPP

#include <limits>
#include <complex>


namespace ROL {
Expand Down

0 comments on commit 17b0453

Please sign in to comment.