#include <GreedyCustomSampler.h>
Public Member Functions | |
GreedyCustomSampler (std::vector< Vector > parameter_points, bool check_local_rom, double relative_error_tolerance, double alpha, double max_clamp, int subset_size, int convergence_subset_size, std::string output_log_path="", std::string warm_start_file_name="", bool use_centroid=true, int random_seed=1, bool debug_algorithm=false) | |
Constructor. More... | |
GreedyCustomSampler (std::vector< double > parameter_points, bool check_local_rom, double relative_error_tolerance, double alpha, double max_clamp, int subset_size, int convergence_subset_size, std::string output_log_path="", std::string warm_start_file_name="", bool use_centroid=true, int random_seed=1, bool debug_algorithm=false) | |
Constructor. More... | |
GreedyCustomSampler (std::string base_file_name, std::string output_log_path="") | |
Constructor. More... | |
~GreedyCustomSampler () | |
Destructor. | |
![]() | |
GreedySampler (std::vector< Vector > parameter_points, bool check_local_rom, double relative_error_tolerance, double alpha, double max_clamp, int subset_size, int convergence_subset_size, std::string output_log_path="", std::string warm_start_file_name="", bool use_centroid=true, int random_seed=1, bool debug_algorithm=false) | |
Constructor. More... | |
GreedySampler (std::vector< double > parameter_points, bool check_local_rom, double relative_error_tolerance, double alpha, double max_clamp, int subset_size, int convergence_subset_size, std::string output_log_path="", std::string warm_start_file_name="", bool use_centroid=true, int random_seed=1, bool debug_algorithm=false) | |
Constructor. More... | |
GreedySampler (Vector param_space_min, Vector param_space_max, int num_parameter_points, bool check_local_rom, double relative_error_tolerance, double alpha, double max_clamp, int subset_size, int convergence_subset_size, std::string output_log_path="", std::string warm_start_file_name="", bool use_centroid=true, int random_seed=1, bool debug_algorithm=false) | |
Constructor. More... | |
GreedySampler (double param_space_min, double param_space_max, int num_parameter_points, bool check_local_rom, double relative_error_tolerance, double alpha, double max_clamp, int subset_size, int convergence_subset_size, std::string output_log_path="", std::string warm_start_file_name="", bool use_centroid=true, int random_seed=1, bool debug_algorithm=false) | |
Constructor. More... | |
GreedySampler (std::string base_file_name, std::string output_log_path="") | |
Constructor. More... | |
~GreedySampler () | |
Destructor. | |
std::shared_ptr< Vector > | getNextParameterPoint () |
Returns the next parameter point for which sampling is required. More... | |
struct GreedyErrorIndicatorPoint | getNextPointRequiringRelativeError () |
Returns the next parameter point for which a relative error is required. More... | |
struct GreedyErrorIndicatorPoint | getNextPointRequiringErrorIndicator () |
Returns the next parameter point for which an error indicator is required. More... | |
void | setPointRelativeError (double error) |
Set the relative error of the specified point. More... | |
void | setPointErrorIndicator (double error, int vec_size) |
Set the error indicator error of the specified parameter point. More... | |
int | getNearestNonSampledPoint (Vector point) |
Returns the index of the nearest non-sampled parameter point to the given point. More... | |
std::shared_ptr< Vector > | getNearestROM (Vector point) |
Returns the nearest local ROM to the specified parameter point. More... | |
std::vector< Vector > | getParameterPointDomain () |
Get the domain of the parameter points. More... | |
std::vector< Vector > | getSampledParameterPoints () |
Get the sampled parameter points. More... | |
virtual void | save (std::string base_file_name) |
Save the object state to a file. More... | |
bool | isComplete () |
Check if the greedy algorithm procedure is complete. More... | |
Protected Member Functions | |
void | constructParameterPoints () |
Construct the list of parameter point candidates to sample. | |
void | getNextParameterPointAfterConvergenceFailure () |
Get the next parameter point to sample after a convergence failure. | |
![]() | |
void | addDatabaseFromFile (std::string const &warm_start_file_name) |
Do a warm start by adding the sampled parameters from the database in a file to the current database. More... | |
virtual void | load (std::string base_file_name) |
Load the object state from a file. More... | |
void | checkParameterPointInput () |
Construct the list of parameter point candidates to sample. | |
void | constructObject (bool check_local_rom, double relative_error_tolerance, double alpha, double max_clamp, int subset_size, int convergence_subset_size, std::string output_log_path, bool use_centroid, int random_seed, bool debug_algorithm) |
Construct the GreedySampler object. | |
void | initializeParameterPoints () |
Initialize the list of parameter point candidates to sample. | |
struct GreedyErrorIndicatorPoint | getNextSubsetPointRequiringErrorIndicator () |
Get the next subset point requiring an error indicator. More... | |
struct GreedyErrorIndicatorPoint | getNextConvergencePointRequiringErrorIndicator () |
Get the next convergence point requiring an error indicator. More... | |
std::vector< Vector > | generateRandomPoints (int num_points) |
Generate a vector of random points. More... | |
void | agnosticPrint (std::string str) |
Print to output_log_file or cout. | |
void | printErrorIndicator (Vector errorIndicatorPoint, double proc_errors) |
Print the error indicator. More... | |
void | printErrorIndicatorToleranceNotMet () |
Print that the error indicator was not met. | |
void | printSamplingType (std::string sampling_type) |
Print the sampling type. More... | |
void | printConvergenceAchieved () |
Print that convergence was achieved. | |
void | setSubsetErrorIndicator (double proc_errors) |
Set the error indicator for a subset point. More... | |
void | setConvergenceErrorIndicator (double proc_errors) |
Set the error indicator for a convergence point. More... | |
void | generateConvergenceSubset () |
Generate a new set of convergence points. | |
void | startConvergence () |
Switch to convergence mode. | |
int | getNearestROMIndexToParameterPoint (int index, bool ignore_self) |
Returns the index to the nearest local ROM to the specified parameter point index in the parameter point list. More... | |
Additional Inherited Members | |
![]() | |
std::vector< Vector > | d_parameter_points |
The parameter points to explore. | |
std::vector< Vector > | d_convergence_points |
The convergence parameter points to explore. | |
Vector | d_min_param_point |
The minimum value of the parameter space. | |
Vector | d_max_param_point |
The maximum value of the parameter space. | |
std::set< int > | d_parameter_sampled_indices |
The parameter points that were already sampled. | |
std::vector< int > | d_parameter_point_random_indices |
The parameter point indices (used to generate the random subsets). | |
std::vector< double > | d_parameter_point_errors |
The current errors of the parameter points. | |
std::vector< int > | d_parameter_point_local_rom |
The local ROMs used to obtain the current errors of the parameter points. | |
std::string | d_output_log_path |
Output log path. | |
double | d_max_error |
The current max error of the parameter points of the current iteration. | |
double | d_curr_relative_error |
The current relative error of the current iteration. | |
double | d_alpha |
The alpha constant. | |
double | d_max_clamp |
The max_clamp constant. | |
double | d_error_indicator_tol |
The error indicator tolerance used to terminate the greedy procedure. | |
double | d_relative_error_tol |
The relative error tolerance used to terminate the greedy procedure. | |
int | d_num_parameter_points |
The maximum number of parameter points to sample. | |
int | d_subset_size |
The size of the subset of parameter points used per iteration. | |
int | d_convergence_subset_size |
The size of the subset of parameter points used to check convergence. | |
int | d_next_point_to_sample |
The next parameter point to sample. | |
int | d_next_point_requiring_error_indicator |
The next parameter point requiring a error indicator. | |
bool | d_use_centroid |
Whether the use the centroid heuristic for obtaining the first parameter point. | |
bool | d_check_local_rom |
Whether the check the last sampled local ROM's error indicator after each iteration. | |
bool | d_iteration_started |
Whether the database has already computed a new parameter point for the current iteration. | |
bool | d_convergence_started |
Whether the database is in the convergence verifying phase. | |
bool | d_next_parameter_point_computed |
Whether the database has already computed a new parameter point to sample. | |
bool | d_point_requiring_error_indicator_computed |
Whether the database has already computed a new paramter point requiring a error indicator. | |
bool | d_subset_created |
Whether the database has already created a random subset for this iteration. | |
bool | d_debug_algorithm |
Turn off randomness for debugging purposes. | |
int | d_counter |
An internal counter. | |
int | d_subset_counter |
An internal subset counter. | |
bool | d_procedure_completed |
Whether the greedy procedure has completed. | |
int | d_rank |
The rank of the given processor. | |
int | d_random_seed |
Then random seed used to generate subsets. | |
std::default_random_engine | rng |
Random engine used to generate subsets. | |
Class GreedyRandomSampler implements a variant of Choi et. al's greedy algorithm using pre-defined parameter points.
CAROM::GreedyCustomSampler::GreedyCustomSampler | ( | std::vector< Vector > | parameter_points, |
bool | check_local_rom, | ||
double | relative_error_tolerance, | ||
double | alpha, | ||
double | max_clamp, | ||
int | subset_size, | ||
int | convergence_subset_size, | ||
std::string | output_log_path = "" , |
||
std::string | warm_start_file_name = "" , |
||
bool | use_centroid = true , |
||
int | random_seed = 1 , |
||
bool | debug_algorithm = false |
||
) |
Constructor.
[in] | parameter_points | A vector of CAROM::Vectors containing the different parameter points. |
[in] | check_local_rom | Compute local ROM error indicator each iteration. |
[in] | relative_error_tolerance | The relative error tolerance value for which to end the algorithm. |
[in] | alpha | A alpha constant to increase greedy algorithm by each iteration. |
[in] | max_clamp | A scalar factor representing the maximum amount the error indicator tolerance can change per iteration. |
[in] | subset_size | The size of the random subset. |
[in] | convergence_subset_size | The size of the convergence subset. |
[in] | output_log_path | The path to the output log file. If not used, outputs to stdout. |
[in] | warm_start_file_name | The path to the HDF5 file of a previous database to use as a warm start. |
[in] | use_centroid | Whether to use the centroid heuristic when determining the first parameter point to sample. |
[in] | random_seed | A random seed. |
[in] | debug_algorithm | Whether to turn off all randomness for debugging purposes. |
CAROM::GreedyCustomSampler::GreedyCustomSampler | ( | std::vector< double > | parameter_points, |
bool | check_local_rom, | ||
double | relative_error_tolerance, | ||
double | alpha, | ||
double | max_clamp, | ||
int | subset_size, | ||
int | convergence_subset_size, | ||
std::string | output_log_path = "" , |
||
std::string | warm_start_file_name = "" , |
||
bool | use_centroid = true , |
||
int | random_seed = 1 , |
||
bool | debug_algorithm = false |
||
) |
Constructor.
[in] | parameter_points | A vector of doubles containing the different parameter points. |
[in] | check_local_rom | Compute local ROM error indicator each iteration. |
[in] | relative_error_tolerance | The relative error tolerance value for which to end the algorithm. |
[in] | alpha | A alpha constant to increase greedy algorithm by each iteration. |
[in] | max_clamp | A scalar factor representing the maximum amount the error indicator tolerance can change per iteration. |
[in] | subset_size | The size of the random subset. |
[in] | convergence_subset_size | The size of the convergence subset. |
[in] | output_log_path | The path to the output log file. If not used, outputs to stdout. |
[in] | warm_start_file_name | The path to the HDF5 file of a previous database to use as a warm start. |
[in] | use_centroid | Whether to use the centroid heuristic when determining the first parameter point to sample. |
[in] | random_seed | A random seed. |
[in] | debug_algorithm | Whether to turn off all randomness for debugging purposes. |
CAROM::GreedyCustomSampler::GreedyCustomSampler | ( | std::string | base_file_name, |
std::string | output_log_path = "" |
||
) |
Constructor.
[in] | base_file_name | The base part of the file of the database to load when restarting from a save. |
[in] | output_log_path | The path to the output log file. If not used, outputs to stdout. |