Skip to content
Snippets Groups Projects
Commit c59a7243 authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

first attempt of abstracting trust regions

[[Imported from SVN: r4000]]
parent b924191b
No related branches found
No related tags found
No related merge requests found
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment