OpenSim Moco
0.4.0
|
Utilities for parallelism, strings, date/time, and error-checking. More...
Classes | |
class | OpenSim::Stopwatch |
Record and report elapsed real time ("clock" or "wall" time) in seconds. More... | |
class | OpenSim::ThreadsafeJar< T > |
This class lets you store objects of a single type for reuse by multiple threads, ensuring threadsafe access to each of those objects. More... | |
class | OpenSim::FileDeletionThrowerException |
Thrown by FileDeletionThrower::throwIfDeleted(). More... | |
class | OpenSim::FileDeletionThrower |
This class helps a user cause an exception within the code. More... | |
Functions | |
template<typename T , typename... Args> | |
std::unique_ptr< T > | OpenSim::make_unique (Args &&... args) |
Since Moco does not require C++14 (which contains std::make_unique()), here is an implementation of make_unique(). | |
OSIMMOCO_API std::string | OpenSim::getMocoFormattedDateTime (bool appendMicroseconds=false, std::string format="%Y-%m-%dT%H%M%S") |
Get a string with the current date and time formatted as Y-m-dTHMS (year, month, day, "T", hour, minute, second). More... | |
bool | OpenSim::startsWith (const std::string &string, const std::string &start) |
Determine if string starts with the substring start . More... | |
bool | OpenSim::endsWith (const std::string &string, const std::string &ending) |
Determine if string ends with the substring ending . More... | |
OSIMMOCO_API std::string | OpenSim::getAbsolutePathnameFromXMLDocument (const std::string &documentFileName, const std::string &pathnameRelativeToDocument) |
An OpenSim XML file may contain file paths that are relative to the directory containing the XML file; use this function to convert that relative path into an absolute path. | |
template<typename T > | |
void | OpenSim::checkPropertyInSet (const Object &obj, const Property< T > &p, const std::set< T > &set) |
Throw an exception if the property's value is not in the provided set. More... | |
template<typename T > | |
void | OpenSim::checkPropertyIsPositive (const Object &obj, const Property< T > &p) |
Throw an exception if the property's value is not positive. More... | |
template<typename T > | |
void | OpenSim::checkPropertyInRangeOrSet (const Object &obj, const Property< T > &p, const T &lower, const T &upper, const std::set< T > &set) |
Throw an exception if the property's value is neither in the provided range nor in the provided set. More... | |
OSIMMOCO_API int | OpenSim::getMocoParallelEnvironmentVariable () |
This obtains the value of the OPENSIM_MOCO_PARALLEL environment variable. More... | |
OSIMMOCO_API SimTK::Real | OpenSim::solveBisection (std::function< double(const double &)> calcResidual, double left, double right, const double &tolerance=1e-6, int maxIterations=1000) |
Solve for the root of a scalar function using the bisection method. More... | |
Utilities for parallelism, strings, date/time, and error-checking.
void OpenSim::checkPropertyInRangeOrSet | ( | const Object & | obj, |
const Property< T > & | p, | ||
const T & | lower, | ||
const T & | upper, | ||
const std::set< T > & | set | ||
) |
Throw an exception if the property's value is neither in the provided range nor in the provided set.
We assume that p
is a single-value property.
void OpenSim::checkPropertyInSet | ( | const Object & | obj, |
const Property< T > & | p, | ||
const std::set< T > & | set | ||
) |
Throw an exception if the property's value is not in the provided set.
We assume that p
is a single-value property.
void OpenSim::checkPropertyIsPositive | ( | const Object & | obj, |
const Property< T > & | p | ||
) |
Throw an exception if the property's value is not positive.
We assume that p
is a single-value property.
|
inline |
Determine if string
ends with the substring ending
.
https://stackoverflow.com/questions/874134/find-if-string-ends-with-another-string-in-c
OSIMMOCO_API std::string OpenSim::getMocoFormattedDateTime | ( | bool | appendMicroseconds = false , |
std::string | format = "%Y-%m-%dT%H%M%S" |
||
) |
Get a string with the current date and time formatted as Y-m-dTHMS (year, month, day, "T", hour, minute, second).
You can change the datetime format via the format
parameter. If you specify "ISO", then we use the ISO 8601 extended datetime format Y-m-dTH:M:S. See https://en.cppreference.com/w/cpp/io/manip/put_time.
OSIMMOCO_API int OpenSim::getMocoParallelEnvironmentVariable | ( | ) |
This obtains the value of the OPENSIM_MOCO_PARALLEL environment variable.
The value has the following meanings:
This variable does not indicate which calculations are parallelized or how the parallelization is achieved. Moco may even ignore or override the setting from the environment variable. See documentation elsewhere (e.g., from a specific MocoSolver) for more information.
OSIMMOCO_API SimTK::Real OpenSim::solveBisection | ( | std::function< double(const double &)> | calcResidual, |
double | left, | ||
double | right, | ||
const double & | tolerance = 1e-6 , |
||
int | maxIterations = 1000 |
||
) |
Solve for the root of a scalar function using the bisection method.
calcResidual | a function that computes the error |
left | lower bound on the root |
right | upper bound on the root |
tolerance | convergence requires that the bisection's "left" and "right" are less than tolerance apart. |
maxIterations | abort after this many iterations. |
|
inline |
Determine if string
starts with the substring start
.
https://stackoverflow.com/questions/874134/find-if-string-ends-with-another-string-in-c