10#ifndef ROL_SIMCONTROLLER_DEF_H
11#define ROL_SIMCONTROLLER_DEF_H
15template <
class Real,
class Key>
24template <
class Real,
class Key>
28 flags_[it->second] =
false;
33template <
class Real,
class Key>
41 if (conUpdated_ && objUpdated_) {
47template <
class Real,
class Key>
61template <
class Real,
class Key>
81 if (conUpdated_ && objUpdated_) {
88template <
class Real,
class Key>
108 if (conUpdated_ && objUpdated_) {
115template <
class Real,
class Key>
122 return isNull(param,indices_);
126 return isNull(param,indices_temp_);
131template <
class Real,
class Key>
147template <
class Real,
class Key>
162template <
class Real,
class Key>
178template <
class Real,
class Key>
194template <
class Real,
class Key>
211template <
class Real,
class Key>
226template <
class Real,
class Key>
233template <
class Real,
class Key>
240template <
class Real,
class Key>
247template <
class Real,
class Key>
249 const std::map<Key,int> &indices)
const {
250 return (indices.count(param)==0);
253template <
class Real,
class Key>
255 const std::map<Key,int> &indices,
const std::vector<bool> &flags)
const {
256 if (indices.count(param)>0) {
257 auto it = indices.find(param);
258 return flags[it->second];
263template <
class Real,
class Key>
265 std::map<Key,int> &indices, std::vector<bool> &flags,
266 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
267 if (
isNull(param,indices)) {
268 int index = maxIndex;
269 indices.insert(std::pair<Key,int>(param, index));
270 flags.push_back(
false);
271 vectors.push_back(x.
clone());
276template <
class Real,
class Key>
278 const std::map<Key,int> &indices,
const std::vector<bool> &flags,
279 const std::vector<Ptr<
Vector<Real>>> &vectors,
const int &maxIndex)
const {
280 int count = indices.count(param);
281 int index = maxIndex;
283 auto it = indices.find(param);
285 return vectors[index];
290template <
class Real,
class Key>
292 std::map<Key,int> &indices, std::vector<bool> &flags,
293 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
294 ROL_TEST_FOR_EXCEPTION(
isNull(param,indices),std::logic_error,
295 ">>> ROL::VectorController::set : Vector has not been allocated!");
296 ROL_TEST_FOR_EXCEPTION(
isComputed(param,indices,flags),std::logic_error,
297 ">>> ROL::VectorController::set : Vector is already computed!");
298 int count = indices.count(param);
299 int index = maxIndex;
301 auto it = indices.find(param);
304 return vectors[index];
309template <
class Real,
class Key>
311 std::map<Key,int> &indices, std::vector<bool> &flags,
312 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
313 int count = indices.count(param);
315 int index = maxIndex;
317 auto it = indices.find(param);
321 x.
set(*vectors[index]);
325 indices.insert(std::pair<Key,int>(param, index));
326 flags.push_back(
false);
327 vectors.push_back(x.
clone());
333template <
class Real,
class Key>
335 std::map<Key,int> &indices, std::vector<bool> &flags,
336 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
337 int count = indices.count(param);
338 int index = maxIndex;
340 auto it = indices.find(param);
343 vectors[index]->set(x);
346 indices.insert(std::pair<Key,int>(param, index));
347 flags.push_back(
true);
348 vectors.push_back(x.
clone());
349 vectors[index]->set(x);
354template <
class Real,
class Key>
VectorController(void)
Constructor.
bool isComputed(const Key ¶m) const
Check if vector has been computed.
std::vector< Ptr< Vector< Real > > > vectors_trial_
std::vector< bool > flags_trial_
bool isNull(const Key ¶m) const
Check if vector associated with provided key is allocated.
void reset(bool flag=true)
void allocate(const Vector< Real > &x, const Key ¶m)
Allocate the vector associated with provided key.
const Ptr< const Vector< Real > > get(const Key ¶m) const
Return the vector associated with provided key.
std::vector< bool > flags_temp_
const Ptr< Vector< Real > > set(const Key ¶m)
Set the vector associated with provided key. This assumes the vector data will be changed.
std::vector< Ptr< Vector< Real > > > vectors_
std::vector< bool > flags_
std::map< Key, int > indices_trial_
std::vector< Ptr< Vector< Real > > > vectors_temp_
std::map< Key, int > indices_
std::map< Key, int > indices_temp_
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void set(const Vector &x)
Set where .
bool isNull(const Key ¶m) const
Check if vector associated with provided key is allocated.
void allocate(const Vector< Real > &x, const Key ¶m)
Allocate the vector associated with provided key.
void reset(bool flag=true)
void objectiveUpdate(bool flag=true)
Objective function update for VectorController storage.
VectorController(void)
Constructor.
void push(VectorController< Real, Key > &to) const
Push the contents of *this into another VectorController.
bool isComputed(const Key ¶m) const
Check if vector has been computed.
const Ptr< Vector< Real > > set(const Key ¶m)
Set the vector associated with provided key. This assumes the vector data will be changed.
void constraintUpdate(bool flag=true)
Equality constraint update for VectorController storage.
const Ptr< const Vector< Real > > get(const Key ¶m) const
Return the vector associated with provided key.