GCOP
1.0
|
#include <aspsa.h>
Classes | |
struct | Stepcoeffs |
Public Member Functions | |
ASPSA (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 | ~ASPSA () |
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 > | dus1 |
control variation (N) vector | |
std::vector< Vectorcd > | ustemp |
control variation (N) vector | |
std::vector< Vectorcd > | dus2 |
control variation (N) vector | |
std::vector< T > | xss |
states (N+1) vector | |
std::vector< Vectorcd > | uss1 |
controls (N) vector perturb1 | |
std::vector< Vectorcd > | uss2 |
controls (N) vector perturb2 | |
std::vector< Vectorcd > | ghat |
Estimated gradient. | |
std::vector< Vectorcd > | ghatavg |
Estimated avg gradient. | |
std::vector< Vectorcd > | hessian_currest |
Current iterate hessian estimate. | |
std::vector< Vectorcd > | hessian_currestavg |
Current iterate hessian estimate after averaging. | |
std::vector< Vectorcd > | hessian_est |
Estimating Hessian. | |
std::vector< Vectorcd > | hessian_estreg |
Adding Regularizing term. | |
std::vector< Vectorcd > | deltaG |
Difference in Gradient. | |
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 ASPSA to complete in one Iterate function. | |
float | toleranceJ |
Tolerance for how high J can go from the current value to reject some. | |
float | toleranceHessianmag |
Tolerance for how high J can go from the current value to reject some. | |
struct gcop::ASPSA::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::ASPSA< T, n, c, _np >::ASPSA | ( | 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 Adaptive 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::ASPSA< T, n, c, _np >::Stepcoeffs::a, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::A, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::a1, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::A1, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::alpha, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::alpha1, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::c1, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::c11, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::c2, gcop::ASPSA< T, n, c, _np >::deltaG, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::gamma, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::gamma1, gcop::ASPSA< T, n, c, _np >::ghat, gcop::ASPSA< T, n, c, _np >::ghatavg, gcop::ASPSA< T, n, c, _np >::hessian_currest, gcop::ASPSA< T, n, c, _np >::hessian_currestavg, gcop::ASPSA< T, n, c, _np >::hessian_est, gcop::ASPSA< T, n, c, _np >::hessian_estreg, gcop::ASPSA< T, n, c, _np >::J, gcop::ASPSA< T, n, c, _np >::N, gcop::ASPSA< T, n, c, _np >::Stepcoeffs::Navg, gcop::ASPSA< T, n, c, _np >::Nit, gcop::ASPSA< T, n, c, _np >::stepc, gcop::ASPSA< T, n, c, _np >::Update(), and gcop::ASPSA< T, n, c, _np >::us.
gcop::ASPSA< T, n, c, _np >::~ASPSA | ( | ) | [virtual] |
void gcop::ASPSA< T, n, c, _np >::Iterate | ( | ) |
Perform one SYSTEMCE iteration.
double gcop::ASPSA< 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::ASPSA< T, n, c, _np >::ASPSA().
std::bernoulli_distribution gcop::ASPSA< T, n, c, _np >::bernoulli_dist |
Default random engine.
Bernoulli generator for getting perturbations
Cost<T, n, c, _np>& gcop::ASPSA< T, n, c, _np >::cost |
given cost function
bool gcop::ASPSA< T, n, c, _np >::debug |
whether to display debugging info
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::deltaG |
Difference in Gradient.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::dus1 |
control variation (N) vector
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::dus2 |
control variation (N) vector
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::ghat |
Estimated gradient.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::ghatavg |
Estimated avg gradient.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::hessian_currest |
Current iterate hessian estimate.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::hessian_currestavg |
Current iterate hessian estimate after averaging.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::hessian_est |
Estimating Hessian.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::hessian_estreg |
Adding Regularizing term.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
double gcop::ASPSA< T, n, c, _np >::J |
optimal cost
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
int gcop::ASPSA< T, n, c, _np >::N |
number of discrete trajectory segments
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
int gcop::ASPSA< T, n, c, _np >::Nit |
Number of steps of ASPSA to complete in one Iterate function.
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
int gcop::ASPSA< T, n, c, _np >::prevcount |
for now use this to propagate the count forward for every iteration
std::default_random_engine gcop::ASPSA< T, n, c, _np >::randgenerator |
struct gcop::ASPSA::Stepcoeffs gcop::ASPSA< T, n, c, _np >::stepc |
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
System<T, n, c, _np>& gcop::ASPSA< T, n, c, _np >::sys |
dynamical system
float gcop::ASPSA< T, n, c, _np >::toleranceHessianmag |
Tolerance for how high J can go from the current value to reject some.
float gcop::ASPSA< T, n, c, _np >::toleranceJ |
Tolerance for how high J can go from the current value to reject some.
std::vector<double>& gcop::ASPSA< T, n, c, _np >::ts |
times (N+1) vector
std::vector<Vectorcd>& gcop::ASPSA< T, n, c, _np >::us |
controls (N) vector
Referenced by gcop::ASPSA< T, n, c, _np >::ASPSA().
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::uss1 |
controls (N) vector perturb1
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::uss2 |
controls (N) vector perturb2
std::vector<Vectorcd> gcop::ASPSA< T, n, c, _np >::ustemp |
control variation (N) vector
std::vector<T>& gcop::ASPSA< T, n, c, _np >::xs |
states (N+1) vector
std::vector<T> gcop::ASPSA< T, n, c, _np >::xss |
states (N+1) vector