Go to the documentation of this file.
23 template<
int StateDim,
int InputDim>
55 Eigen::VectorXd alpha_exponent_list = Eigen::VectorXd::LinSpaced(list_size, 0, -3);
56 for(
int i = 0; i < list_size; i++)
58 alpha_list[i] = std::pow(10, alpha_exponent_list[i]);
135 Fx.resize(state_dim, state_dim);
136 Fu.resize(state_dim, input_dim);
140 Lx.resize(state_dim);
141 Lu.resize(input_dim);
142 Lxx.resize(state_dim, state_dim);
143 Luu.resize(input_dim, input_dim);
144 Lxu.resize(state_dim, input_dim);
154 std::vector<StateStateDimMatrix>
Fxx;
157 std::vector<InputInputDimMatrix>
Fuu;
160 std::vector<StateInputDimMatrix>
Fxu;
250 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
275 bool solve(
double current_t,
const StateDimVector & current_x,
const std::vector<InputDimVector> & initial_u_list);
282 inline void setInputLimitsFunc(
const std::function<std::array<InputDimVector, 2>(
double)> & input_limits_func)
332 std::shared_ptr<DDPProblem<StateDim, InputDim>>
problem_;
double duration_forward
Duration to process forward pass [msec].
Data to trace optimization loop.
double forward
Duration to process forward pass (included in opt) [msec].
Derivatives of DDP problem.
double cost_update_actual
Actual update value of cost.
InputDimVector Lu
First-order derivative of running cost w.r.t. input.
const Configuration & config() const
Const accessor to configuration.
void forwardPass(double alpha)
Process forward pass.
std::vector< StateDimVector > x_list
Sequence of state (x[0], ..., x[N-1], x[N])
typename DDPProblem< StateDim, InputDim >::StateDimVector StateDimVector
Type of vector of state dimension.
StateStateDimMatrix last_Vxx_
Second-order derivative of value in last step of horizon.
const ControlData & controlData() const
Const accessor to control data calculated by solve().
double reg
Duration to calculate regularization (included in backward) [msec].
double derivative
Duration to calculate derivatives (included in opt) [msec].
InputInputDimMatrix Luu
Second-order derivative of running cost w.r.t. input.
double lambda_
Regularization coefficient.
std::vector< InputDimVector > u_list
Sequence of input (u[0], ..., u[N-1])
const std::vector< TraceData > & traceDataList() const
Const accessor to trace data list.
std::vector< InputDimVector > k_list_
Sequence of feedforward term for input (k[0], ..., k[N-1])
double duration_backward
Duration to process backward pass [msec].
double lambda_thre
Termination threshold of regularization coefficient.
Configuration()
Constructor.
typename DDPProblem< StateDim, InputDim >::InputInputDimMatrix InputInputDimMatrix
Type of matrix of input x input dimension.
StateDimVector last_Vx_
First-order derivative of value in last step of horizon.
bool use_state_eq_second_derivative
Whether to use second-order derivatives of state equation.
double current_t_
Current time [sec].
typename DDPProblem< StateDim, InputDim >::InputDimVector InputDimVector
Type of vector of input dimension.
StateDimVector Lx
First-order derivative of running cost w.r.t. state.
std::shared_ptr< DDPProblem< StateDim, InputDim > > problem_
DDP problem.
typename DDPProblem< StateDim, InputDim >::StateStateDimMatrix StateStateDimMatrix
Type of matrix of state x state dimension.
std::vector< TraceData > trace_data_list_
Sequence of trace data.
std::vector< Derivative > derivative_list_
Sequence of derivatives.
double opt
Duration of optimization loop (included in solve) [msec].
double duration_derivative
Duration to calculate derivatives [msec].
std::vector< InputInputDimMatrix > Fuu
Second-order derivative of state equation w.r.t. input (tensor of rank 3)
bool backwardPass()
Process backward pass.
double lambda
Regularization coefficient.
std::vector< StateStateDimMatrix > Fxx
Second-order derivative of state equation w.r.t. state (tensor of rank 3)
double dlambda
Scaling factor of regularization coefficient.
StateInputDimMatrix Fu
First-order derivative of state equation w.r.t. input.
std::vector< StateInputDimMatrix > Fxu
Second-order derivative of state equation w.r.t. state and input (tensor of rank 3)
double lambda_max
Maximum regularization coefficient.
int print_level
Print level (0: no print, 1: print only important, 2: print verbose, 3: print very verbose)
int procOnce(int iter)
Process one iteration.
Derivative(int state_dim, int input_dim, int outer_dim)
Constructor.
double setup
Duration to setup (included in solve) [msec].
std::function< std::array< InputDimVector, 2 >double)> input_limits_func_
Function to return input limits (in the order of lower, upper)
StateStateDimMatrix Fx
First-order derivative of state equation w.r.t. state.
typename DDPProblem< StateDim, InputDim >::StateInputDimMatrix StateInputDimMatrix
Type of matrix of state x input dimension.
double gain
Duration to calculate gains (included in backward) [msec].
bool solve(double current_t, const StateDimVector ¤t_x, const std::vector< InputDimVector > &initial_u_list)
Solve optimization.
ComputationDuration computation_duration_
Computation duration data.
int reg_type
Regularization type (1: Quu + lambda * I, 2: Vxx + lambda * I)
Eigen::VectorXd alpha_list
List of alpha (scaling factor of k)
StateInputDimMatrix Lxu
Second-order derivative of running cost w.r.t. state and input.
Configuration & config()
Accessor to configuration.
Eigen::VectorXd cost_list
Sequence of cost (L[0], ..., L[N-1], phi[N])
double Q
Duration to calculate Q (included in backward) [msec].
double cost_update_ratio
Ratio of actual and expected update values of cost.
double alpha
Scaling factor of k.
Eigen::Matrix< double, StateDim, 1 > StateDimVector
Type of vector of state dimension.
double initial_lambda
Initial regularization coefficient.
double k_rel_norm
Norm of relative values of k and u.
Eigen::Vector2d dV_
Expected update of value.
double cost_update_expected
Expected update value of cost.
double k_rel_norm_thre
Termination threshold of relative norm of k.
Eigen::Matrix< double, StateDim, StateDim > StateStateDimMatrix
Type of matrix of state x state dimension.
Eigen::Matrix< double, StateDim, InputDim > StateInputDimMatrix
Type of matrix of state x input dimension.
Data of computation duration.
int horizon_steps
Number of steps in horizon.
double lambda_factor
Increasing/decreasing factor of regularization coefficient scaling.
typename DDPProblem< StateDim, InputDim >::InputStateDimMatrix InputStateDimMatrix
Type of matrix of input x state dimension.
void dumpTraceDataList(const std::string &file_path) const
Dump trace data list.
double initial_dlambda
Initial scaling factor of regularization coefficient.
int iter
Iteration of optimization loop.
double cost_update_thre
Termination threshold of cost update.
double dlambda_
Scaling factor of regularization coefficient.
StateStateDimMatrix Lxx
Second-order derivative of running cost w.r.t. state.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DDPSolver(const std::shared_ptr< DDPProblem< StateDim, InputDim >> &problem)
Constructor.
Eigen::Matrix< double, InputDim, StateDim > InputStateDimMatrix
Type of matrix of input x state dimension.
ControlData candidate_control_data_
Candidate control data (sequence of state, input, and cost)
double cost_update_ratio_thre
Allowable threshold of cost update ratio.
double solve
Duration to solve [msec].
bool with_input_constraint
Whether input has constraints.
void setInputLimitsFunc(const std::function< std::array< InputDimVector, 2 >(double)> &input_limits_func)
Set function to return input limits.
Configuration config_
Configuration.
double lambda_min
Minimum regularization coefficient.
std::vector< InputStateDimMatrix > K_list_
Sequence of feedback gain for input w.r.t. state error (K[0], ..., K[N-1])
Eigen::Matrix< double, InputDim, 1 > InputDimVector
Type of vector of input dimension.
Eigen::Matrix< double, InputDim, InputDim > InputInputDimMatrix
Type of matrix of input x input dimension.
int max_iter
Maximum iteration of optimization loop.
ControlData control_data_
Control data (sequence of state, input, and cost)
const ComputationDuration & computationDuration() const
Const accessor to computation duration.
double backward
Duration to process backward pass (included in opt) [msec].