buffer.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2020 Northwestern University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *********************************************************************/
38 #ifndef BUFFER_HPP
39 #define BUFFER_HPP
40 
41 #include <unordered_map>
42 #include <armadillo>
43 
44 namespace ergodic_exploration
45 {
46 using arma::mat;
47 using arma::vec;
48 
51 {
52 public:
58  ReplayBuffer(unsigned int buffer_size, unsigned int batch_size);
59 
64  void append(const vec& x);
65 
71  mat sampleMemory(const mat& xt) const;
72 
73 private:
74  unsigned int buffer_size_; // total number of past states in memory
75  unsigned int batch_size_; // number of states sampled from memory
76  std::unordered_map<unsigned int, vec> memory_; // past states
77 };
78 } // namespace ergodic_exploration
79 #endif
ergodic_exploration::ReplayBuffer::sampleMemory
mat sampleMemory(const mat &xt) const
Sample states from memory.
Definition: buffer.cpp:64
ergodic_exploration::ReplayBuffer::append
void append(const vec &x)
Add current state to memory.
Definition: buffer.cpp:54
ergodic_exploration::ReplayBuffer
Store and smaple past states.
Definition: buffer.hpp:50
ergodic_exploration::ReplayBuffer::memory_
std::unordered_map< unsigned int, vec > memory_
Definition: buffer.hpp:76
ergodic_exploration::ReplayBuffer::ReplayBuffer
ReplayBuffer(unsigned int buffer_size, unsigned int batch_size)
Constructor.
Definition: buffer.cpp:49
ergodic_exploration::ReplayBuffer::batch_size_
unsigned int batch_size_
Definition: buffer.hpp:75
ergodic_exploration
Definition: basis.hpp:43
ergodic_exploration::ReplayBuffer::buffer_size_
unsigned int buffer_size_
Definition: buffer.hpp:74


ergodic_exploration
Author(s): bostoncleek
autogenerated on Wed Mar 2 2022 00:17:13