From c59a72433ea65ad547886c8db4dffe68a532d293 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Thu, 16 Apr 2009 12:07:41 +0000 Subject: [PATCH] first attempt of abstracting trust regions [[Imported from SVN: r4000]] --- src/maxnormtrustregion.hh | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/maxnormtrustregion.hh diff --git a/src/maxnormtrustregion.hh b/src/maxnormtrustregion.hh new file mode 100644 index 00000000..4d9fddda --- /dev/null +++ b/src/maxnormtrustregion.hh @@ -0,0 +1,61 @@ +#ifndef MAX_NORM_TRUST_REGION_HH +#define MAX_NORM_TRUST_REGION_HH + +template <int blocksize> +class MaxNormTrustRegion +{ +public: + + MaxNormTrustRegion(size_t size, double initialRadius) + : obstacles_(size) + { + set(initialRadius); + } + + void set(double radius) { + + for (size_t i=0; i<obstacles_.size(); i++) { + + for (int k=0; k<blocksize; k++) { + + obstacles_[i].lower(k) = -radius; + obstacles_[i].upper(k) = radius; + + } + + } + + } + + double radius() const { + assert(obstacles_.size()>0); + assert(blocksize>0); + return obstacles_[0].upper(0); + } + + void scale(double factor) { + + for (size_t i=0; i<obstacles_.size(); i++) { + + for (int k=0; k<blocksize; k++) { + + obstacles_[i].lower(k) *= factor; + obstacles_[i].upper(k) *= factor; + + } + + } + + } + + const std::vector<BoxConstraint<double,blocksize> >& obstacles() const { + return obstacles_; + } + +private: + + std::vector<BoxConstraint<double,blocksize> > obstacles_; + +}; + +#endif -- GitLab