45#ifndef ROL_SIMCONTROLLER_DEF_H
46#define ROL_SIMCONTROLLER_DEF_H
50template <
class Real,
class Key>
59template <
class Real,
class Key>
63 flags_[it->second] =
false;
68template <
class Real,
class Key>
82template <
class Real,
class Key>
96template <
class Real,
class Key>
116 if (conUpdated_ && objUpdated_) {
123template <
class Real,
class Key>
143 if (conUpdated_ && objUpdated_) {
150template <
class Real,
class Key>
157 return isNull(param,indices_);
161 return isNull(param,indices_temp_);
166template <
class Real,
class Key>
182template <
class Real,
class Key>
197template <
class Real,
class Key>
213template <
class Real,
class Key>
229template <
class Real,
class Key>
246template <
class Real,
class Key>
261template <
class Real,
class Key>
268template <
class Real,
class Key>
275template <
class Real,
class Key>
282template <
class Real,
class Key>
284 const std::map<Key,int> &indices)
const {
285 return (indices.count(param)==0);
288template <
class Real,
class Key>
290 const std::map<Key,int> &indices,
const std::vector<bool> &flags)
const {
291 if (indices.count(param)>0) {
292 auto it = indices.find(param);
293 return flags[it->second];
298template <
class Real,
class Key>
300 std::map<Key,int> &indices, std::vector<bool> &flags,
301 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
302 if (
isNull(param,indices)) {
303 int index = maxIndex;
304 indices.insert(std::pair<Key,int>(param, index));
305 flags.push_back(
false);
306 vectors.push_back(x.
clone());
311template <
class Real,
class Key>
313 const std::map<Key,int> &indices,
const std::vector<bool> &flags,
314 const std::vector<Ptr<
Vector<Real>>> &vectors,
const int &maxIndex)
const {
315 int count = indices.count(param);
316 int index = maxIndex;
318 auto it = indices.find(param);
320 return vectors[index];
325template <
class Real,
class Key>
327 std::map<Key,int> &indices, std::vector<bool> &flags,
328 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
329 ROL_TEST_FOR_EXCEPTION(
isNull(param,indices),std::logic_error,
330 ">>> ROL::VectorController::set : Vector has not been allocated!");
331 ROL_TEST_FOR_EXCEPTION(
isComputed(param,indices,flags),std::logic_error,
332 ">>> ROL::VectorController::set : Vector is already computed!");
333 int count = indices.count(param);
334 int index = maxIndex;
336 auto it = indices.find(param);
339 return vectors[index];
344template <
class Real,
class Key>
346 std::map<Key,int> &indices, std::vector<bool> &flags,
347 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
348 int count = indices.count(param);
350 int index = maxIndex;
352 auto it = indices.find(param);
356 x.
set(*vectors[index]);
360 indices.insert(std::pair<Key,int>(param, index));
361 flags.push_back(
false);
362 vectors.push_back(x.
clone());
368template <
class Real,
class Key>
370 std::map<Key,int> &indices, std::vector<bool> &flags,
371 std::vector<Ptr<
Vector<Real>>> &vectors,
int &maxIndex)
const {
372 int count = indices.count(param);
373 int index = maxIndex;
375 auto it = indices.find(param);
378 vectors[index]->set(x);
381 indices.insert(std::pair<Key,int>(param, index));
382 flags.push_back(
true);
383 vectors.push_back(x.
clone());
384 vectors[index]->set(x);
389template <
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 std::vector< Real > ¶m) const
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.