44 template <
class TNumType,
class TLeafType>
53 return this->
template sub<0>();
59 return this->
template sub<0>();
65 return this->
template sub<1>();
71 return this->
template sub<1>();
77 return this->
template sub<2>();
83 return this->
template sub<2>();
99 template <
class TNumType,
class TLeafType>
108 return this->
template sub<0>();
112 const auto&
L()
const 114 return this->
template sub<0>();
120 return this->
template sub<1>();
124 const auto&
x()
const 126 return this->
template sub<1>();
132 return this->
template sub<2>();
136 const auto&
y()
const 138 return this->
template sub<2>();
144 return this->
template sub<3>();
150 return this->
template sub<3>();
166 template <
class TNumType,
class TLeafType>
175 return this->
template sub<0>();
179 const auto&
v()
const 181 return this->
template sub<0>();
187 return this->
template sub<1>();
193 return this->
template sub<1>();
199 return this->
template sub<2>();
205 return this->
template sub<2>();
211 return this->
template sub<3>();
217 return this->
template sub<3>();
223 return this->
template sub<4>();
227 const auto&
t()
const 229 return this->
template sub<4>();
235 return this->
template sub<5>();
239 const auto&
s()
const 241 return this->
template sub<5>();
247 template <
class TNumType,
typename TLeafType>
256 return this->
template sub<1>();
261 return this->
template sub<1>();
267 return this->
template sub<3>();
272 return this->
template sub<3>();
278 return this->
template sub<0>();
283 return this->
template sub<0>();
289 return this->
template sub<2>();
294 return this->
template sub<2>();
298 template <
class TNumType>
300 template <
class TNumType>
302 template <
class TNumType>
304 template <
class TNumType>
307 template <
class TNumType,
class TCfDataType>
322 template <
class TNumType,
class MapDataType,
class TStateType,
template <
class>
class TDiscretizationType,
325 :
public StateSimBase<StateSimE8Base<TNumType, MapDataType, TStateType, TDiscretizationType, TFuncsType...>,
326 ParamType<TNumType, MapDataType>, TStateType, TDiscretizationType, TFuncsType...>
333 this->paramStruct->paramFuncs.precompute();
343 arcCfNmStepCache_ = _arc;
344 auto& paramFuncs = this->paramStruct->paramFuncs;
345 paramFuncs.setEvalArc(_arc, _eAG);
347 _XCf.v() = paramFuncs.computeFuncVal(
asInt(
PFV::V));
348 _XCf.phi() = paramFuncs.computeFuncVal(
asInt(PFV::Phi));
352 void setXCfImpl(
auto& _XCf,
const TNumType& _arc,
const PfEaG& _eAG)
354 setXCfNmStep(_XCf, _arc, _eAG);
355 auto& paramFuncs = this->paramStruct->paramFuncs;
356 _XCf.vDot() = paramFuncs.computeFuncDiff1(
asInt(
PFV::V));
357 _XCf.phiDot() = paramFuncs.computeFuncDiff1(
asInt(PFV::Phi));
359 _XCf.s() = paramFuncs.computeS();
363 void setXCfDotImpl(
auto& _XCfDot,
const auto& _XCf,
const TNumType& _arc,
const PfEaG& _eAG)
const 365 _XCfDot.v() = _XCf.vDot();
366 _XCfDot.phi() = _XCf.phiDot();
368 _XCfDot.phiDot() = 0;
370 _XCfDot.s() = fabs(_XCf.v());
376 for (
int i = 0; i < _XNm0.data().size(); ++i)
380 _XNm0.x() = this->paramStruct->state0.stateNm().x();
381 _XNm0.y() = this->paramStruct->state0.stateNm().y();
382 _XNm0.theta() = this->paramStruct->state0.stateNm().theta();
386 void setXNmDotImpl(
auto& _XNmDot,
auto& _stateCf,
const auto& _stateNm,
const TNumType& _arc,
const PfEaG& _eAG)
388 setXCfNmStep(_stateCf, _arc, _eAG);
394 tanPhi_ = tan(_stateCf.phi());
395 arcNmDotCache_ = _arc;
397 _XNmDot.x() = _stateCf.v() * cos(_stateNm.theta());
398 _XNmDot.y() = _stateCf.v() * sin(_stateNm.theta());
399 _XNmDot.theta() = _stateCf.v() * tanPhi_ / this->paramStruct->lB;
407 for (
int i = 0; i < _gradXNm0.data().size(); ++i)
409 _gradXNm0.data()(i) = 0;
416 auto& paramFuncs = this->paramStruct->paramFuncs;
417 int ctrlPtOptNr = paramFuncs.funcCtrlPtSize(0) - 1;
418 if (_gradXNm.sub(0).sub(0).data().size() != ctrlPtOptNr)
420 for (
size_t i = 0; i < _gradXNm.subSize(); ++i)
422 for (
size_t j = 0; j < _gradXNm.sub(i).subSize(); ++j)
426 _gradXNm.sub(i).sub(j).subResize(ctrlPtOptNr);
430 _gradXNm.sub(i).sub(j).subResize(ctrlPtOptNr - 1);
434 for (
size_t i = 0; i < _gradXCf.subSize(); ++i)
436 for (
size_t j = 0; j < _gradXCf.sub(i).subSize(); ++j)
440 _gradXCf.sub(i).sub(j).subResize(ctrlPtOptNr);
444 _gradXCf.sub(i).sub(j).subResize(ctrlPtOptNr - 1);
452 void setGradXCfImpl(
auto& _gradXCf,
const auto& _XCf,
const TNumType& _arc,
const PfEaG& _eAG)
454 setGradXCfNmStep(_gradXCf, _XCf, _arc, _eAG);
456 auto& paramFuncs = this->paramStruct->paramFuncs;
458 auto& dSdParamV = _gradXCf.s().optParamV();
459 for (
size_t i = 0; i < dSdParamV.subSize(); ++i)
461 auto& dSdParamVI = dSdParamV.sub(i);
463 if (i + 1 < dSdParamV.subSize())
465 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::ARC);
466 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::ARC);
467 if (_arc > evalArcBelow)
469 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
470 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
471 dSdParamVI = +(arcIntEnd - evalArcBelow) * (evalArcBelow - 2. * _arc + arcIntEnd) / (2. * deltaEvalArc);
474 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::ARC);
475 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(0, i,
CtrlPtDim::ARC);
476 if (_arc > evalArcBelow)
478 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
479 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
480 dSdParamVI += -(arcIntEnd - evalArcBelow) * (evalArcBelow - 2. * _arc + arcIntEnd) / (2. * deltaEvalArc);
484 auto& dSdParamT = _gradXCf.s().optParamTV();
485 auto& dAVdParamV = _gradXCf.vDot().optParamV();
486 auto& dAPdParamP = _gradXCf.phiDot().optParamP();
487 auto& dAVdParamT = _gradXCf.vDot().optParamTV();
488 for (
size_t i = 0; i < dSdParamT.subSize(); ++i)
490 auto& dSdParamTI = dSdParamT.sub(i);
491 auto& dAVdParamVI = dAVdParamV.sub(i);
492 auto& dAPdParamPI = dAPdParamP.sub(i);
493 auto& dAVdParamTI = dAVdParamT.sub(i);
494 if (i + 1 < paramFuncs.funcCtrlPtSize(0))
496 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::ARC);
497 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(0, i,
CtrlPtDim::ARC);
498 const TNumType& evalArcAboveP = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::ARC);
499 const TNumType& evalArcBelowP = paramFuncs.ctrlPtVal(1, i,
CtrlPtDim::ARC);
500 if ((_arc <= evalArcAbove) && (_arc > evalArcBelow))
502 const TNumType& vP = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::VAL);
503 const TNumType& vM = paramFuncs.ctrlPtVal(0, i + 0,
CtrlPtDim::VAL);
504 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
505 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
506 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
507 const TNumType deltaArcIntBound = arcIntEnd - evalArcBelow;
508 dAVdParamTI = -(vP - vM) / deltaEvalArcSqr;
509 dAVdParamVI = +1. / deltaEvalArc;
510 dSdParamTI = +deltaArcIntBound * (vP - vM) * (evalArcBelow - 2. * _arc + arcIntEnd) / (2. * deltaEvalArcSqr);
512 else if ((_arc > evalArcBelow) && (i + 1 < dSdParamT.subSize()))
514 const TNumType& evalArcAbove2 = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::ARC);
515 const TNumType deltaEvalArc = evalArcAbove2 - evalArcAbove;
516 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
517 if (_arc <= evalArcAbove2)
519 dAVdParamVI = -1. / deltaEvalArc;
520 const TNumType& vP = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::VAL);
521 const TNumType& vM = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::VAL);
522 dAVdParamTI = +(vP - vM) / deltaEvalArcSqr;
524 if (_arc < evalArcAbove2)
526 const TNumType& vP = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::VAL);
527 const TNumType& vM = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::VAL);
528 const TNumType& vMM = paramFuncs.ctrlPtVal(0, i + 0,
CtrlPtDim::VAL);
529 const TNumType arcIntEnd = fmin(_arc, evalArcAbove2);
530 dSdParamTI = -(+(vM - vMM) * evalArcAbove2 * evalArcAbove2 +
531 (vP - vMM) * (evalArcAbove * evalArcAbove - 2. * evalArcAbove * evalArcAbove2) +
532 (vP - vM) * (arcIntEnd * arcIntEnd + 2. * _arc * (evalArcAbove2 - arcIntEnd))) /
533 (2. * deltaEvalArcSqr);
537 const TNumType& vP = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::VAL);
538 const TNumType& vM = paramFuncs.ctrlPtVal(0, i + 0,
CtrlPtDim::VAL);
539 dSdParamTI = -(vP - vM) / 2.;
542 else if (_arc > evalArcBelow)
544 const TNumType& vP = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::VAL);
545 const TNumType& vM = paramFuncs.ctrlPtVal(0, i + 0,
CtrlPtDim::VAL);
546 dSdParamTI = -(vP - vM) / 2.;
549 if ((_arc <= evalArcAboveP) && (_arc > evalArcBelowP))
551 dAPdParamPI = +1. / (evalArcAboveP - evalArcBelowP);
553 else if ((_arc > evalArcBelowP) && (i + 1 < dSdParamT.subSize()))
555 const TNumType& evalArcAbove2P = paramFuncs.ctrlPtVal(1, i + 2,
CtrlPtDim::ARC);
556 const TNumType deltaEvalArcP = evalArcAbove2P - evalArcAboveP;
557 if (_arc <= evalArcAbove2P)
559 dAPdParamPI = -1. / deltaEvalArcP;
565 auto& dAPdParamT = _gradXCf.phiDot().optParamTP();
566 for (
size_t i = 0; i < dAPdParamT.subSize(); ++i)
568 auto& dAPdParamTI = dAPdParamT.sub(i);
569 if (i + 1 < paramFuncs.funcCtrlPtSize(1))
571 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::ARC);
572 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(1, i,
CtrlPtDim::ARC);
573 if ((_arc <= evalArcAbove) && (_arc > evalArcBelow))
575 const TNumType& wP = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::VAL);
576 const TNumType& wM = paramFuncs.ctrlPtVal(1, i + 0,
CtrlPtDim::VAL);
577 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
578 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
579 dAPdParamTI = -(wP - wM) / deltaEvalArcSqr;
581 else if ((_arc > evalArcBelow) && (i + 1 < dAPdParamT.subSize() + 1))
583 const TNumType& evalArcAbove2 = paramFuncs.ctrlPtVal(1, i + 2,
CtrlPtDim::ARC);
584 const TNumType deltaEvalArc = evalArcAbove2 - evalArcAbove;
585 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
586 if (_arc <= evalArcAbove2)
588 const TNumType& wP = paramFuncs.ctrlPtVal(1, i + 2,
CtrlPtDim::VAL);
589 const TNumType& wM = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::VAL);
590 dAPdParamTI = +(wP - wM) / deltaEvalArcSqr;
598 void setGradXCfNmStep(
auto& _gradXCf,
const auto& _XCf,
const TNumType& _arc,
const PfEaG& _eAG)
604 arcGradCache_ = _arc;
605 auto& paramFuncs = this->paramStruct->paramFuncs;
607 _gradXCf.data().setZero();
608 auto& dVdParamV = _gradXCf.v().optParamV();
609 for (
size_t i = 0; i < dVdParamV.subSize(); ++i)
611 auto& dVdParamVI = dVdParamV.sub(i);
613 if (i + 1 < dVdParamV.subSize())
615 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::ARC);
616 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::ARC);
617 if (_arc > evalArcBelow)
619 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
620 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
621 dVdParamVI = -(arcIntEnd - evalArcBelow) / deltaEvalArc;
624 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::ARC);
625 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(0, i,
CtrlPtDim::ARC);
626 if (_arc > evalArcBelow)
628 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
629 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
630 dVdParamVI += +(arcIntEnd - evalArcBelow) / deltaEvalArc;
634 auto& dPdParamP = _gradXCf.phi().optParamP();
635 for (
size_t i = 0; i < dPdParamP.subSize(); ++i)
637 auto& dPdParamPI = dPdParamP.sub(i);
638 if (i + 1 < dPdParamP.subSize())
640 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(1, i + 2,
CtrlPtDim::ARC);
641 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::ARC);
642 if (_arc > evalArcBelow)
644 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
645 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
646 dPdParamPI = -(arcIntEnd - evalArcBelow) / deltaEvalArc;
649 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::ARC);
650 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(1, i,
CtrlPtDim::ARC);
651 if (_arc > evalArcBelow)
653 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
654 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
655 dPdParamPI += +(arcIntEnd - evalArcBelow) / deltaEvalArc;
659 auto& dVdParamT = _gradXCf.v().optParamTV();
660 for (
size_t i = 0; i < dVdParamT.subSize(); ++i)
662 auto& dVdParamTI = dVdParamT.sub(i);
663 if (i + 1 < paramFuncs.funcCtrlPtSize(0))
665 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::ARC);
666 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(0, i,
CtrlPtDim::ARC);
667 if ((_arc <= evalArcAbove) && (_arc > evalArcBelow))
669 const TNumType& vP = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::VAL);
670 const TNumType& vM = paramFuncs.ctrlPtVal(0, i + 0,
CtrlPtDim::VAL);
671 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
672 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
673 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
674 const TNumType deltaArcIntBound = arcIntEnd - evalArcBelow;
675 dVdParamTI = -deltaArcIntBound * (vP - vM) / deltaEvalArcSqr;
677 else if ((_arc > evalArcBelow) && (i + 1 < dVdParamT.subSize()))
679 const TNumType& evalArcAbove2 = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::ARC);
680 const TNumType deltaEvalArc = evalArcAbove2 - evalArcAbove;
681 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
682 if (_arc < evalArcAbove2)
684 const TNumType& vP = paramFuncs.ctrlPtVal(0, i + 2,
CtrlPtDim::VAL);
685 const TNumType& vM = paramFuncs.ctrlPtVal(0, i + 1,
CtrlPtDim::VAL);
686 const TNumType arcIntEnd = fmin(_arc, evalArcAbove2);
688 const TNumType deltaArcIntBound = evalArcAbove2 - arcIntEnd;
689 dVdParamTI = -deltaArcIntBound * (vP - vM) / deltaEvalArcSqr;
695 auto& dPdParamT = _gradXCf.phi().optParamTP();
696 for (
size_t i = 0; i < dPdParamT.subSize(); ++i)
698 auto& dPdParamTI = dPdParamT.sub(i);
699 if (i + 1 < paramFuncs.funcCtrlPtSize(1))
701 const TNumType& evalArcAbove = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::ARC);
702 const TNumType& evalArcBelow = paramFuncs.ctrlPtVal(1, i,
CtrlPtDim::ARC);
703 if ((_arc <= evalArcAbove) && (_arc > evalArcBelow))
705 const TNumType& wP = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::VAL);
706 const TNumType& wM = paramFuncs.ctrlPtVal(1, i + 0,
CtrlPtDim::VAL);
707 const TNumType arcIntEnd = fmin(_arc, evalArcAbove);
708 const TNumType deltaEvalArc = evalArcAbove - evalArcBelow;
709 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
710 const TNumType deltaArcIntBound = arcIntEnd - evalArcBelow;
711 dPdParamTI = -deltaArcIntBound * (wP - wM) / deltaEvalArcSqr;
713 else if ((_arc > evalArcBelow) && (i + 1 < dPdParamT.subSize() + 1))
715 const TNumType& evalArcAbove2 = paramFuncs.ctrlPtVal(1, i + 2,
CtrlPtDim::ARC);
716 const TNumType deltaEvalArc = evalArcAbove2 - evalArcAbove;
717 const TNumType deltaEvalArcSqr = deltaEvalArc * deltaEvalArc;
718 if (_arc < evalArcAbove2)
720 const TNumType& wP = paramFuncs.ctrlPtVal(1, i + 2,
CtrlPtDim::VAL);
721 const TNumType& wM = paramFuncs.ctrlPtVal(1, i + 1,
CtrlPtDim::VAL);
722 const TNumType arcIntEnd = fmin(_arc, evalArcAbove2);
724 const TNumType deltaArcIntBound = evalArcAbove2 - arcIntEnd;
725 dPdParamTI = -deltaArcIntBound * (wP - wM) / deltaEvalArcSqr;
733 void setGradXNmDotImpl(
auto& _gradXNmDot,
auto& _XGradXCf,
const auto& _XGradXNm,
const TNumType& _arc,
740 arcGradNmStepCache_ = _arc;
742 auto& gradXCf = _XGradXCf.stateGrad();
743 const auto& XCf = _XGradXCf.state();
744 setGradXCfNmStep(gradXCf, XCf, _arc, _eAG);
747 static Eigen::Matrix<TNumType, 2, 1> dfduX;
748 static Eigen::Matrix<TNumType, 2, 1> dfdTh;
749 const TNumType vPhiSqrForm = XCf.v() * (1 + tanPhi_ * tanPhi_);
751 cosTheta_ = cos(_XGradXNm.state().theta());
752 sinTheta_ = sin(_XGradXNm.state().theta());
754 dfduX(0) = cosTheta_;
755 dfduX(1) = sinTheta_;
757 dfdTh(0) = -XCf.v() * sinTheta_;
758 dfdTh(1) = +XCf.v() * cosTheta_;
760 auto& dXdParamV = _gradXNmDot.x().optParamV().data();
761 auto& dYdParamV = _gradXNmDot.y().optParamV().data();
762 auto& dThdParamV = _gradXNmDot.theta().optParamV().data();
763 auto& dXdParamP = _gradXNmDot.x().optParamP().data();
764 auto& dYdParamP = _gradXNmDot.y().optParamP().data();
765 auto& dThdParamP = _gradXNmDot.theta().optParamP().data();
767 auto& dXdParamTV = _gradXNmDot.x().optParamTV().data();
768 auto& dYdParamTV = _gradXNmDot.y().optParamTV().data();
769 auto& dThdParamTV = _gradXNmDot.theta().optParamTV().data();
771 auto& dXdParamTP = _gradXNmDot.x().optParamTP().data();
772 auto& dYdParamTP = _gradXNmDot.y().optParamTP().data();
773 auto& dThdParamTP = _gradXNmDot.theta().optParamTP().data();
775 const auto& stateGradCfParamVIV = gradXCf.v().optParamV();
776 const auto& stateGradCfParamWIPhi = gradXCf.phi().optParamP();
778 const auto& stateGradCfParamTVIV = gradXCf.v().optParamTV();
779 const auto& stateGradCfParamTPIV = gradXCf.v().optParamTP();
780 const auto& stateGradCfParamTVIPhi = gradXCf.phi().optParamTV();
781 const auto& stateGradCfParamTPIPhi = gradXCf.phi().optParamTP();
783 auto& gradXNm = _XGradXNm.stateGrad();
784 const auto& stateGradNmParamVITh = gradXNm.theta().optParamV();
785 const auto& stateGradNmParamPITh = gradXNm.theta().optParamP();
786 const auto& stateGradNmParamTVITh = gradXNm.theta().optParamTV();
787 const auto& stateGradNmParamTPITh = gradXNm.theta().optParamTP();
789 for (
int i = 0; i < dXdParamV.size(); ++i)
791 const auto& stateGradCfParamVIVI = stateGradCfParamVIV.sub(i);
792 const auto& stateGradCfParamWIPhiI = stateGradCfParamWIPhi.sub(i);
794 const auto& stateGradNmParamVIThI = stateGradNmParamVITh.sub(i);
795 const auto& stateGradNmParamPIThI = stateGradNmParamPITh.sub(i);
797 const auto& stateGradCfParamTVIVI = stateGradCfParamTVIV.sub(i);
798 const auto& stateGradCfParamTVIPhiI = stateGradCfParamTVIPhi.sub(i);
799 const auto& stateGradNmParamTVIThI = stateGradNmParamTVITh.sub(i);
801 dXdParamV(i) = dfduX(0) * stateGradCfParamVIVI + dfdTh(0) * stateGradNmParamVIThI;
802 dYdParamV(i) = dfduX(1) * stateGradCfParamVIVI + dfdTh(1) * stateGradNmParamVIThI;
804 dXdParamP(i) = +dfdTh(0) * stateGradNmParamPIThI;
805 dYdParamP(i) = +dfdTh(1) * stateGradNmParamPIThI;
807 dXdParamTV(i) = dfduX(0) * stateGradCfParamTVIVI + dfdTh(0) * stateGradNmParamTVIThI;
808 dYdParamTV(i) = dfduX(1) * stateGradCfParamTVIVI + dfdTh(1) * stateGradNmParamTVIThI;
810 dThdParamV(i) = (stateGradCfParamVIVI * tanPhi_) / this->paramStruct->lB;
812 dThdParamP(i) = (vPhiSqrForm * stateGradCfParamWIPhiI) / this->paramStruct->lB;
815 (vPhiSqrForm * stateGradCfParamTVIPhiI + stateGradCfParamTVIVI * tanPhi_) / this->paramStruct->lB;
817 for (
int i = 0; i < dXdParamV.size() - 1; ++i)
819 const auto& stateGradCfParamTPIPhiI = stateGradCfParamTPIPhi.sub(i);
820 const auto& stateGradCfParamTPIVI = stateGradCfParamTPIV.sub(i);
821 const auto& stateGradNmParamTPIThI = stateGradNmParamTPITh.sub(i);
823 dXdParamTP(i) = dfduX(0) * stateGradCfParamTPIVI + dfdTh(0) * stateGradNmParamTPIThI;
824 dYdParamTP(i) = dfduX(1) * stateGradCfParamTPIVI + dfdTh(1) * stateGradNmParamTPIThI;
827 (vPhiSqrForm * stateGradCfParamTPIPhiI + stateGradCfParamTPIVI * tanPhi_) / this->paramStruct->lB;
855 template <
class TNumType,
class TParamStructType>
858 static void setOptVar(TParamStructType& _paramStruct,
const Eigen::Matrix<TNumType, -1, 1>& _optVarExt)
860 auto& paramFuncs = _paramStruct.paramFuncs;
861 size_t idxOptVec = 0;
862 for (
int i = paramFuncs.funcsSize() - 1; i >= 0; --i)
864 for (
size_t j = 1; j < paramFuncs.funcCtrlPtSize(i); ++j)
866 paramFuncs.ctrlPtVal(i, j,
CtrlPtDim::VAL) = _optVarExt(idxOptVec++);
869 for (
size_t j = 1; j < paramFuncs.funcsArcSize(1) - 1; ++j)
871 paramFuncs.funcsArc(1, j) = _optVarExt(idxOptVec++);
873 for (
size_t j = 1; j < paramFuncs.funcsArcSize(0); ++j)
875 paramFuncs.funcsArc(0, j) = _optVarExt(idxOptVec++);
878 static void getOptVar(Eigen::Matrix<TNumType, -1, 1>& _optVarExt,
const TParamStructType& _paramStruct)
880 auto& paramFuncs = _paramStruct.paramFuncs;
881 int newSize = paramFuncs.funcsSize() * (paramFuncs.funcCtrlPtSize(0) - 1) + (paramFuncs.funcsArcSize(0) - 1) +
882 (paramFuncs.funcsArcSize(1) - 2);
883 if (newSize != _optVarExt.size())
885 _optVarExt.resize(newSize);
887 size_t idxOptVec = 0;
888 for (
int i = paramFuncs.funcsSize() - 1; i >= 0; --i)
890 for (
size_t j = 1; j < paramFuncs.funcCtrlPtSize(i); ++j)
892 _optVarExt(idxOptVec++) = paramFuncs.ctrlPtVal(i, j,
CtrlPtDim::VAL);
895 for (
size_t j = 1; j < paramFuncs.funcsArcSize(1) - 1; ++j)
897 _optVarExt(idxOptVec++) = paramFuncs.funcsArc(1, j);
899 for (
size_t j = 1; j < paramFuncs.funcsArcSize(0); ++j)
901 _optVarExt(idxOptVec++) = paramFuncs.funcsArc(0, j);
906 template <
class TNumType,
class TMapDataType,
template <
class>
class TDiscretizationType>
911 template <
class TNumType,
class TMapDataType,
template <
class>
class TDiscretizationType,
class... TCostFuncType>
913 :
public StateSimE8Base<TNumType, TMapDataType, StateWithLE8<TNumType>, TDiscretizationType, TCostFuncType...>
917 template <
class TNumType,
class TMapDataType,
template <
class>
class TDiscretizationType>
922 template <
class TNumType,
class TMapDataType,
template <
class>
class TDiscretizationType,
class... TCostFuncType>
924 TDiscretizationType, TCostFuncType...>
void adjustGradXSizeImpl(auto &_gradXNm, auto &_gradXCf)
const auto & optParamTV() const
void setXCfImpl(auto &_XCf, const TNumType &_arc, const PfEaG &_eAG)
static void getOptVar(Eigen::Matrix< TNumType,-1, 1 > &_optVarExt, const TParamStructType &_paramStruct)
void setGradXNm0Impl(auto &_gradXNm0, const auto &_XNm0)
--------------------------------—Gradient information--------------------------------—/// ...
void adjustXSizeImpl(auto &_XNm, auto &_XCf)
const auto & theta() const
const auto & optParamP() const
control point arc parameter
const auto & optParamTP() const
ParamFuncsSpline0Dist< TNumType, 2, 2 > paramFuncs
static constexpr const size_t optParamBlockSize
constexpr auto asInt(Enumeration const value) -> typename std::underlying_type< Enumeration >::type
const auto & state() const
void setXCfNmStep(auto &_XCf, const TNumType &_arc, const PfEaG &_eAG)
const auto & vDot() const
static void setOptVar(TParamStructType &_paramStruct, const Eigen::Matrix< TNumType,-1, 1 > &_optVarExt)
agent base center linear velocity is parametric function
const auto & optParamV() const
const auto & phiDot() const
void setGradXCfNmStep(auto &_gradXCf, const auto &_XCf, const TNumType &_arc, const PfEaG &_eAG)
const auto & theta() const
TNumType arcGradNmStepCache_
TNumType arcCfNmStepCache_
StateE8< TNumType > state0
void setXNm0Impl(auto &_XNm0)
close to previous evaluation arc
void setGradXNmDotImpl(auto &_gradXNmDot, auto &_XGradXCf, const auto &_XGradXNm, const TNumType &_arc, const PfEaG &_eAG)
void setXNmDotImpl(auto &_XNmDot, auto &_stateCf, const auto &_stateNm, const TNumType &_arc, const PfEaG &_eAG)
const auto & state() const
typename ParamType< TNumType, TMapDataType >::ParamFuncVars PFV
void setGradXCfImpl(auto &_gradXCf, const auto &_XCf, const TNumType &_arc, const PfEaG &_eAG)
void setXCfDotImpl(auto &_XCfDot, const auto &_XCf, const TNumType &_arc, const PfEaG &_eAG) const