GCOP
1.0
|
#include <systemce.h>
Public Member Functions | |
SystemCe (System< T, n, c, np > &sys, Cost< T, n, c, np, Tc > &cost, vector< double > &ts, vector< T > &xs, vector< Vectorcd > &us, Vectormd *p, vector< Vectorcd > &dus, vector< Vectorcd > &es, bool update=true) | |
SystemCe (System< T, n, c, np > &sys, Cost< T, n, c, np, Tc > &cost, Tparam< T, n, c, np, ntp, Tc > &tp, vector< double > &ts, vector< T > &xs, vector< Vectorcd > &us, Vectormd *p, vector< Vectorcd > &dus, vector< Vectorcd > &es, bool update=true) | |
SystemCe (System< T, n, c, np > &sys, Cost< T, n, c, np, Tc > &cost, Tparam< T, n, c, np, ntp, Tc > &tp, vector< double > &ts, vector< T > &xs, vector< Vectorcd > &us, Vectormd *p, VectorXd &dss, VectorXd &dess, bool update=true) | |
SystemCe (System< T, n, c, np > &sys, Cost< T, n, c, np, Tc > &cost, Tparam< T, n, c, np, ntp, Tc > &tp, Creator< Tc > *contextSampler, vector< double > &ts, vector< T > &xs, vector< Vectorcd > &us, Vectormd *p, Vectortpd &mu0, Matrixtpd &P0, Matrixtpd &S, bool update=true) | |
virtual | ~SystemCe () |
void | Iterate (bool updatexsfromus=true) |
double | Update (std::vector< T > &xs, const std::vector< Vectorcd > &us, bool evalCost=true) |
void | us2z (Vectortpd &z, const std::vector< Vectorcd > &us) const |
void | z2us (std::vector< Vectorcd > &us, const Vectortpd &z) const |
SystemCe (System< T, n, c, np > &sys, Cost< T, n, c, np > &cost, vector< double > &ts, vector< T > &xs, vector< Vectorcd > &us, Vectormd *p, vector< Vectorcd > &dus, vector< Vectorcd > &es, bool update=true) | |
SystemCe (System< T, n, c, np > &sys, Cost< T, n, c, np > &cost, Tparam< T, n, c, np, ntp > &tp, vector< double > &ts, vector< T > &xs, vector< Vectorcd > &us, Vectormd *p, vector< Vectorcd > &dus, vector< Vectorcd > &es, bool update=true) | |
virtual | ~SystemCe () |
void | Iterate () |
double | Update (std::vector< T > &xs, const std::vector< Vectorcd > &us, bool evalCost=true) |
void | us2z (Vectortpd &z, const std::vector< Vectorcd > &us) const |
void | z2us (std::vector< Vectorcd > &us, const Vectortpd &z) const |
Public Attributes | |
System< T, n, c, np > & | sys |
dynamical system | |
Cost< T, n, c, np, Tc > & | cost |
given cost function | |
Tparam< T, n, c, np, ntp, Tc > * | tp |
trajectory parametrization | |
Creator< Tc > * | contextSampler |
context sampler | |
std::vector< double > & | ts |
times (N+1) vector | |
std::vector< T > & | xs |
states (N+1) vector | |
std::vector< Vectorcd > & | us |
controls (N) vector | |
Vectormd * | p |
system internal parameters | |
std::vector< Vectorcd > & | dus |
control standard deviations (N) vector | |
std::vector< T > | xss |
states (N+1) vector | |
std::vector< Vectorcd > | uss |
controls (N) vector | |
std::vector< std::vector< T > > | xsas |
all state samples | |
std::vector< std::vector < Vectorcd > > | usas |
all control samples | |
std::vector< bool > | bs |
all samples feasibility | |
int | N |
number of discrete trajectory segments | |
Ce< ntp > | ce |
GMM-based cross-entropy algorithm. | |
int | Ns |
number of cross-entropy samples | |
double | J |
optimal cost | |
bool | enforceUpperBound |
whether to discard any samples with cost > Jub (true by default) | |
bool | updateUpperBound |
after every iteration Jub is updated to be the current max cost (true by default) | |
double | Jub |
allowed cost upper bound (inf by default) | |
Vectortpd | zmin |
Current best z corresponding to J. | |
int | nofevaluations |
Number of evaluations at any point of time. | |
bool | debug |
whether to display debugging info | |
RenderFunc * | external_render |
RenderFunction for rendering samples. | |
Cost< T, n, c, np > & | cost |
given cost function | |
Tparam< T, n, c, np, ntp > * | tp |
trajectory parametrization |
The CE method for dynamical systems
Note: the vector dus should denote the variances along the diagonal of the initial distribution
Authors: Marin Kobilarov, Gowtham Garimella
gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe | ( | System< T, n, c, np > & | sys, |
Cost< T, n, c, np, Tc > & | cost, | ||
vector< double > & | ts, | ||
vector< T > & | xs, | ||
vector< Vectorcd > & | us, | ||
Vectormd * | p, | ||
vector< Vectorcd > & | dus, | ||
vector< Vectorcd > & | es, | ||
bool | update = true |
||
) |
Create an optimal control problem using a system, a cost, and a trajectory given by a sequence of times, states, and controls. The times ts must be given, the initial state xs[0] must be set, and the optimization will be performed over the controls us
sys | system |
cost | cost |
ts | (N+1) sequence of discrete times |
xs | (N+1) sequence of discrete states |
us | (N) sequence of control inputs |
p | (np-size) system parameters (set to 0 if none) |
dus | (N) initial control standard deviations (determines how widespread the initial distro is) |
es | (N) zero-mean regularization/local-exploration noise variances |
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::SystemCe< T, n, c, np, ntp, Tc >::ce, gcop::SystemCe< T, n, c, np, ntp, Tc >::dus, gcop::Ce< _n >::gmm, gcop::SystemCe< T, n, c, np, ntp, Tc >::J, gcop::Manifold< T, _n >::n, gcop::SystemCe< T, n, c, np, ntp, Tc >::N, gcop::Ce< _n >::S, gcop::System< T, _nx, _nu, _np >::U, gcop::SystemCe< T, n, c, np, ntp, Tc >::Update(), gcop::SystemCe< T, n, c, np, ntp, Tc >::us, gcop::SystemCe< T, n, c, np, ntp, Tc >::us2z(), gcop::SystemCe< T, n, c, np, ntp, Tc >::uss, and gcop::SystemCe< T, n, c, np, ntp, Tc >::xss.
gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe | ( | System< T, n, c, np > & | sys, |
Cost< T, n, c, np, Tc > & | cost, | ||
Tparam< T, n, c, np, ntp, Tc > & | tp, | ||
vector< double > & | ts, | ||
vector< T > & | xs, | ||
vector< Vectorcd > & | us, | ||
Vectormd * | p, | ||
vector< Vectorcd > & | dus, | ||
vector< Vectorcd > & | es, | ||
bool | update = true |
||
) |
Create an optimal control problem using a system, a cost, and a trajectory parametrized using a finite set of parameters of dimension ntp The parametrization Tparam defines a mapping between the parameters and a discrete trajectory at times ts, states xs, and control us (and optionally system parameters p) Optimization occurs over the parametrization.
sys | system |
cost | cost |
tp | trajectory parametrization |
ts | (N+1) sequence of discrete times |
xs | (N+1) sequence of discrete states |
us | (N) sequence of control inputs |
p | (np-size) system parameters (set to 0 if none) |
dus | (N) initial control standard deviations (determines how widespread the initial distro is) |
es | (N) zero-mean regularization/local-exploration noise variances |
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::SystemCe< T, n, c, np, ntp, Tc >::ce, gcop::SystemCe< T, n, c, np, ntp, Tc >::dus, gcop::Ce< _n >::gmm, gcop::SystemCe< T, n, c, np, ntp, Tc >::J, gcop::SystemCe< T, n, c, np, ntp, Tc >::N, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::ntp, gcop::Ce< _n >::S, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::To(), gcop::SystemCe< T, n, c, np, ntp, Tc >::Update(), gcop::SystemCe< T, n, c, np, ntp, Tc >::us, gcop::SystemCe< T, n, c, np, ntp, Tc >::uss, and gcop::SystemCe< T, n, c, np, ntp, Tc >::xss.
gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe | ( | System< T, n, c, np > & | sys, |
Cost< T, n, c, np, Tc > & | cost, | ||
Tparam< T, n, c, np, ntp, Tc > & | tp, | ||
vector< double > & | ts, | ||
vector< T > & | xs, | ||
vector< Vectorcd > & | us, | ||
Vectormd * | p, | ||
VectorXd & | dss, | ||
VectorXd & | dess, | ||
bool | update = true |
||
) |
Create an optimal control problem using a system, a cost, and a trajectory parametrized using a finite set of parameters of dimension ntp The parametrization Tparam defines a mapping between the parameters and a discrete trajectory at times ts, states xs, and control us (and optionally system parameters p) Optimization occurs over the parametrization.
sys | system |
cost | cost |
tp | trajectory parametrization |
ts | (N+1) sequence of discrete times |
xs | (N+1) sequence of discrete states |
us | (N) sequence of control inputs |
p | (np-size) system parameters (set to 0 if none) |
dss | (N) initial tparam variances (determines how widespread the initial distro is) |
dess | (N) zero-mean regularization/local-exploration noise variances |
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::SystemCe< T, n, c, np, ntp, Tc >::ce, gcop::Ce< _n >::gmm, gcop::SystemCe< T, n, c, np, ntp, Tc >::J, gcop::SystemCe< T, n, c, np, ntp, Tc >::N, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::ntp, gcop::Ce< _n >::S, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::To(), gcop::SystemCe< T, n, c, np, ntp, Tc >::Update(), gcop::SystemCe< T, n, c, np, ntp, Tc >::uss, and gcop::SystemCe< T, n, c, np, ntp, Tc >::xss.
gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe | ( | System< T, n, c, np > & | sys, |
Cost< T, n, c, np, Tc > & | cost, | ||
Tparam< T, n, c, np, ntp, Tc > & | tp, | ||
Creator< Tc > * | contextSampler, | ||
vector< double > & | ts, | ||
vector< T > & | xs, | ||
vector< Vectorcd > & | us, | ||
Vectormd * | p, | ||
Vectortpd & | mu0, | ||
Matrixtpd & | P0, | ||
Matrixtpd & | S, | ||
bool | update = true |
||
) |
Create an optimal control problem using a system, a cost, and a trajectory parametrized using a finite set of parameters of dimension ntp The parametrization Tparam defines a mapping between the parameters and a discrete trajectory at times ts, states xs, and control us (and optionally system parameters p) For this cosntructor, it is not necessary to have a mapping from discrete trajectory to tparam, but only fro tparam to discrete trajectory.
sys | system |
cost | cost |
tp | trajectory parametrization |
ts | (N+1) sequence of discrete times |
xs | (N+1) sequence of discrete states |
us | (N) sequence of control inputs |
p | (np-size) system parameters (set to 0 if none) |
mu0 | (N) initial tparam parameters mean |
P0 | (N) initial tparam parameters covaraiance |
S | (N) zero-mean regularization/local-exploration noise variances |
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::SystemCe< T, n, c, np, ntp, Tc >::ce, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::From(), gcop::Ce< _n >::gmm, gcop::SystemCe< T, n, c, np, ntp, Tc >::N, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::ntp, gcop::Ce< _n >::S, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::SetContext(), gcop::SystemCe< T, n, c, np, ntp, Tc >::uss, and gcop::SystemCe< T, n, c, np, ntp, Tc >::xss.
gcop::SystemCe< T, n, c, np, ntp >::~SystemCe | ( | ) | [virtual] |
gcop::SystemCe< T, n, c, np, ntp >::SystemCe | ( | System< T, n, c, np > & | sys, |
Cost< T, n, c, np > & | cost, | ||
vector< double > & | ts, | ||
vector< T > & | xs, | ||
vector< Vectorcd > & | us, | ||
Vectormd * | p, | ||
vector< Vectorcd > & | dus, | ||
vector< Vectorcd > & | es, | ||
bool | update = true |
||
) |
Create an optimal control problem using a system, a cost, and a trajectory given by a sequence of times, states, and controls. 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 |
p | (np-size) system parameters (set to 0 if none) |
dus | (N) initial control variations (determines how widespread the initial distro is) |
es | (N) zero-mean regularization/local-exploration noise variances |
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::SystemCe< T, n, c, np, ntp, Tc >::ce, gcop::SystemCe< T, n, c, np, ntp, Tc >::dus, gcop::Ce< _n >::gmm, gcop::SystemCe< T, n, c, np, ntp, Tc >::J, gcop::Manifold< T, _n >::n, gcop::SystemCe< T, n, c, np, ntp, Tc >::N, gcop::Ce< _n >::S, gcop::System< T, _nx, _nu, _np >::U, gcop::SystemCe< T, n, c, np, ntp, Tc >::Update(), gcop::SystemCe< T, n, c, np, ntp, Tc >::us, gcop::SystemCe< T, n, c, np, ntp, Tc >::us2z(), gcop::SystemCe< T, n, c, np, ntp, Tc >::uss, and gcop::SystemCe< T, n, c, np, ntp, Tc >::xss.
gcop::SystemCe< T, n, c, np, ntp >::SystemCe | ( | System< T, n, c, np > & | sys, |
Cost< T, n, c, np > & | cost, | ||
Tparam< T, n, c, np, ntp > & | tp, | ||
vector< double > & | ts, | ||
vector< T > & | xs, | ||
vector< Vectorcd > & | us, | ||
Vectormd * | p, | ||
vector< Vectorcd > & | dus, | ||
vector< Vectorcd > & | es, | ||
bool | update = true |
||
) |
Create an optimal control problem using a system, a cost, and a trajectory given by a sequence of times, states, and controls. 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 |
tp | trajectory parametrization |
ts | (N+1) sequence of discrete times |
xs | (N+1) sequence of discrete states |
us | (N) sequence of control inputs |
p | (np-size) system parameters (set to 0 if none) |
dus | (N) initial control variations (determines how widespread the initial distro is) |
es | (N) zero-mean regularization/local-exploration noise variances |
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::SystemCe< T, n, c, np, ntp, Tc >::ce, gcop::SystemCe< T, n, c, np, ntp, Tc >::dus, gcop::Ce< _n >::gmm, gcop::SystemCe< T, n, c, np, ntp, Tc >::J, gcop::SystemCe< T, n, c, np, ntp, Tc >::N, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::ntp, gcop::Ce< _n >::S, gcop::Tparam< T, nx, nu, np, _ntp, Tc >::To(), gcop::SystemCe< T, n, c, np, ntp, Tc >::Update(), gcop::SystemCe< T, n, c, np, ntp, Tc >::us, gcop::SystemCe< T, n, c, np, ntp, Tc >::uss, and gcop::SystemCe< T, n, c, np, ntp, Tc >::xss.
virtual gcop::SystemCe< T, n, c, np, ntp, Tc >::~SystemCe | ( | ) | [virtual] |
void gcop::SystemCe< T, n, c, np, ntp >::Iterate | ( | ) |
Perform one SYSTEMCE iteration.
void gcop::SystemCe< T, n, c, np, ntp, Tc >::Iterate | ( | bool | updatexsfromus = true | ) |
Perform one SYSTEMCE iteration.
double gcop::SystemCe< T, n, c, np, ntp, Tc >::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 |
double gcop::SystemCe< T, n, c, np, ntp, Tc >::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::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
void gcop::SystemCe< T, n, c, np, ntp, Tc >::us2z | ( | Vectortpd & | z, |
const std::vector< Vectorcd > & | us | ||
) | const |
void gcop::SystemCe< T, n, c, np, ntp >::us2z | ( | Vectortpd & | z, |
const std::vector< Vectorcd > & | us | ||
) | const |
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
void gcop::SystemCe< T, n, c, np, ntp, Tc >::z2us | ( | std::vector< Vectorcd > & | us, |
const Vectortpd & | z | ||
) | const |
void gcop::SystemCe< T, n, c, np, ntp >::z2us | ( | std::vector< Vectorcd > & | us, |
const Vectortpd & | z | ||
) | const |
std::vector< bool > gcop::SystemCe< T, n, c, np, ntp, Tc >::bs |
all samples feasibility
Ce< ntp > gcop::SystemCe< T, n, c, np, ntp, Tc >::ce |
GMM-based cross-entropy algorithm.
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
Creator<Tc>* gcop::SystemCe< T, n, c, np, ntp, Tc >::contextSampler |
context sampler
Cost<T, n, c, np>& gcop::SystemCe< T, n, c, np, ntp, Tc >::cost |
given cost function
Cost<T, n, c, np, Tc>& gcop::SystemCe< T, n, c, np, ntp, Tc >::cost |
given cost function
bool gcop::SystemCe< T, n, c, np, ntp, Tc >::debug |
whether to display debugging info
std::vector< Vectorcd > & gcop::SystemCe< T, n, c, np, ntp, Tc >::dus |
control standard deviations (N) vector
control variation (N) vector
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
bool gcop::SystemCe< T, n, c, np, ntp, Tc >::enforceUpperBound |
whether to discard any samples with cost > Jub (true by default)
RenderFunc * gcop::SystemCe< T, n, c, np, ntp, Tc >::external_render |
RenderFunction for rendering samples.
double gcop::SystemCe< T, n, c, np, ntp, Tc >::J |
optimal cost
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
double gcop::SystemCe< T, n, c, np, ntp, Tc >::Jub |
allowed cost upper bound (inf by default)
int gcop::SystemCe< T, n, c, np, ntp, Tc >::N |
number of discrete trajectory segments
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
int gcop::SystemCe< T, n, c, np, ntp, Tc >::nofevaluations |
Number of evaluations at any point of time.
int gcop::SystemCe< T, n, c, np, ntp, Tc >::Ns |
number of cross-entropy samples
Vectormd * gcop::SystemCe< T, n, c, np, ntp, Tc >::p |
system internal parameters
controls (N) vector
System< T, n, c, np > & gcop::SystemCe< T, n, c, np, ntp, Tc >::sys |
dynamical system
Tparam<T, n, c, np, ntp>* gcop::SystemCe< T, n, c, np, ntp, Tc >::tp |
trajectory parametrization
Tparam<T, n, c, np, ntp, Tc>* gcop::SystemCe< T, n, c, np, ntp, Tc >::tp |
trajectory parametrization
std::vector< double > & gcop::SystemCe< T, n, c, np, ntp, Tc >::ts |
times (N+1) vector
bool gcop::SystemCe< T, n, c, np, ntp, Tc >::updateUpperBound |
after every iteration Jub is updated to be the current max cost (true by default)
std::vector< Vectorcd > & gcop::SystemCe< T, n, c, np, ntp, Tc >::us |
controls (N) vector
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
std::vector< std::vector<Vectorcd> > gcop::SystemCe< T, n, c, np, ntp, Tc >::usas |
all control samples
std::vector< Vectorcd > gcop::SystemCe< T, n, c, np, ntp, Tc >::uss |
controls (N) vector
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
std::vector< T > & gcop::SystemCe< T, n, c, np, ntp, Tc >::xs |
states (N+1) vector
std::vector< std::vector<T> > gcop::SystemCe< T, n, c, np, ntp, Tc >::xsas |
all state samples
std::vector< T > gcop::SystemCe< T, n, c, np, ntp, Tc >::xss |
states (N+1) vector
Referenced by gcop::SystemCe< T, n, c, np, ntp, Tc >::SystemCe().
Vectortpd gcop::SystemCe< T, n, c, np, ntp, Tc >::zmin |
Current best z corresponding to J.