GCOP  1.0
Classes | Public Member Functions | Public Attributes
gcop::SPSA< T, n, c, _np > Class Template Reference

#include <spsa.h>

Collaboration diagram for gcop::SPSA< T, n, c, _np >:
Collaboration graph
[legend]

List of all members.

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

template<typename T, int n = Dynamic, int c = Dynamic, int _np = Dynamic>
class gcop::SPSA< T, n, c, _np >


Constructor & Destructor Documentation

template<typename T , int n, int c, int _np>
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.

Parameters:
syssystem
costcost
ts(N+1) sequence of discrete times
xs(N+1) sequence of discrete states
us(N) sequence of control inputs
updatewhether 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.

template<typename T , int n, int c, int _np>
gcop::SPSA< T, n, c, _np >::~SPSA ( ) [virtual]

Member Function Documentation

template<typename T , int n, int c, int _np>
void gcop::SPSA< T, n, c, _np >::Iterate ( )

Perform one SYSTEMCE iteration.

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
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

Parameters:
xstrajectory
uscontrols
evalCostwhether to compute and return the trajectory cost

Referenced by gcop::SPSA< T, n, c, _np >::SPSA().


Member Data Documentation

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::bernoulli_distribution gcop::SPSA< T, n, c, _np >::bernoulli_dist

Default random engine.

Bernoulli generator for getting perturbations

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
Cost<T, n, c, _np>& gcop::SPSA< T, n, c, _np >::cost

given cost function

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
bool gcop::SPSA< T, n, c, _np >::debug

whether to display debugging info

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::vector<Vectorcd> gcop::SPSA< T, n, c, _np >::dus

control variation (N) vector

Referenced by gcop::SPSA< T, n, c, _np >::SPSA().

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
double gcop::SPSA< T, n, c, _np >::J

optimal cost

Referenced by gcop::SPSA< T, n, c, _np >::SPSA().

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
int gcop::SPSA< T, n, c, _np >::N

number of discrete trajectory segments

Referenced by gcop::SPSA< T, n, c, _np >::SPSA().

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
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().

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
int gcop::SPSA< T, n, c, _np >::prevcount

for now use this to propagate the count forward for every iteration

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::default_random_engine gcop::SPSA< T, n, c, _np >::randgenerator
template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
struct gcop::SPSA::Stepcoeffs gcop::SPSA< T, n, c, _np >::stepc
template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
System<T, n, c, _np>& gcop::SPSA< T, n, c, _np >::sys

dynamical system

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::vector<double>& gcop::SPSA< T, n, c, _np >::ts

times (N+1) vector

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::vector<Vectorcd>& gcop::SPSA< T, n, c, _np >::us

controls (N) vector

Referenced by gcop::SPSA< T, n, c, _np >::SPSA().

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::vector<Vectorcd> gcop::SPSA< T, n, c, _np >::uss

controls (N) vector

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::vector<T>& gcop::SPSA< T, n, c, _np >::xs

states (N+1) vector

template<typename T , int n = Dynamic, int c = Dynamic, int _np = Dynamic>
std::vector<T> gcop::SPSA< T, n, c, _np >::xss

states (N+1) vector


The documentation for this class was generated from the following file: