Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Master to AutoScaling #38

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/OptimalControl/LGLInterpTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,27 @@ namespace ASSET {
}
void setMethod(TranscriptionModes m);


template<class VecType>
void checkInput(const std::vector<VecType>& xtudat) {

double t0 = xtudat.front()[this->axis];
double tf = xtudat.back()[this->axis];

for (int i = 0; i < xtudat.size() - 1; i++) {
double ti = xtudat[i][this->axis];
double tip1 = xtudat[i+1][this->axis];
if (tip1 == ti) {
throw std::invalid_argument(fmt::format("Duplicate time coordinates in LGLInterpTable."));
}

if ( ( (tip1 < ti)&& tf>t0) || ( ( (tip1 > ti)&& tf<t0)) ){
throw std::invalid_argument(
fmt::format("Non monotonic time coordinates in LGLInterpTable."));
}
}
}

void makePeriodic() {
this->Periodic = true;

Expand Down Expand Up @@ -215,6 +236,9 @@ namespace ASSET {
<< std::endl;
exit(1);
}

checkInput(xtudat);

this->XtUData.resize(this->XtUVars, xtudat.size());
this->XdotData.resize(this->XVars, xtudat.size());
this->T0 = xtudat[0][axis];
Expand Down Expand Up @@ -243,6 +267,7 @@ namespace ASSET {
<< std::endl;
exit(1);
}
checkInput(xtudat);

Eigen::VectorXd myspace = this->Tspacing;
TranscriptionModes mymeth = this->Method;
Expand Down Expand Up @@ -295,6 +320,10 @@ namespace ASSET {
}

void loadRegularData(int dnum, const std::vector<Eigen::VectorXd>& xtudat) {


checkInput(xtudat);

this->XtUData.resize(this->XtUVars, xtudat.size());
this->XtUData.setZero();
this->XdotData.resize(this->XVars, xtudat.size());
Expand All @@ -318,6 +347,9 @@ namespace ASSET {
this->loadEvenData(nxs);
}
void loadExactData(const std::vector<Eigen::VectorXd>& xtudat) {

checkInput(xtudat);

this->XtUData.resize(this->XtUVars, xtudat.size());
this->XtUData.setZero();
this->XdotData.resize(this->XVars, xtudat.size());
Expand All @@ -340,6 +372,7 @@ namespace ASSET {
}
template<class V1, class V2>
void loadExactData(const std::vector<V1>& xtudat, const std::vector<V2>& xdotdat) {
checkInput(xtudat);
this->XtUData.resize(this->XtUVars, xtudat.size());
this->XtUData.setZero();
this->XdotData.resize(this->XVars, xtudat.size());
Expand Down
1 change: 1 addition & 0 deletions src/OptimalControl/ODEPhaseBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,7 @@ void ASSET::ODEPhaseBase::Build(py::module& m) {
obj.def_readwrite("DetectControlSwitches", &ODEPhaseBase::DetectControlSwitches);
obj.def_readwrite("RelSwitchTol", &ODEPhaseBase::RelSwitchTol);
obj.def_readwrite("AbsSwitchTol", &ODEPhaseBase::AbsSwitchTol);
obj.def_readwrite("MeshAbortFlag", &ODEPhaseBase::MeshAbortFlag);


obj.def_readwrite("NumExtraSegs", &ODEPhaseBase::NumExtraSegs);
Expand Down
Loading