Skip to content

Commit

Permalink
ROL: add some override keywords to eliminate -Winconsistent-override …
Browse files Browse the repository at this point in the history
…warnings

for issue #13798

Signed-off-by: Kevin L. Manktelow <[email protected]>
  • Loading branch information
klmankt committed Feb 11, 2025
1 parent 95b49d7 commit a1491a8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MixedCVaR : public RandVarFunctional<Real> {
checkInputs();
}

void initialize(const Vector<Real> &x) {
void initialize(const Vector<Real> &x) override {
RandVarFunctional<Real>::initialize(x);
vec_.assign(size_,static_cast<Real>(0));
}
Expand All @@ -136,7 +136,7 @@ class MixedCVaR : public RandVarFunctional<Real> {
void updateValue(Objective<Real> &obj,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
Real pf(0), one(1);
Real val = computeValue(obj,x,tol);
for (int i = 0; i < size_; i++) {
Expand All @@ -147,7 +147,7 @@ class MixedCVaR : public RandVarFunctional<Real> {

Real getValue(const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
Real cvar(0);
sampler.sumAll(&val_,&cvar,1);
for (int i = 0; i < size_; i++) {
Expand All @@ -159,7 +159,7 @@ class MixedCVaR : public RandVarFunctional<Real> {
void updateGradient(Objective<Real> &obj,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
Real pf(0), c(0), one(1);
Real val = computeValue(obj,x,tol);
for (int i = 0; i < size_; i++) {
Expand All @@ -177,7 +177,7 @@ class MixedCVaR : public RandVarFunctional<Real> {
std::vector<Real> &gstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
sampler.sumAll(&vec_[0],&gstat[0],size_);
for (int i = 0; i < size_; i++) {
gstat[i] += coeff_[i];
Expand All @@ -190,7 +190,7 @@ class MixedCVaR : public RandVarFunctional<Real> {
const std::vector<Real> &vstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
Real pf1(0), pf2(0), c(0), one(1);
Real val = computeValue(obj,x,tol);
for (int i = 0; i < size_; i++) {
Expand All @@ -216,7 +216,7 @@ class MixedCVaR : public RandVarFunctional<Real> {
const std::vector<Real> &vstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
sampler.sumAll(&vec_[0],&hvstat[0],size_);
sampler.sumAll(*hv_,hv);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class QuantileRadius : public RandVarFunctional<Real> {
checkInputs();
}

void initialize(const Vector<Real> &x) {
void initialize(const Vector<Real> &x) override {
RandVarFunctional<Real>::initialize(x);
vec_.assign(2,static_cast<Real>(0));
}
Expand All @@ -91,7 +91,7 @@ class QuantileRadius : public RandVarFunctional<Real> {
void updateValue(Objective<Real> &obj,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
const Real half(0.5), one(1);
Real val = computeValue(obj,x,tol);
Real pf1 = plusFunction_->evaluate(val-xstat[0],0);
Expand All @@ -101,7 +101,7 @@ class QuantileRadius : public RandVarFunctional<Real> {

Real getValue(const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
const Real half(0.5);
Real cvar(0);
sampler.sumAll(&val_,&cvar,1);
Expand All @@ -112,7 +112,7 @@ class QuantileRadius : public RandVarFunctional<Real> {
void updateGradient(Objective<Real> &obj,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
const Real half(0.5), one(1);
Real val = computeValue(obj,x,tol);
Real pf1 = plusFunction_->evaluate(val-xstat[0],1);
Expand All @@ -128,7 +128,7 @@ class QuantileRadius : public RandVarFunctional<Real> {
std::vector<Real> &gstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
const Real half(0.5);
sampler.sumAll(&vec_[0],&gstat[0],2);
sampler.sumAll(*g_,g);
Expand All @@ -141,7 +141,7 @@ class QuantileRadius : public RandVarFunctional<Real> {
const std::vector<Real> &vstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
const Real half(0.5), one(1);
Real val = computeValue(obj,x,tol);
Real pf11 = plusFunction_->evaluate(val-xstat[0],1);
Expand All @@ -163,7 +163,7 @@ class QuantileRadius : public RandVarFunctional<Real> {
const std::vector<Real> &vstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
sampler.sumAll(&vec_[0],&hvstat[0],2);
sampler.sumAll(*hv_,hv);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,33 +174,33 @@ class SpectralRisk : public RandVarFunctional<Real> {
}

void setStorage(const Ptr<ScalarController<Real>> &value_storage,
const Ptr<VectorController<Real>> &gradient_storage) {
const Ptr<VectorController<Real>> &gradient_storage) override {
RandVarFunctional<Real>::setStorage(value_storage,gradient_storage);
mqq_->setStorage(value_storage,gradient_storage);
}

void setHessVecStorage(const Ptr<ScalarController<Real>> &gradvec_storage,
const Ptr<VectorController<Real>> &hessvec_storage) {
const Ptr<VectorController<Real>> &hessvec_storage) override {
RandVarFunctional<Real>::setHessVecStorage(gradvec_storage,hessvec_storage);
mqq_->setHessVecStorage(gradvec_storage,hessvec_storage);
}

void setSample(const std::vector<Real> &point, const Real weight) {
void setSample(const std::vector<Real> &point, const Real weight) override {
RandVarFunctional<Real>::setSample(point,weight);
mqq_->setSample(point,weight);
}

void resetStorage(bool flag = true) {
void resetStorage(bool flag = true) override {
RandVarFunctional<Real>::resetStorage(flag);
mqq_->resetStorage(flag);
}

void resetStorage(UpdateType type) {
void resetStorage(UpdateType type) override {
RandVarFunctional<Real>::resetStorage(type);
mqq_->resetStorage(type);
}

void initialize(const Vector<Real> &x) {
void initialize(const Vector<Real> &x) override {
RandVarFunctional<Real>::initialize(x);
mqq_->initialize(x);
}
Expand All @@ -212,14 +212,14 @@ class SpectralRisk : public RandVarFunctional<Real> {
void updateValue(Objective<Real> &obj,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
mqq_->updateValue(obj,x,xstat,tol);
}

void updateGradient(Objective<Real> &obj,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
mqq_->updateGradient(obj,x,xstat,tol);
}

Expand All @@ -228,21 +228,21 @@ class SpectralRisk : public RandVarFunctional<Real> {
const std::vector<Real> &vstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
Real &tol) {
Real &tol) override {
mqq_->updateHessVec(obj,v,vstat,x,xstat,tol);
}

Real getValue(const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
return mqq_->getValue(x,xstat,sampler);
}

void getGradient(Vector<Real> &g,
std::vector<Real> &gstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
mqq_->getGradient(g,gstat,x,xstat,sampler);
}

Expand All @@ -252,7 +252,7 @@ class SpectralRisk : public RandVarFunctional<Real> {
const std::vector<Real> &vstat,
const Vector<Real> &x,
const std::vector<Real> &xstat,
SampleGenerator<Real> &sampler) {
SampleGenerator<Real> &sampler) override {
mqq_->getHessVec(hv,hvstat,v,vstat,x,xstat,sampler);
}
};
Expand Down

0 comments on commit a1491a8

Please sign in to comment.