24 #include <boost/serialization/export.hpp> 25 #include <boost/serialization/vector.hpp> 26 #include <boost/archive/text_iarchive.hpp> 27 #include <boost/archive/text_oarchive.hpp> 28 #include <boost/archive/xml_iarchive.hpp> 29 #include <boost/archive/xml_oarchive.hpp> 39 #include <eigen3/Eigen/Core> 53 using namespace Eigen;
58 #define SPRING segment(0*dim_orig()+0,2*dim_orig()) 60 #define SPRING_Y segment(0*dim_orig()+0,dim_orig()) 62 #define SPRING_Z segment(1*dim_orig()+0,dim_orig()) 64 #define GOAL segment(2*dim_orig()+0,dim_orig()) 66 #define PHASE segment(3*dim_orig()+0, 1) 68 #define GATING segment(3*dim_orig()+1, 1) 71 #define SPRINGM(T) block(0,0*dim_orig()+0,T,2*dim_orig()) 73 #define SPRINGM_Y(T) block(0,0*dim_orig()+0,T,dim_orig()) 75 #define SPRINGM_Z(T) block(0,1*dim_orig()+0,T,dim_orig()) 77 #define GOALM(T) block(0,2*dim_orig()+0,T,dim_orig()) 79 #define PHASEM(T) block(0,3*dim_orig()+0,T, 1) 81 #define GATINGM(T) block(0,3*dim_orig()+1,T, 1) 83 boost::mt19937 Dmp::rng = boost::mt19937(getpid() + time(0));
85 Dmp::Dmp(
double tau, Eigen::VectorXd y_init, Eigen::VectorXd y_attr,
86 std::vector<FunctionApproximator*> function_approximators,
87 double alpha_spring_damper,
93 goal_system_(goal_system),
94 phase_system_(phase_system), gating_system_(gating_system),
95 forcing_term_scaling_(scaling)
97 initSubSystems(alpha_spring_damper, goal_system, phase_system, gating_system);
98 initFunctionApproximators(function_approximators);
102 Dmp::Dmp(
int n_dims_dmp, std::vector<FunctionApproximator*> function_approximators,
106 :
DynamicalSystem(1, 1.0, VectorXd::Zero(n_dims_dmp), VectorXd::Ones(n_dims_dmp),
"name"),
107 goal_system_(goal_system),
108 phase_system_(phase_system), gating_system_(gating_system),
109 forcing_term_scaling_(scaling)
111 initSubSystems(alpha_spring_damper, goal_system, phase_system, gating_system);
112 initFunctionApproximators(function_approximators);
115 Dmp::Dmp(
double tau, Eigen::VectorXd y_init, Eigen::VectorXd y_attr,
116 std::vector<FunctionApproximator*> function_approximators,
120 forcing_term_scaling_(scaling)
122 initSubSystems(dmp_type);
123 initFunctionApproximators(function_approximators);
126 Dmp::Dmp(
int n_dims_dmp,
127 std::vector<FunctionApproximator*> function_approximators,
129 :
DynamicalSystem(1, 1.0, VectorXd::Zero(n_dims_dmp), VectorXd::Ones(n_dims_dmp),
"name"),
130 forcing_term_scaling_(scaling)
132 initSubSystems(dmp_type);
133 initFunctionApproximators(function_approximators);
136 Dmp::Dmp(
double tau, Eigen::VectorXd y_init, Eigen::VectorXd y_attr,
double alpha_spring_damper,
DynamicalSystem* goal_system)
137 :
DynamicalSystem(1, tau, y_init, y_attr,
"name"), forcing_term_scaling_(NO_SCALING)
140 VectorXd one_1 = VectorXd::Ones(1);
141 VectorXd one_0 = VectorXd::Zero(1);
144 initSubSystems(alpha_spring_damper, goal_system, phase_system, gating_system);
146 vector<FunctionApproximator*> function_approximators(y_init.size());
147 for (
int dd=0; dd<y_init.size(); dd++)
148 function_approximators[dd] = NULL;
149 initFunctionApproximators(function_approximators);
152 void Dmp::initSubSystems(
DmpType dmp_type)
154 VectorXd one_1 = VectorXd::Ones(1);
155 VectorXd one_0 = VectorXd::Zero(1);
160 if (dmp_type==IJSPEERT_2002_MOVEMENT)
166 else if (dmp_type==KULVICIUS_2012_JOINING || dmp_type==COUNTDOWN_2013)
170 bool count_down = (dmp_type==COUNTDOWN_2013);
174 double alpha_spring_damper = 20;
176 initSubSystems(alpha_spring_damper, goal_system, phase_system, gating_system);
179 void Dmp::initSubSystems(
double alpha_spring_damper,
DynamicalSystem* goal_system,
189 goal_system_ = goal_system;
190 if (goal_system!=NULL)
198 phase_system_ = phase_system;
201 gating_system_ = gating_system;
205 attractor_state_prealloc_ = VectorXd(
dim_orig());
206 initial_state_prealloc_ = VectorXd(
dim_orig());
207 fa_outputs_one_prealloc_ = MatrixXd(1,
dim_orig());
208 fa_outputs_prealloc_ = MatrixXd(1,
dim_orig());
209 fa_output_prealloc_ = MatrixXd(1,
dim_orig());
210 forcing_term_prealloc_ = VectorXd(
dim_orig());
211 g_minus_y0_prealloc_ = VectorXd(
dim_orig());
224 void Dmp::initFunctionApproximators(vector<FunctionApproximator*> function_approximators)
226 if (function_approximators.empty())
229 assert(
dim_orig()==(
int)function_approximators.size());
231 function_approximators_ = vector<FunctionApproximator*>(function_approximators.size());
232 for (
unsigned int dd=0; dd<function_approximators.size(); dd++)
234 if (function_approximators[dd]==NULL)
235 function_approximators_[dd] = NULL;
237 function_approximators_[dd] = function_approximators[dd]->clone();
245 delete spring_system_;
246 delete phase_system_;
247 delete gating_system_;
248 for (
unsigned int ff=0; ff<function_approximators_.size(); ff++)
249 delete (function_approximators_[ff]);
253 vector<FunctionApproximator*> function_approximators;
254 for (
unsigned int ff=0; ff<function_approximators_.size(); ff++)
255 function_approximators.push_back(function_approximators_[ff]->clone());
259 phase_system_->
clone(), gating_system_->
clone());
265 assert(x.size()==
dim());
266 assert(xd.size()==
dim());
272 if (goal_system_==NULL)
315 int T = phase_state.rows();
320 fa_outputs_prealloc_.resize(T,
dim_orig());
323 for (
int i_dim=0; i_dim<
dim_orig(); i_dim++)
325 if (function_approximators_[i_dim]!=NULL)
327 if (function_approximators_[i_dim]->isTrained())
331 function_approximators_[i_dim]->predict(phase_state,fa_outputs_one_prealloc_);
332 fa_output.col(i_dim) = fa_outputs_one_prealloc_;
336 function_approximators_[i_dim]->predict(phase_state,fa_outputs_prealloc_);
337 fa_output.col(i_dim) = fa_outputs_prealloc_;
345 const Eigen::Ref<const Eigen::VectorXd>& x,
346 Eigen::Ref<Eigen::VectorXd> xd)
const 349 ENTERING_REAL_TIME_CRITICAL_CODE
352 if (goal_system_==NULL)
387 double gating = (x.GATING)[0];
388 forcing_term_prealloc_ = gating*fa_output_prealloc_.row(t0);
392 if (forcing_term_scaling_==G_MINUS_Y0_SCALING)
395 g_minus_y0_prealloc_ = (attractor_state_prealloc_-initial_state_prealloc_).transpose();
396 forcing_term_prealloc_ = forcing_term_prealloc_.array()*g_minus_y0_prealloc_.array();
398 else if (forcing_term_scaling_==AMPLITUDE_SCALING)
400 forcing_term_prealloc_ = forcing_term_prealloc_.array()*trajectory_amplitudes_.array();
404 xd.SPRING_Z = xd.SPRING_Z + forcing_term_prealloc_/
tau();
406 EXITING_REAL_TIME_CRITICAL_CODE
410 void Dmp::statesAsTrajectory(
const Eigen::MatrixXd& x_in,
const Eigen::MatrixXd& xd_in, Eigen::MatrixXd& y_out, Eigen::MatrixXd& yd_out, Eigen::MatrixXd& ydd_out)
const 412 int n_time_steps = x_in.rows();
413 y_out = x_in.SPRINGM_Y(n_time_steps);
414 yd_out = xd_in.SPRINGM_Y(n_time_steps);
415 ydd_out = xd_in.SPRINGM_Z(n_time_steps)/
tau();
426 int n_time_steps = ts.rows();
427 #ifndef NDEBUG // Variables below are only required for asserts; check for NDEBUG to avoid warnings. 428 int n_dims = x_in.cols();
430 assert(n_time_steps==x_in.rows());
431 assert(n_time_steps==xd_in.rows());
432 assert(n_dims==xd_in.cols());
438 x_in.SPRINGM_Y(n_time_steps),
440 xd_in.SPRINGM_Y(n_time_steps),
442 xd_in.SPRINGM_Z(n_time_steps)/
tau()
445 trajectory = new_trajectory;
449 void Dmp::analyticalSolution(
const Eigen::VectorXd& ts, Eigen::MatrixXd& xs, Eigen::MatrixXd& xds, Eigen::MatrixXd& forcing_terms, Eigen::MatrixXd& fa_outputs)
const 451 int n_time_steps = ts.size();
452 assert(n_time_steps>0);
457 bool caller_expects_transposed = (xs.rows()==
dim() && xs.cols()==n_time_steps);
472 fa_outputs.resize(ts.size(),
dim_orig());
473 fa_outputs.fill(0.0);
478 MatrixXd xs_gating_rep = xs_gating.replicate(1,fa_outputs.cols());
479 forcing_terms = fa_outputs.array()*xs_gating_rep.array();
482 if (forcing_term_scaling_==G_MINUS_Y0_SCALING)
485 forcing_terms = forcing_terms.array()*g_minus_y0_rep.array();
487 else if (forcing_term_scaling_==AMPLITUDE_SCALING)
489 MatrixXd trajectory_amplitudes_rep = trajectory_amplitudes_.transpose().replicate(n_time_steps,1);
490 forcing_terms = forcing_terms.array()*trajectory_amplitudes_rep.array();
494 MatrixXd xs_goal, xds_goal;
496 if (goal_system_==NULL)
502 xds_goal = MatrixXd::Zero(n_time_steps,
dim_orig());
510 xs.resize(n_time_steps,
dim());
511 xds.resize(n_time_steps,
dim());
513 int T = n_time_steps;
515 xs.GOALM(T) = xs_goal; xds.GOALM(T) = xds_goal;
516 xs.PHASEM(T) = xs_phase; xds.PHASEM(T) = xds_phase;
517 xs.GATINGM(T) = xs_gating; xds.GATINGM(T) = xds_gating;
530 int dim_spring = localspring_system_.
dim();
531 VectorXd x_spring(dim_spring), xd_spring(dim_spring);
534 xs.row(t0).SPRING = x_spring;
535 xds.row(t0).SPRING = xd_spring;
538 xds.SPRINGM_Z(1) = xds.SPRINGM_Z(1) + forcing_terms.row(t0)/
tau();
541 if (analytical_solution_perturber_==NULL && perturbation_standard_deviation_>0.0)
543 boost::normal_distribution<> normal(0, perturbation_standard_deviation_);
544 analytical_solution_perturber_ =
new boost::variate_generator<boost::mt19937&, boost::normal_distribution<> >(rng, normal);
548 for (
int tt=1; tt<n_time_steps; tt++)
550 double dt = ts[tt]-ts[tt-1];
553 xs.row(tt).SPRING = xs.row(tt-1).SPRING + dt*xds.row(tt-1).SPRING;
560 xds.row(tt).SPRING = xd_spring;
563 RowVectorXd perturbation = RowVectorXd::Constant(
dim_orig(),0.0);
564 if (analytical_solution_perturber_!=NULL)
565 for (
int i_dim=0; i_dim<
dim_orig(); i_dim++)
567 perturbation(i_dim) = (*analytical_solution_perturber_)();
570 xds.row(tt).SPRING_Z = xds.row(tt).SPRING_Z + forcing_terms.row(tt)/
tau() + perturbation;
572 xds.row(tt).SPRING_Y = xs.row(tt).SPRING_Z/
tau();
576 if (caller_expects_transposed)
578 xs.transposeInPlace();
579 xds.transposeInPlace();
585 int n_time_steps = trajectory.
length();
586 double dim_data = trajectory.
dim();
590 cout <<
"WARNING: Cannot train " <<
dim_orig() <<
"-D DMP with " << dim_data <<
"-D data. Doing nothing." << endl;
607 MatrixXd xs_goal = xs_ana.GOALM(n_time_steps);
608 MatrixXd xs_gating = xs_ana.GATINGM(n_time_steps);
609 MatrixXd xs_phase = xs_ana.PHASEM(n_time_steps);
611 fa_inputs_phase = xs_phase;
616 double mass = spring_system_->
mass();
619 cout <<
"WARNING: Usually, spring-damper system of the DMP should have mass==1, but it is " << mass << endl;
623 f_target =
tau()*
tau()*trajectory.
ydds() + (spring_constant*(trajectory.
ys()-xs_goal) + damping_coefficient*
tau()*trajectory.
yds())/mass;
626 for (
unsigned int dd=0; dd<function_approximators_.size(); dd++)
627 f_target.col(dd) = f_target.col(dd).array()/xs_gating.array();
630 if (forcing_term_scaling_==G_MINUS_Y0_SCALING)
633 f_target = f_target.array()/g_minus_y0_rep.array();
635 else if (forcing_term_scaling_==AMPLITUDE_SCALING)
637 MatrixXd trajectory_amplitudes_rep = trajectory_amplitudes_.transpose().replicate(n_time_steps,1);
638 f_target = f_target.array()/trajectory_amplitudes_rep.array();
645 train(trajectory,
"");
660 VectorXd fa_input_phase;
665 assert(!function_approximators_.empty());
667 for (
unsigned int dd=0; dd<function_approximators_.size(); dd++)
670 string save_directory_dim;
671 if (!save_directory.empty())
673 if (function_approximators_.size()==1)
674 save_directory_dim = save_directory;
676 save_directory_dim = save_directory +
"/dim" + to_string(dd);
680 VectorXd fa_target = f_target.col(dd);
681 if (function_approximators_[dd]==NULL)
683 cerr << __FILE__ <<
":" << __LINE__ <<
":";
684 cerr <<
"WARNING: function approximator cannot be trained because it is NULL." << endl;
688 if (function_approximators_[dd]->isTrained())
689 function_approximators_[dd]->reTrain(fa_input_phase,fa_target,save_directory_dim,overwrite);
691 function_approximators_[dd]->train(fa_input_phase,fa_target,save_directory_dim,overwrite);
695 if (!save_directory.empty())
697 int n_time_steps = 101;
698 VectorXd ts = VectorXd::LinSpaced(n_time_steps,0,
tau());
702 trajectory.
saveToFile(save_directory,
"traj_demonstration.txt",overwrite);
703 traj_reproduced.
saveToFile(save_directory,
"traj_reproduced.txt",overwrite);
709 assert(function_approximators_.size()>0);
712 if (function_approximators_[dd]!=NULL)
714 if (function_approximators_[dd]->isTrained())
716 set<string> cur_labels;
717 function_approximators_[dd]->getSelectableParameters(cur_labels);
718 selectable_values_labels.insert(cur_labels.begin(), cur_labels.end());
722 selectable_values_labels.insert(
"goal");
733 assert(function_approximators_.size()>0);
735 if (function_approximators_[dd]!=NULL)
736 if (function_approximators_[dd]->isTrained())
742 VectorXi lengths_per_dimension = VectorXi::Zero(
dim_orig());
745 if (function_approximators_[dd]!=NULL)
746 if (function_approximators_[dd]->isTrained())
749 if (selected_values_labels.find(
"goal")!=selected_values_labels.end())
750 lengths_per_dimension[dd]++;
759 assert(function_approximators_.size()>0);
762 assert(function_approximators_[dd]!=NULL);
763 assert(function_approximators_[dd]->isTrained());
767 selected_mask.fill(0);
769 const int TMP_GOAL_NUMBER = -1;
774 function_approximators_[dd]->getParameterVectorMask(selected_values_labels,cur_mask);
777 int mask_offset = selected_mask.maxCoeff();
778 for (
int ii=0; ii<cur_mask.size(); ii++)
780 cur_mask[ii] += mask_offset;
782 selected_mask.segment(offset,cur_mask.size()) = cur_mask;
783 offset += cur_mask.size();
786 if (selected_values_labels.find(
"goal")!=selected_values_labels.end())
787 selected_mask(offset) = TMP_GOAL_NUMBER;
794 int goal_number = selected_mask.maxCoeff() + 1;
795 for (
int ii=0; ii<selected_mask.size(); ii++)
796 if (selected_mask[ii]==TMP_GOAL_NUMBER)
797 selected_mask[ii] = goal_number;
804 for (
unsigned int dd=0; dd<function_approximators_.size(); dd++)
821 function_approximators_[dd]->getParameterVectorAll(cur_values);
822 values.segment(offset,cur_values.size()) = cur_values;
823 offset += cur_values.size();
825 values(offset) = attractor(dd);
838 int n_parameters_required = function_approximators_[dd]->getParameterVectorAllSize();
839 cur_values = values.segment(offset,n_parameters_required);
840 function_approximators_[dd]->setParameterVectorAll(cur_values);
841 offset += n_parameters_required;
843 attractor(dd) = values(offset);
858 if (goal_system_!=NULL)
869 if (goal_system_!=NULL)
877 if (goal_system_!=NULL)
888 perturbation_standard_deviation_ = perturbation_standard_deviation;
889 analytical_solution_perturber_ = NULL;
899 template<
class Archive>
900 void Dmp::serialize(Archive & ar,
const unsigned int version)
906 ar & BOOST_SERIALIZATION_NVP(goal_system_);
907 ar & BOOST_SERIALIZATION_NVP(spring_system_);
908 ar & BOOST_SERIALIZATION_NVP(phase_system_);
909 ar & BOOST_SERIALIZATION_NVP(gating_system_);
910 ar & BOOST_SERIALIZATION_NVP(function_approximators_);
912 ar & BOOST_SERIALIZATION_NVP(forcing_term_scaling_);
913 ar & BOOST_SERIALIZATION_NVP(trajectory_amplitudes_);
915 ar & BOOST_SERIALIZATION_NVP(perturbation_standard_deviation_);
double tau(void) const
Accessor function for the time constant.
void getParameterVectorMask(const std::set< std::string > selected_values_labels, Eigen::VectorXi &selected_mask) const
Get a mask for selecting parameters.
void set_damping_coefficient(double damping_coefficient)
Accessor function for damping coefficient.
const Eigen::VectorXd & ts(void) const
Accessor function for the times at which measurements were made.
void setVectorLengthsPerDimension(const Eigen::VectorXi &lengths_per_dimension)
The vector (VectorXd) with parameter values can be split into different parts (as vector<VectorXd>; t...
void set_dim(int dim)
Set the dimensionality of the dynamical system, i.e.
virtual void set_attractor_state(const Eigen::VectorXd &y_attr)
Accessor function for the attractor state of the system.
void getParameterVectorAll(Eigen::VectorXd &values) const
Return a vector that returns all available parameter values.
virtual void analyticalSolution(const Eigen::VectorXd &ts, Eigen::MatrixXd &xs, Eigen::MatrixXd &xds) const =0
Return analytical solution of the system at certain times.
virtual void set_attractor_state(const Eigen::Ref< const Eigen::VectorXd > &attractor_state)
Mutator function for the attractor state of the dynamical system.
Trajectory class header file.
Implementation of Dynamical Movement Primitives.
int dim_orig(void) const
Get the dimensionality of the dynamical system, i.e.
FunctionApproximator class header file.
virtual void set_tau(double tau)
Accessor function for the time constant.
void set_spring_constant(double spring_constant)
Accessor function for spring constant.
SpringDamperSystem class header file.
void computeFunctionApproximatorInputsAndTargets(const Trajectory &trajectory, Eigen::VectorXd &fa_inputs_phase, Eigen::MatrixXd &fa_targets) const
Given a trajectory, compute the inputs and targets for the function approximators.
ExponentialSystem class header file.
const Eigen::MatrixXd & ys(void) const
Accessor function for the positions at different times.
double duration(void) const
Get the duration of the trajectory in seconds.
A class for storing trajectories: positions, velocities and accelerations of variables over time...
const Eigen::MatrixXd & ydds(void) const
Accessor function for the accelerations at different times.
Eigen::VectorXd initial_state(void) const
Accessor function for the initial state of the dynamical system.
Dynamical System modelling the evolution of a sigmoidal system .
virtual void statesAsTrajectory(const Eigen::MatrixXd &x_in, const Eigen::MatrixXd &xd_in, Eigen::MatrixXd &y_out, Eigen::MatrixXd &yd_out, Eigen::MatrixXd &ydd_out) const
Get the output of a DMP dynamical system as a trajectory.
Class for providing access to a model's parameters as a vector.
Eigen::VectorXd final_y(void) const
Get the last state, i.e.
Dynamical System modelling the evolution of a time: .
virtual void set_initial_state(const Eigen::VectorXd &initial_state)
Mutator function for the initial state of the dynamical system.
int getParameterVectorAllSize(void) const
Get the size of the parameter values vector when it contains all available parameter values...
int dim(void) const
Get the dimensionality of the dynamical system, i.e.
double damping_coefficient(void)
Accessor function for damping coefficient.
TimeSystem class header file.
#define RETURN_STRING_FROM_BOOST_SERIALIZATION_XML(name)
Macro to convert the boost XML serialization of an object into a string.
int length(void) const
Get the length of the trajectory, i.e.
Dynamical System modelling the evolution of an exponential system: .
void differentialEquation(const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::VectorXd > xd) const
The differential equation which defines the system.
virtual DynamicalSystem * clone(void) const =0
Return a pointer to a deep copy of the DynamicalSystem object.
void setSelectedParameters(const std::set< std::string > &selected_values_labels)
Determine which subset of parameters is represented in the vector returned by Parameterizable::getPar...
Eigen::VectorXd getRangePerDim(void) const
Get the range of ys per dimension.
DmpType
Different types of DMPs that can be initialized.
int dim(void) const
Get the dimensionality of the trajectory.
virtual void differentialEquation(const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::VectorXd > xd) const =0
The differential equation which defines the system.
virtual void train(const Trajectory &trajectory)
Train a DMP with a trajectory.
const Eigen::MatrixXd & yds(void) const
Accessor function for the velocities at different times.
virtual void computeFunctionApproximatorOutput(const Eigen::Ref< const Eigen::MatrixXd > &phase_state, Eigen::MatrixXd &fa_output) const
Compute the outputs of the function approximators.
std::string name(void) const
Accessor function for the name of the dynamical system.
BOOST_CLASS_EXPORT_IMPLEMENT(DmpBbo::Dmp)
For boost::serialization.
Dmp * clone(void) const
Return a deep copy of this object.
void differentialEquation(const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::VectorXd > xd) const
The differential equation which defines the system.
void setParameterVectorAll(const Eigen::VectorXd &values)
Set all available parameter values with one vector.
Interface for implementing dynamical systems.
virtual void setSelectedParameters(const std::set< std::string > &selected_values_labels)
Determine which subset of parameters is represented in the vector returned by Parameterizable::getPar...
virtual void integrateStart(Eigen::Ref< Eigen::VectorXd > x, Eigen::Ref< Eigen::VectorXd > xd) const
Start integrating the system.
Eigen::VectorXd initial_y(void) const
Get the first state, i.e.
SigmoidSystem class header file.
virtual void set_name(std::string name)
Mutator function for the name of the dynamical system.
Eigen::VectorXd attractor_state(void) const
Accessor function for the attractor state of the dynamical system.
double mass(void)
Accessor function for mass.
virtual int getParameterVectorSelectedSize(void) const
Get the size of the vector of selected parameters, as returned by getParameterVectorSelected(.
void set_spring_constant(double spring_constant)
Accessor function for spring constant of spring-damper system.
ForcingTermScaling
Different ways to scale the forcing term.
virtual void integrateStart(Eigen::Ref< Eigen::VectorXd > x, Eigen::Ref< Eigen::VectorXd > xd) const
Start integrating the system.
void set_perturbation_analytical_solution(double perturbation_standard_deviation)
Add a perturbation to the forcing term when computing the analytical solution.
Header file to generate strings from boost serialized files.
virtual void set_tau(double tau)
Mutator function for the time constant.
virtual void set_initial_state(const Eigen::VectorXd &y_init)
Accessor function for the initial state of the system.
std::string toString(void) const
Returns a string representation of the object.
Dynamical System modelling the evolution of a spring-damper system: .
void analyticalSolution(const Eigen::VectorXd &ts, Eigen::MatrixXd &xs, Eigen::MatrixXd &xds, Eigen::MatrixXd &forcing_terms, Eigen::MatrixXd &fa_output) const
Return analytical solution of the system at certain times (and return forcing terms) ...
double spring_constant(void)
Accessor function for spring constant.
void getSelectableParameters(std::set< std::string > &selectable_values_labels) const
Return all the names of the parameter types that can be selected.
bool saveToFile(std::string directory, std::string filename, bool overwrite=false) const
Save a trajectory to a file.
Header file for serialization of Eigen matrices.
void set_damping_coefficient(double damping_coefficient)
Accessor function for damping coefficient of spring-damper system.