full_discretization_grid_base.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
26 
28 
30 #include <corbo-core/console.h>
31 
32 #include <algorithm>
33 #include <cmath>
34 #include <memory>
35 
36 namespace corbo {
37 
38 GridUpdateResult FullDiscretizationGridBase::update(const Eigen::VectorXd& x0, ReferenceTrajectoryInterface& xref, ReferenceTrajectoryInterface& uref,
39  NlpFunctions& nlp_fun, OptimizationEdgeSet& edges, SystemDynamicsInterface::Ptr dynamics,
40  bool new_run, const Time& t, ReferenceTrajectoryInterface* sref, const Eigen::VectorXd* prev_u,
41  double prev_u_dt, ReferenceTrajectoryInterface* xinit, ReferenceTrajectoryInterface* uinit)
42 {
43  assert(x0.size() == dynamics->getStateDimension());
44  assert(xref.getDimension() == x0.size());
45  assert(uref.getDimension() == dynamics->getInputDimension());
46 
47  GridUpdateResult result;
48  _nlp_fun = &nlp_fun; // for bound access in e.g. resampleTrajectory()
49 
50  if (isGridAdaptActive() && !_first_run && !isEmpty()) // TODO(roesmann): this might not be efficient in case warm start is deactivated
51  {
52  // adapt grid if implemented by subclass
53  adaptGrid(new_run, nlp_fun); // note, isModified() should return true if something was changed!, we could also use the return value...
54  }
55 
56  // check if we need to cache the reference trajectory values // TODO(roesmann): we could restrict this to new_run==true only as long as we do not
57  // have a grid resize...
58  int n = std::max(std::max(getNRef(), getN()), _n_adapt);
59  if (_dt.value() <= 0) _dt.value() = _dt_ref; // initialize _dt to _dt_ref in case it has not been optimized before
60  if (!xref.isCached(getDt(), n, t)) xref.precompute(getDt(), n, t);
61  if (!uref.isCached(getDt(), n, t)) uref.precompute(getDt(), n, t);
62  if (sref && !sref->isCached(getDt(), n, t)) sref->precompute(getDt(), n, t);
63  if (xinit && !xinit->isCached(getDt(), n, t)) xinit->precompute(getDt(), n, t);
64  if (uinit && !uinit->isCached(getDt(), n, t)) uinit->precompute(getDt(), n, t);
65 
66  // set previous control which might be utilized by some edges
67  if (prev_u && prev_u->size() > 0)
68  setPreviousControl(*prev_u, prev_u_dt);
69  else
70  setPreviousControl(Eigen::VectorXd::Zero(dynamics->getInputDimension()), prev_u_dt);
71 
72  // set last control to uref
73  setLastControlRef(uref.getReferenceCached(n - 1));
74 
75  // TODO(roesmann): we do not check if bounds in nlp_fun are updated
76  // updateBounds(); // calling this everytime is not efficient
77 
78  // initialize trajectories if empty or if the goal differs from the last one
79  // reinit if goal is far away
80  if (isEmpty()) // TODO(roesmann): threshold?: if (_cached_xf.rows() > 0 && (xf - _cached_xf).norm() > _warm_start_goal_dist_reinit)
81  {
82  if (xref.isStatic() && !xinit)
83  {
84  initializeSequences(x0, xref.getReferenceCached(n - 1), uinit ? *uinit : uref, nlp_fun);
85  }
86  else
87  {
88  initializeSequences(x0, xref.getReferenceCached(n - 1), xinit ? *xinit : xref, uinit ? *uinit : uref, nlp_fun);
89  }
90  }
91  else
92  {
93  if (new_run && isMovingHorizonWarmStartActive())
94  {
95  // warm_start
97  }
98  if (new_run)
99  {
100  // make sure to always overwrite the start with the actual (measured) values
101  _x_seq.front().values() = x0;
102  // update fixed goal states
103  for (int i = 0; i < _xf_fixed.size(); ++i)
104  {
105  if (_xf_fixed[i]) _xf.values()[i] = xref.getReferenceCached(getN() - 1)[i];
106  }
107  }
108  }
109 
110  result.vertices_updated = isModified(); // isModified() returns if the underlying vertex set is updated
111 
112  if (new_run || result.updated()) // new run -> new t
113  {
114  // update NLP functions w.r.t. the current discretization
115  result.edges_updated = nlp_fun.update(getN(), t.toSec(), xref, uref, sref, hasSingleDt(), x0, {getDt()},
116  this); // returns true if dimensions changed
117  // TODO(roesmann): sref is not yet implemented for testing, add this later...
118  // TODO(roesmann): we do not yet check if dt was updated, this might affect nlp update
119  // TODO(roesmann): maybe, for non-uniform grids, we need a better nlp update method which gets all correct reference time stamps
120  }
121 
122  if (result.updated()) // vertices or eges updated
123  {
124  // create grid specific edges
125  // TODO(roesmann): for now, we assume that we are the only maintainer of the edge set (which might be not true generally!)
126  // so we clear the edge set whenever we want
127  createEdges(nlp_fun, edges, dynamics);
128  result.edges_updated = true; // now we definitely updated the edgeset
129  }
130  _first_run = false;
131  return result;
132 }
133 
134 void FullDiscretizationGridBase::initializeSequences(const Eigen::VectorXd& x0, const Eigen::VectorXd& xf, ReferenceTrajectoryInterface& uref,
135  NlpFunctions& nlp_fun)
136 {
137  // clear(); // make sure everything is cleared
138  _x_seq.clear();
139  _u_seq.clear();
140  _xf.clear();
141  _active_vertices.clear();
142 
143  // check or initalize bounds if empty
144  nlp_fun.checkAndInitializeBoundDimensions(x0.size(), uref.getDimension());
145 
146  // check x_fixed
148 
149  int n_init = _n_adapt > 0 ? _n_adapt : _n_ref;
150 
151  int num_intervals = n_init - 1;
152 
153  // we initialize the state trajectory linearly
154  Eigen::VectorXd dir = xf - x0;
155  double dist = dir.norm();
156  if (dist != 0) dir /= dist;
157  double step = dist / num_intervals;
158 
159  for (int k = 0; k < num_intervals; ++k)
160  {
161  // add new state by linear interpolation
162  _x_seq.emplace_back(x0 + (double)k * step * dir, nlp_fun.x_lb, nlp_fun.x_ub);
163  // add new constant control (assume u0 to hold
164  _u_seq.emplace_back(uref.getReferenceCached(k), nlp_fun.u_lb, nlp_fun.u_ub);
165  }
166  // add final state
167  _xf.set(xf, nlp_fun.x_lb, nlp_fun.x_ub, _xf_fixed);
168 
169  // set first state as fixed
170  _x_seq.front().setFixed(true);
171 
172  // set dt
174 
175  assert(_x_seq.size() > 0);
176 
177  // notify graph that vertices are changed
178  setModified(true);
179 }
180 
181 void FullDiscretizationGridBase::initializeSequences(const Eigen::VectorXd& x0, const Eigen::VectorXd& xf, ReferenceTrajectoryInterface& xref,
182  ReferenceTrajectoryInterface& uref, NlpFunctions& nlp_fun)
183 {
184  // clear(); // make sure everything is cleared
185  _x_seq.clear();
186  _u_seq.clear();
187  _xf.clear();
188  _active_vertices.clear();
189 
190  // TODO(roesmann): check if this is ever needed in any pracital realization:
191  // if ((x0 - xref.getReferenceCached(0)).norm() > _non_static_ref_dist_threshold)
192  // {
193  // initializeSequences(x0, xref.getReferenceCached(getN() - 1), uref, nlp_fun);
194  // }
195 
196  // check or initalize bounds if empty
197  nlp_fun.checkAndInitializeBoundDimensions(x0.size(), uref.getDimension());
198 
199  // check x_fixed
201 
202  int n_init = _n_adapt > 0 ? _n_adapt : _n_ref;
203 
204  int num_intervals = n_init - 1;
205 
206  _x_seq.emplace_back(x0, nlp_fun.x_lb, nlp_fun.x_ub); // always add the (exact) x0
207  _u_seq.emplace_back(uref.getReferenceCached(0), nlp_fun.u_lb, nlp_fun.u_ub);
208  for (int k = 1; k < num_intervals; ++k)
209  {
210  // add new state by linear interpolation
211  _x_seq.emplace_back(xref.getReferenceCached(k), nlp_fun.x_lb, nlp_fun.x_ub);
212  // add new constant control (assume u0 to hold
213  _u_seq.emplace_back(uref.getReferenceCached(k), nlp_fun.u_lb, nlp_fun.u_ub);
214  }
215  // add final state
216  _xf.set(xf, nlp_fun.x_lb, nlp_fun.x_ub, _xf_fixed);
217 
218  // set first state as fixed
219  _x_seq.front().setFixed(true);
220 
221  // set dt
223 
224  assert(_x_seq.size() > 1);
225 
226  // notify graph that vertices are changed
227  setModified(true);
228 }
229 
230 void FullDiscretizationGridBase::warmStartShifting(const Eigen::VectorXd& x0)
231 {
232  // find nearest state to x0 (ideally it is the second one in _x_seq).
233  int num_shift = findNearestState(x0);
234  if (num_shift <= 0) return;
235 
236  if (num_shift > getN() - 2)
237  {
238  PRINT_ERROR_NAMED("Cannot shift if num_shift > N-2");
239  return;
240  }
241 
242  // the simplest strategy would be to just remove remove x_seq[0], append xf to x_seq and replace xf (num_shift=1)
243  // however, this requries to change the structure which always triggers an edge recreation and so the solver must reallocate memory.
244  // TOOD(roesmann): for time-optimal stuff, if we are sure that we resize the grid, it is then more efficent to implement the strategy above...
245 
246  // shift from end to front:
247  for (int i = 0; i < getN() - num_shift; ++i)
248  {
249  int idx = i + num_shift;
250  if (idx == getN() - 1)
251  {
252  // final state reached
253  _x_seq[i].values() = _xf.values();
254  }
255  else
256  {
257  _x_seq[i].values() = _x_seq[idx].values();
258  _u_seq[i].values() = _u_seq[idx].values();
259  }
260  }
261 
262  int idx = getN() - num_shift;
263  if (idx < 0)
264  {
265  PRINT_ERROR_NAMED("idx < 0...");
266  return;
267  }
268  for (int i = 0; i < num_shift; ++i, ++idx)
269  {
270  // now extrapolate
271  assert(idx > 1);
272 
273  // linearly extrapolate states
274  if (i == num_shift - 1) // consider xf
275  {
276  _xf.values() = _x_seq[idx - 2].values() + 2.0 * (_x_seq[idx - 1].values() - _x_seq[idx - 2].values());
277  }
278  else
279  {
280  _x_seq[idx].values() = _x_seq[idx - 2].values() + 2.0 * (_x_seq[idx - 1].values() - _x_seq[idx - 2].values());
281  // TODO(roesmann) multiply by fraction of last dt and _dt
282  }
283  _u_seq[idx - 1].values() = _u_seq[idx - 2].values();
284  }
285 }
286 
287 int FullDiscretizationGridBase::findNearestState(const Eigen::VectorXd& x0)
288 {
289  assert(!isEmpty());
290  assert(isValid());
291 
292  // same start as before
293  double first_dist = (x0 - _x_seq.front().values()).norm();
294  if (std::abs(first_dist) < 1e-12) return 0;
295 
296  // find nearest state (using l2-norm) in order to prune the trajectory
297  // (remove already passed states, should be 1 if the sampling times of the planning and controller call match, but could be higher if rates
298  // differ)
299 
300  int num_interv = getN() - 1;
301 
302  double dist_cache = first_dist;
303  double dist;
304  int num_keep_interv = 1; // std::max(1, _num_states_min - 1); // we need to keep at least this number of intervals in the trajectory
305  int lookahead = std::min(num_interv - num_keep_interv, 20); // max 20 samples
306 
307  int nearest_idx = 0;
308 
309  for (int i = 1; i <= lookahead; ++i)
310  {
311  dist = (x0 - _x_seq[i].values()).norm();
312  if (dist < dist_cache)
313  {
314  dist_cache = dist;
315  nearest_idx = i;
316  }
317  else
318  break;
319  }
320 
321  return nearest_idx;
322 }
323 
324 bool FullDiscretizationGridBase::getFirstControlInput(Eigen::VectorXd& u0)
325 {
326  if (isEmpty() || !isValid()) return false;
327  assert(!_u_seq.empty());
328 
329  u0 = _u_seq.front().values();
330  return true;
331 }
332 
334 {
335  // clear grid if we change n
336  if (n != getN()) clear();
337  if (n < 2)
338  {
339  PRINT_ERROR_NAMED("Number of states must be n>1.");
340  _n_ref = 2;
341  return;
342  }
343  _n_ref = n;
344  _n_adapt = 0;
345 }
346 
348 {
349  if (_xf_fixed.size() == 0)
350  {
351  _xf_fixed.setConstant(dim_x, false);
352  return true;
353  }
354  else if (_xf_fixed.size() == dim_x)
355  return true;
356 
357  PRINT_ERROR_NAMED("Dimensions mismatch between xf_fixed and xf. Setting xf_fixed to false.");
358  _xf_fixed.setConstant(dim_x, false);
359  return false;
360 }
361 
363 {
364  if (isEmpty()) return;
365  for (VectorVertex& vtx : _x_seq)
366  {
367  if (vtx.getDimension() == nlp_fun.x_lb.size())
368  vtx.setLowerBounds(nlp_fun.x_lb);
369  else
370  PRINT_ERROR_NAMED("Cannot update lower state bounds due to dimensions mismatch");
371 
372  if (vtx.getDimension() == nlp_fun.x_ub.size())
373  vtx.setUpperBounds(nlp_fun.u_ub);
374  else
375  PRINT_ERROR_NAMED("Cannot update upper state bounds due to dimensions mismatch");
376  }
377 
378  for (VectorVertex& vtx : _u_seq)
379  {
380  if (vtx.getDimension() == nlp_fun.u_lb.size())
381  vtx.setLowerBounds(nlp_fun.u_lb);
382  else
383  PRINT_ERROR_NAMED("Cannot update lower control input bounds due to dimensions mismatch");
384 
385  if (vtx.getDimension() == nlp_fun.u_ub.size())
386  vtx.setUpperBounds(nlp_fun.u_ub);
387  else
388  PRINT_ERROR_NAMED("Cannot update upper control input bounds due to dimensions mismatch");
389  }
390 
393 
394  _nlp_fun = &nlp_fun; // for bound access in e.g. resampleTrajectory()
395 }
396 
398 {
399  assert(isValid());
400  int n = getN();
401  if (n == n_new) return;
402 
403  if (!_nlp_fun)
404  {
405  PRINT_ERROR_NAMED("We currently need _nlp_fun to be valid in order to retrieve bounds");
406  }
407 
408  // copy vertices (vertices itself are shared pointers)
411  TimeSeries::Ptr ts_states_old = std::make_shared<TimeSeries>();
412  TimeSeries::Ptr ts_controls_old = std::make_shared<TimeSeries>();
413  getStateAndControlTimeSeries(ts_states_old, ts_controls_old);
414 
415  TimeSeries::ValuesMatMap x_seq_old = ts_states_old->getValuesMatrixView();
416  TimeSeries::ValuesMatMap u_seq_old = ts_controls_old->getValuesMatrixView();
417 
418  int num_interv = n - 1;
419 
420  double dt_old = getDt();
421  // compute new time diff
422  double dt_new = dt_old * double(n - 1) / double(n_new - 1);
423 
424  double t_new;
425  int idx_old = 1;
426  double t_old_p1 = dt_old; // time for old sample with index idx_old (acutally its the subsequent time step w.r.t t_new)
427 
428  for (int idx_new = 1; idx_new < n_new - 1; ++idx_new) // n_new-1 since last state is identical and copied later. idx_new=1, since start
429  // sample is already valid (we do not touch it)
430  // we allow a small mismatch for the control u_1 and let the optimizer correct it later
431  {
432  t_new = dt_new * double(idx_new);
433  while (t_new > double(idx_old) * dt_old && idx_old < n)
434  {
435  ++idx_old;
436  }; // find idx_old that represents the state subsequent to the new one (w.r.t. time)
437  t_old_p1 = double(idx_old) * dt_old;
438 
439  const Eigen::VectorXd& x_prev = x_seq_old.col(idx_old - 1);
440  const Eigen::VectorXd& x_cur = (idx_old < n - 1) ? x_seq_old.col(idx_old) : _xf.values();
441 
442  if (idx_new < num_interv)
443  {
444  // states
445  _x_seq[idx_new].values() = x_prev + (t_new - (t_old_p1 - dt_old)) / dt_old * (x_cur - x_prev);
446 
447  // controls
448  // TODO(roesmann): we do not have a valid control (u_f), so hold last
449  _u_seq[idx_new].values() = u_seq_old.col(idx_old - 1);
450  }
451  else
452  {
453  // add new pair
454  _x_seq.emplace_back(x_prev + (t_new - (t_old_p1 - dt_old)) / dt_old * (x_cur - x_prev), _nlp_fun->x_lb, _nlp_fun->x_ub);
455  _u_seq.emplace_back(u_seq_old.col(idx_old - 1), _nlp_fun->u_lb, _nlp_fun->u_ub);
456  }
457  }
458 
459  // clear invalid states
460  if (n_new < n)
461  {
462  _x_seq.resize(n_new - 1);
463  _u_seq.resize(n_new - 1);
464  }
465 
466  // save new dt
467  _dt.value() = dt_new;
468 
469  // set first vertex always to fixed
470  // _x_seq.front().setFixed(true); // should not be necessary here (we just change values in the first node)
471 
472  // notify graph that vertices are changed
473  setModified(true);
474 }
475 
477 {
478  _x_seq.clear();
479  _u_seq.clear();
480  _xf.clear();
481  _active_vertices.clear();
482  _nlp_fun = nullptr;
483  _n_adapt = 0;
484  _first_run = true;
485  setModified(true);
486 }
487 
488 void FullDiscretizationGridBase::setN(int n, bool try_resample)
489 {
490  if (try_resample && _nlp_fun && !isEmpty())
491  {
493  }
494  else
495  {
496  clear(); // resampling not yet implemented
497  }
499 }
500 
501 void FullDiscretizationGridBase::getVertices(std::vector<VertexInterface*>& vertices)
502 {
503  vertices.clear();
504  // order doesn't matter here
505  for (VectorVertex& vtx : _x_seq) vertices.push_back(&vtx);
506  for (VectorVertex& vtx : _u_seq) vertices.push_back(&vtx);
507  vertices.push_back(&_xf);
508  vertices.push_back(&_dt); // make sure to make it fixed if desired in any subclass
509  vertices.push_back(&_u_prev); // always fixed...
510  vertices.push_back(&_u_ref);
511  vertices.push_back(&_u_prev_dt);
512 }
513 
515 {
516  _active_vertices.clear();
517  assert(isValid());
518  int n = getN();
519 
520  for (int i = 0; i < n - 1; ++i)
521  {
522  if (!_x_seq[i].isFixed()) _active_vertices.push_back(&_x_seq[i]);
523  if (!_u_seq[i].isFixed()) _active_vertices.push_back(&_u_seq[i]);
524  }
525  if (!_xf.isFixed()) _active_vertices.push_back(&_xf);
526  if (!_dt.isFixed()) _active_vertices.push_back(&_dt);
527 }
528 
530 {
531  if (x_sequence) x_sequence->clear();
532  if (u_sequence) u_sequence->clear();
533 
534  if (isEmpty()) return;
535  assert(isValid());
536 
537  PRINT_ERROR_COND_NAMED(t_max < 0, "t_max >= 0 required");
538 
539  double dt = getDt();
540 
541  if (x_sequence)
542  {
543  double t = 0;
544  for (int i = 0; i < _x_seq.size(); ++i)
545  {
546  x_sequence->add(t, _x_seq[i].values());
547  t += dt;
548  if (t > t_max) break;
549  }
550  if (t <= t_max) x_sequence->add(t, _xf.values());
551  }
552 
553  if (u_sequence)
554  {
555  double t = 0;
556  for (int i = 0; i < _u_seq.size(); ++i)
557  {
558  u_sequence->add(t, _u_seq[i].values());
559  t += dt;
560  if (t > t_max) break;
561  }
562  // duplicate last u to have the sampe time stamps as x_sequence
563  if (t <= t_max) u_sequence->add(t, _u_seq.back().values());
564  }
565 }
566 
567 } // namespace corbo
corbo::DiscretizationGridInterface::_u_ref
VectorVertex _u_ref
Definition: discretization_grid_interface.h:192
full_discretization_grid_base.h
corbo::FullDiscretizationGridBase::_n_ref
int _n_ref
Definition: full_discretization_grid_base.h:191
corbo::FullDiscretizationGridBase::isValid
virtual bool isValid() const
Definition: full_discretization_grid_base.h:118
corbo::ScalarVertex::setUpperBound
void setUpperBound(double ub)
Set upper bound.
Definition: scalar_vertex.h:150
PRINT_ERROR_NAMED
#define PRINT_ERROR_NAMED(msg)
Definition: console.h:260
corbo::FullDiscretizationGridBase::_u_seq
std::vector< VectorVertex > _u_seq
Definition: full_discretization_grid_base.h:185
corbo::FullDiscretizationGridBase::_first_run
bool _first_run
Definition: full_discretization_grid_base.h:196
corbo::FullDiscretizationGridBase::_x_seq
std::vector< VectorVertex > _x_seq
Definition: full_discretization_grid_base.h:184
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::NlpFunctions::x_ub
Eigen::VectorXd x_ub
Definition: nlp_functions.h:69
PRINT_ERROR_COND_NAMED
#define PRINT_ERROR_COND_NAMED(cond, msg)
Definition: console.h:262
corbo::DiscretizationGridInterface::setPreviousControl
void setPreviousControl(const Eigen::VectorXd &prev_u, double prev_u_dt)
Definition: discretization_grid_interface.h:175
corbo::ScalarVertex::set
void set(double value, double lb, double ub, bool fixed)
Definition: scalar_vertex.h:134
corbo::FullDiscretizationGridBase::clear
void clear() override
Definition: full_discretization_grid_base.cpp:498
corbo::NlpFunctions
Definition: nlp_functions.h:58
corbo::FullDiscretizationGridBase::_xf_fixed
Eigen::Matrix< bool, -1, 1 > _xf_fixed
Definition: full_discretization_grid_base.h:199
corbo::FullDiscretizationGridBase::getStateAndControlTimeSeries
void getStateAndControlTimeSeries(TimeSeries::Ptr x_sequence, TimeSeries::Ptr u_sequence, double t_max=CORBO_INF_DBL) const override
Return state and control trajectory as time series object (shared instance)
Definition: full_discretization_grid_base.cpp:551
corbo::DiscretizationGridInterface::setLastControlRef
void setLastControlRef(const Eigen::VectorXd &last_u_ref)
Definition: discretization_grid_interface.h:183
corbo::DiscretizationGridInterface::_u_prev_dt
ScalarVertex _u_prev_dt
Definition: discretization_grid_interface.h:191
corbo::FullDiscretizationGridBase::getDt
double getDt() const
Definition: full_discretization_grid_base.h:130
console.h
corbo::FullDiscretizationGridBase::hasSingleDt
bool hasSingleDt() const override
Definition: full_discretization_grid_base.h:106
corbo::FullDiscretizationGridBase::update
GridUpdateResult update(const Eigen::VectorXd &x0, ReferenceTrajectoryInterface &xref, ReferenceTrajectoryInterface &uref, NlpFunctions &nlp_fun, OptimizationEdgeSet &edges, SystemDynamicsInterface::Ptr dynamics, bool new_run, const Time &t, ReferenceTrajectoryInterface *sref=nullptr, const Eigen::VectorXd *prev_u=nullptr, double prev_u_dt=0, ReferenceTrajectoryInterface *xinit=nullptr, ReferenceTrajectoryInterface *uinit=nullptr) override
Definition: full_discretization_grid_base.cpp:60
corbo::FullDiscretizationGridBase::checkAndInitializeXfFixedFlags
bool checkAndInitializeXfFixedFlags(int dim_x)
Definition: full_discretization_grid_base.cpp:369
finite_differences_collocation_edges.h
corbo::FullDiscretizationGridBase::_dt_ref
double _dt_ref
Definition: full_discretization_grid_base.h:193
corbo::FullDiscretizationGridBase::getVertices
void getVertices(std::vector< VertexInterface * > &vertices) override
Definition: full_discretization_grid_base.cpp:523
corbo::VectorVertex::values
const Eigen::VectorXd & values() const
Read-access to the underlying value vector.
Definition: vector_vertex.h:284
corbo::FullDiscretizationGridBase::_dt_ub
double _dt_ub
Definition: full_discretization_grid_base.h:201
corbo::NlpFunctions::u_ub
Eigen::VectorXd u_ub
Definition: nlp_functions.h:71
Eigen::PlainObjectBase::setConstant
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:341
abs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE AbsReturnType abs() const
Definition: ArrayCwiseUnaryOps.h:43
corbo::FullDiscretizationGridBase::isDtFixedIntended
virtual bool isDtFixedIntended() const
Definition: full_discretization_grid_base.h:176
corbo::FullDiscretizationGridBase::_active_vertices
std::vector< VertexInterface * > _active_vertices
Definition: full_discretization_grid_base.h:187
corbo::FullDiscretizationGridBase::warmStartShifting
virtual void warmStartShifting(const Eigen::VectorXd &x0)
Definition: full_discretization_grid_base.cpp:252
corbo::FullDiscretizationGridBase::_nlp_fun
const NlpFunctions * _nlp_fun
Definition: full_discretization_grid_base.h:189
corbo::FullDiscretizationGridBase::findNearestState
int findNearestState(const Eigen::VectorXd &x0)
Definition: full_discretization_grid_base.cpp:309
corbo::NlpFunctions::x_lb
Eigen::VectorXd x_lb
Definition: nlp_functions.h:68
corbo::FullDiscretizationGridBase::adaptGrid
virtual bool adaptGrid(bool new_run, NlpFunctions &nlp_fun)
Definition: full_discretization_grid_base.h:164
corbo::FullDiscretizationGridBase::getNRef
int getNRef() const
Definition: full_discretization_grid_base.h:125
corbo::FullDiscretizationGridBase::_n_adapt
int _n_adapt
Definition: full_discretization_grid_base.h:192
corbo::NlpFunctions::u_lb
Eigen::VectorXd u_lb
Definition: nlp_functions.h:70
corbo::VectorVertex::clear
void clear() override
Clear complete backup container.
Definition: vector_vertex.h:279
corbo::VertexInterface::isFixed
virtual bool isFixed() const
Check if all components are fixed.
Definition: vertex_interface.h:91
corbo::FullDiscretizationGridBase::_xf
PartiallyFixedVectorVertex _xf
Definition: full_discretization_grid_base.h:186
corbo::FullDiscretizationGridBase::isGridAdaptActive
virtual bool isGridAdaptActive() const
Definition: full_discretization_grid_base.h:178
corbo::FullDiscretizationGridBase::createEdges
virtual void createEdges(NlpFunctions &nlp_fun, OptimizationEdgeSet &edges, SystemDynamicsInterface::Ptr dynamics)=0
corbo::FullDiscretizationGridBase::isEmpty
bool isEmpty() const override
Definition: full_discretization_grid_base.h:117
corbo::SystemDynamicsInterface::Ptr
std::shared_ptr< SystemDynamicsInterface > Ptr
Definition: system_dynamics_interface.h:91
corbo::FullDiscretizationGridBase::initializeSequences
virtual void initializeSequences(const Eigen::VectorXd &x0, const Eigen::VectorXd &xf, ReferenceTrajectoryInterface &uref, NlpFunctions &nlp_fun)
Definition: full_discretization_grid_base.cpp:156
corbo::FullDiscretizationGridBase::isMovingHorizonWarmStartActive
virtual bool isMovingHorizonWarmStartActive() const
Definition: full_discretization_grid_base.h:177
corbo::FullDiscretizationGridBase::setN
void setN(int n, bool try_resample=true) override
Return dimension of the control input dimension in the grid.
Definition: full_discretization_grid_base.cpp:510
utilities.h
corbo::TimeSeries::ValuesMatMap
Eigen::Map< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > > ValuesMatMap
Definition: time_series.h:110
corbo::ScalarVertex::value
const double & value() const
Get underlying value.
Definition: scalar_vertex.h:225
corbo::FullDiscretizationGridBase::_dt_lb
double _dt_lb
Definition: full_discretization_grid_base.h:200
corbo::PartiallyFixedVectorVertex::set
void set(const Eigen::Ref< const Eigen::VectorXd > &values, const Eigen::Ref< const Eigen::VectorXd > &lb, const Eigen::Ref< const Eigen::VectorXd > &ub, bool fixed=false) override
Set values and bounds at once.
Definition: vector_vertex.h:349
corbo::FullDiscretizationGridBase::getN
int getN() const override
Definition: full_discretization_grid_base.h:126
corbo::FullDiscretizationGridBase::setNRef
void setNRef(int n)
Definition: full_discretization_grid_base.cpp:355
corbo::VertexSetInterface::isModified
bool isModified() const
Definition: vertex_set.h:127
min
#define min(a, b)
Definition: datatypes.h:19
corbo::FullDiscretizationGridBase::computeActiveVertices
void computeActiveVertices() override
Definition: full_discretization_grid_base.cpp:536
n
PlainMatrixType mat * n
Definition: eigenvalues.cpp:41
corbo::VectorVertex
Vertex implementation that stores an Eigen::VectorXd (dynamic dimension)
Definition: vector_vertex.h:73
corbo::TimeSeries::Ptr
std::shared_ptr< TimeSeries > Ptr
Definition: time_series.h:108
max
#define max(a, b)
Definition: datatypes.h:20
corbo::FullDiscretizationGridBase::resampleTrajectory
virtual void resampleTrajectory(int n_new)
Definition: full_discretization_grid_base.cpp:419
corbo::FullDiscretizationGridBase::_dt
ScalarVertex _dt
Definition: full_discretization_grid_base.h:194
corbo::VertexSetInterface::setModified
void setModified(bool modified)
Definition: vertex_set.h:126
corbo::FullDiscretizationGridBase::getFirstControlInput
bool getFirstControlInput(Eigen::VectorXd &u0) override
Definition: full_discretization_grid_base.cpp:346
corbo::ScalarVertex::setLowerBound
void setLowerBound(double lb)
Set lower bound.
Definition: scalar_vertex.h:148
corbo::FullDiscretizationGridBase::updateBounds
void updateBounds(const NlpFunctions &nlp_fun)
Definition: full_discretization_grid_base.cpp:384
corbo::DiscretizationGridInterface::_u_prev
VectorVertex _u_prev
Definition: discretization_grid_interface.h:190


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:45