|
Quandary
|
Configuration class containing all validated settings. More...
#include <config.hpp>
Public Member Functions | |
| Config (const MPILogger &logger, const toml::table &table) | |
| Config (const MPILogger &logger, const ParsedConfigData &settings) | |
| ~Config ()=default | |
| void | printConfig (std::stringstream &log) const |
| const std::vector< size_t > & | getNLevels () const |
| size_t | getNLevels (size_t i_osc) const |
| size_t | getNumOsc () const |
| const std::vector< size_t > & | getNEssential () const |
| size_t | getNEssential (size_t i_osc) const |
| size_t | getNTime () const |
| double | getDt () const |
| double | getTotalTime () const |
| const std::vector< double > & | getTransitionFrequency () const |
| const std::vector< double > & | getSelfKerr () const |
| const std::vector< double > & | getCrossKerrCoupling () const |
| const std::vector< double > & | getDipoleCoupling () const |
| const std::vector< double > & | getRotationFrequency () const |
| DecoherenceType | getDecoherenceType () const |
| const std::vector< double > & | getDecayTime () const |
| const std::vector< double > & | getDephaseTime () const |
| size_t | getNInitialConditions () const |
| const InitialConditionSettings & | getInitialCondition () const |
| const std::optional< std::string > & | getHamiltonianFileHsys () const |
| const std::optional< std::string > & | getHamiltonianFileHc () const |
| const ControlParameterizationSettings & | getControlParameterizations (size_t i_osc) const |
| bool | getControlZeroBoundaryCondition () const |
| const ControlInitializationSettings & | getControlInitializations (size_t i_osc) const |
| double | getControlAmplitudeBound (size_t i_osc) const |
| const std::vector< double > & | getCarrierFrequencies (size_t i_osc) const |
| const OptimTargetSettings & | getOptimTarget () const |
| ObjectiveType | getOptimObjective () const |
| const std::vector< double > & | getOptimWeights () const |
| double | getOptimTolGradAbs () const |
| double | getOptimTolGradRel () const |
| double | getOptimTolFinalCost () const |
| double | getOptimTolInfidelity () const |
| size_t | getOptimMaxiter () const |
| double | getOptimTikhonovCoeff () const |
| bool | getOptimTikhonovUseX0 () const |
| double | getOptimPenaltyLeakage () const |
| double | getOptimPenaltyWeightedCost () const |
| double | getOptimPenaltyWeightedCostWidth () const |
| double | getOptimPenaltyDpdm () const |
| double | getOptimPenaltyEnergy () const |
| double | getOptimPenaltyVariation () const |
| const std::string & | getOutputDirectory () const |
| const std::vector< OutputType > & | getOutputObservables () const |
| size_t | getOutputTimestepStride () const |
| size_t | getOutputOptimizationStride () const |
| RunType | getRuntype () const |
| bool | getUseMatFree () const |
| LinearSolverType | getLinearSolverType () const |
| size_t | getLinearSolverMaxiter () const |
| TimeStepperType | getTimestepperType () const |
| int | getRandSeed () const |
Static Public Member Functions | |
| static Config | fromFile (const std::string &filename, const MPILogger &logger) |
| static Config | fromToml (const std::string &toml_filename, const MPILogger &logger) |
| static Config | fromTomlString (const std::string &toml_content, const MPILogger &logger) |
| static Config | fromCfg (const std::string &cfg_filename, const MPILogger &logger) |
| static Config | fromCfgString (const std::string &cfg_content, const MPILogger &logger) |
Configuration class containing all validated settings.
Contains validated, typed configuration parameters. All fields have been validated with defaults set. Handles parsing from TOML configuration files and deprecated CFG format, as well as printing log of used configuration. This class is immutable after construction.
1) Add new member variable to the Config class below
2) Add parsing logic in constructor Config::Config(toml::table) in src/config.cpp. Either access directly from toml table, or use chains of validators for type-safe extraction and validation. For example:
Parsing simple scalar fields (T foo):
foo = toml["foo"].value(): required scalar field, no default, not validated)foo = toml["foo"].value_or(default_value): optional scalar with default, not validatedfoo = validators::field<T>(toml, "foo").<validation_chain>.value(): validated required scalarfoo = validators::field<T>(toml, "foo").<validation_chain>.valueOr(default_value): validated optional scalar with defaultParsing vectors (std::vector<T> foo):
foo = toml["foo"].as_array()->as<T>().value_or(default_vector): vector with default, not validatedfoo = validators::vectorField<T>(toml, "foo").<validation_chain>.value(): validated required vectorfoo = validators::vectorField<T>(toml, "foo").<validation_chain>.value(default_vector): validated optional vector with defaultAvailable validation chain methods can found in include/config_validators.hpp, such as: .positive(), .greaterThan(val), .lessThan(val), .minLength(len), .hasLength(len), etc.
3) Add a getter method to the Config class below (T getFoo() const {return foo};)
4) Add printing logic in Config::printConfig() in src/config.cpp
| Config::Config | ( | const MPILogger & | logger, |
| const toml::table & | table | ||
| ) |
| Config::Config | ( | const MPILogger & | logger, |
| const ParsedConfigData & | settings | ||
| ) |
|
default |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void Config::printConfig | ( | std::stringstream & | log | ) | const |