ROL
ROL_VectorController.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Rapid Optimization Library (ROL) Package
4//
5// Copyright 2014 NTESS and the ROL contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef ROL_SIMCONTROLLER_H
11#define ROL_SIMCONTROLLER_H
12
13#include "ROL_Vector.hpp"
14#include "ROL_UpdateType.hpp"
15#include <map>
16#include <vector>
17
18namespace ROL {
19
20template <class Real, class Key=std::vector<Real>>
22private:
23 // Storage
25 std::vector<bool> flags_, flags_trial_, flags_temp_;
26 std::vector<Ptr<Vector<Real>>> vectors_, vectors_trial_, vectors_temp_;
28
29 // Update flags
32
33public:
36 VectorController(void);
37
38 void reset(bool flag = true);
39
42 void objectiveUpdate(bool flag = true);
43
46 void constraintUpdate(bool flag = true);
47
50 void objectiveUpdate(UpdateType type);
51
55
58 bool isNull(const Key &param) const;
59
62 bool isComputed(const Key &param) const;
63
66 void allocate(const Vector<Real> &x, const Key &param);
67
71 const Ptr<Vector<Real>> set(const Key &param);
72
75 const Ptr<const Vector<Real>> get(const Key &param) const;
76
79 bool get(Vector<Real> &x, const Key &param);
80
83 void set(const Vector<Real> &x, const Key &param);
84
87 void push(VectorController<Real,Key> &to) const;
88
89private:
90
91 void resetTrial(void);
92
93 void resetTemp(void);
94
95 bool isNull(const Key &param, const std::map<Key,int> &indices) const;
96
97 bool isComputed(const Key &param, const std::map<Key,int> &indices,
98 const std::vector<bool> &flags) const;
99
100 void allocate(const Vector<Real> &x, const Key &param,
101 std::map<Key,int> &indices, std::vector<bool> &flags,
102 std::vector<Ptr<Vector<Real>>> &vectors, int &maxIndex) const;
103
104 const Ptr<const Vector<Real>> get(const Key &param,
105 const std::map<Key,int> &indices, const std::vector<bool> &flags,
106 const std::vector<Ptr<Vector<Real>>> &vectors, const int &maxIndex) const;
107
108 const Ptr<Vector<Real>> set(const Key &param,
109 std::map<Key,int> &indices, std::vector<bool> &flags,
110 std::vector<Ptr<Vector<Real>>> &vectors, int &maxIndex) const;
111
112 bool get(Vector<Real> &x, const Key &param,
113 std::map<Key,int> &indices, std::vector<bool> &flags,
114 std::vector<Ptr<Vector<Real>>> &vectors, int &maxIndex) const;
115
116 void set(const Vector<Real> &x, const Key &param,
117 std::map<Key,int> &indices, std::vector<bool> &flags,
118 std::vector<Ptr<Vector<Real>>> &vectors, int &maxIndex) const;
119
120 void accept(void);
121}; // class VectorController
122
123} // namespace ROL
124
126
127#endif
bool isNull(const Key &param) const
Check if vector associated with provided key is allocated.
void allocate(const Vector< Real > &x, const Key &param)
Allocate the vector associated with provided key.
std::vector< bool > flags_trial_
std::vector< Ptr< Vector< Real > > > vectors_
void objectiveUpdate(bool flag=true)
Objective function update for VectorController storage.
std::vector< Ptr< Vector< Real > > > vectors_trial_
std::map< Key, int > indices_temp_
void push(VectorController< Real, Key > &to) const
Push the contents of *this into another VectorController.
std::vector< bool > flags_temp_
std::map< Key, int > indices_
bool isComputed(const Key &param) const
Check if vector has been computed.
const Ptr< Vector< Real > > set(const Key &param)
Set the vector associated with provided key. This assumes the vector data will be changed.
std::map< Key, int > indices_trial_
std::vector< Ptr< Vector< Real > > > vectors_temp_
void constraintUpdate(bool flag=true)
Equality constraint update for VectorController storage.
const Ptr< const Vector< Real > > get(const Key &param) const
Return the vector associated with provided key.
Defines the linear algebra or vector space interface.