GCOP
1.0
|
#include <spsa.h>
Classes | |
struct | Stepcoeffs |
Public Member Functions | |
SPSA (System< T, n, c, _np > &sys, Cost< T, n, c, _np > &cost, vector< double > &ts, vector< T > &xs, vector< Vectorcd > &us, Vectormd *p=0, bool update=true) | |
virtual | ~SPSA () |
void | Iterate () |
double | Update (std::vector< T > &xs, const std::vector< Vectorcd > &us, bool evalCost=true) |
Public Attributes | |
System< T, n, c, _np > & | sys |
dynamical system | |
Cost< T, n, c, _np > & | cost |
given cost function | |
std::vector< double > & | ts |
times (N+1) vector | |
std::vector< T > & | xs |
states (N+1) vector | |
std::vector< Vectorcd > & | us |
controls (N) vector | |
std::vector< Vectorcd > | dus |
control variation (N) vector | |
std::vector< T > | xss |
states (N+1) vector | |
std::vector< Vectorcd > | uss |
controls (N) vector | |
std::default_random_engine | randgenerator |
std::bernoulli_distribution | bernoulli_dist |
Default random engine. | |
int | N |
number of discrete trajectory segments | |
int | Nit |
Number of steps of SPSA to complete in one Iterate function. | |
struct gcop::SPSA::Stepcoeffs | stepc |
double | J |
optimal cost | |
bool | debug |
whether to display debugging info | |
int | prevcount |
for now use this to propagate the count forward for every iteration |
gcop::SPSA< T, n, c, _np >::SPSA | ( | System< T, n, c, _np > & | sys, |
Cost< T, n, c, _np > & | cost, | ||
vector< double > & | ts, | ||
vector< T > & | xs, | ||
vector< Vectorcd > & | us, | ||
Vectormd * | p = 0 , |
||
bool | update = true |
||
) |
Implementing a Simultaneous Perturbation and Stochastic Approximation algorithm in GCOP library. The gains needed for the algorithms should be chosen wisely using Section 7.5.2 of Introduction to Stochastic Search and Optimization (ISSO) book.
This method minimizes the cost of a trajectory using the input parameters as us The times ts must be given, the initial state xs[0] must be set, and the controls us will be used as an initial guess for the optimization.
After initialization, every call to Iterate() will optimize the controls us and states xs and modify them accordingly. Problems involving time-optimization will also modify the sequence of times ts.
sys | system |
cost | cost |
ts | (N+1) sequence of discrete times |
xs | (N+1) sequence of discrete states |
us | (N) sequence of control inputs |
update | whether to update trajectory xs using initial state xs[0] and inputs us. This is necessary only if xs was not already generated from us. |
References gcop::SPSA< T, n, c, _np >::Stepcoeffs::a, gcop::SPSA< T, n, c, _np >::Stepcoeffs::A, gcop::SPSA< T, n, c, _np >::Stepcoeffs::alpha, gcop::SPSA< T, n, c, _np >::Stepcoeffs::c1, gcop::SPSA< T, n, c, _np >::dus, gcop::SPSA< T, n, c, _np >::Stepcoeffs::gamma, gcop::SPSA< T, n, c, _np >::J, gcop::SPSA< T, n, c, _np >::N, gcop::SPSA< T, n, c, _np >::Nit, gcop::SPSA< T, n, c, _np >::stepc, gcop::SPSA< T, n, c, _np >::Update(), and gcop::SPSA< T, n, c, _np >::us.
gcop::SPSA< T, n, c, _np >::~SPSA | ( | ) | [virtual] |
void gcop::SPSA< T, n, c, _np >::Iterate | ( | ) |
Perform one SYSTEMCE iteration.
double gcop::SPSA< T, n, c, _np >::Update | ( | std::vector< T > & | xs, |
const std::vector< Vectorcd > & | us, | ||
bool | evalCost = true |
||
) |
Generate a full trajectory (xs and us) from a parameter z and (optionally) return its cost
xs | trajectory |
us | controls |
evalCost | whether to compute and return the trajectory cost |
Referenced by gcop::SPSA< T, n, c, _np >::SPSA().
std::bernoulli_distribution gcop::SPSA< T, n, c, _np >::bernoulli_dist |
Default random engine.
Bernoulli generator for getting perturbations
Cost<T, n, c, _np>& gcop::SPSA< T, n, c, _np >::cost |
given cost function
bool gcop::SPSA< T, n, c, _np >::debug |
whether to display debugging info
std::vector<Vectorcd> gcop::SPSA< T, n, c, _np >::dus |
control variation (N) vector
Referenced by gcop::SPSA< T, n, c, _np >::SPSA().
double gcop::SPSA< T, n, c, _np >::J |
optimal cost
Referenced by gcop::SPSA< T, n, c, _np >::SPSA().
int gcop::SPSA< T, n, c, _np >::N |
number of discrete trajectory segments
Referenced by gcop::SPSA< T, n, c, _np >::SPSA().
int gcop::SPSA< T, n, c, _np >::Nit |
Number of steps of SPSA to complete in one Iterate function.
Referenced by gcop::SPSA< T, n, c, _np >::SPSA().
int gcop::SPSA< T, n, c, _np >::prevcount |
for now use this to propagate the count forward for every iteration
std::default_random_engine gcop::SPSA< T, n, c, _np >::randgenerator |
struct gcop::SPSA::Stepcoeffs gcop::SPSA< T, n, c, _np >::stepc |
Referenced by gcop::SPSA< T, n, c, _np >::SPSA().
System<T, n, c, _np>& gcop::SPSA< T, n, c, _np >::sys |
dynamical system
std::vector<double>& gcop::SPSA< T, n, c, _np >::ts |
times (N+1) vector
std::vector<Vectorcd>& gcop::SPSA< T, n, c, _np >::us |
controls (N) vector
Referenced by gcop::SPSA< T, n, c, _np >::SPSA().
std::vector<Vectorcd> gcop::SPSA< T, n, c, _np >::uss |
controls (N) vector
std::vector<T>& gcop::SPSA< T, n, c, _np >::xs |
states (N+1) vector
std::vector<T> gcop::SPSA< T, n, c, _np >::xss |
states (N+1) vector