#include <GreedySampler.h>
Public Member Functions | |
| 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 | 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... | |
| virtual void | constructParameterPoints ()=0 |
| Construct the list of parameter point candidates to sample. | |
| 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. | |
| virtual void | getNextParameterPointAfterConvergenceFailure ()=0 |
| Get the next parameter point to sample after a convergence failure. | |
| 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... | |
Protected Attributes | |
| 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 GreedySampler is a class defining the interface of a greedy algorithm that given a domain of parameter points, iteratively returns the next best parameter point to sample in order to create a ROM database efficiently.
| CAROM::GreedySampler::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.
| [in] | parameter_points | A vector of CAROM::Vectors containing many user-defined parameter points from which a subset will be chosen for building ROMs. |
| [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 constant factor to increase the error indicator tolerance 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::GreedySampler::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.
| [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::GreedySampler::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.
| [in] | param_space_min | A CAROM::Vector representing the minimum of the parameter space domain. |
| [in] | param_space_max | A CAROM::Vector representing the maximum of the parameter space domain. |
| [in] | num_parameter_points | The maximum number of parameter points to sample. |
| [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::GreedySampler::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.
| [in] | param_space_min | A double representing the minimum of the parameter space domain. |
| [in] | param_space_max | A double representing the maximum of the parameter space domain. |
| [in] | num_parameter_points | The maximum number of parameter points to sample. |
| [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::GreedySampler::GreedySampler | ( | 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. |
|
protected |
Do a warm start by adding the sampled parameters from the database in a file to the current database.
| [in] | warm_start_file_name | The path to the HDF5 file of a previous database to use as a warm start. |
|
protected |
Generate a vector of random points.
| [in] | num_points | The number of points to generate |
| int CAROM::GreedySampler::getNearestNonSampledPoint | ( | Vector | point | ) |
Returns the index of the nearest non-sampled parameter point to the given point.
| [in] | point | The CAROM::Vector holding the point. |
Returns the nearest local ROM to the specified parameter point.
| [in] | point | The CAROM::Vector holding the point. |
|
protected |
Returns the index to the nearest local ROM to the specified parameter point index in the parameter point list.
| [in] | index | The index of the specified parameter point. |
| [in] | ignore_self | Whether to ignore the specified parameter point if a local ROM was built there. |
|
protected |
Get the next convergence point requiring an error indicator.
| std::shared_ptr<Vector> CAROM::GreedySampler::getNextParameterPoint | ( | ) |
Returns the next parameter point for which sampling is required.
| struct GreedyErrorIndicatorPoint CAROM::GreedySampler::getNextPointRequiringErrorIndicator | ( | ) |
Returns the next parameter point for which an error indicator is required.
| struct GreedyErrorIndicatorPoint CAROM::GreedySampler::getNextPointRequiringRelativeError | ( | ) |
Returns the next parameter point for which a relative error is required.
|
protected |
Get the next subset point requiring an error indicator.
| std::vector<Vector> CAROM::GreedySampler::getParameterPointDomain | ( | ) |
Get the domain of the parameter points.
| std::vector<Vector> CAROM::GreedySampler::getSampledParameterPoints | ( | ) |
Get the sampled parameter points.
| bool CAROM::GreedySampler::isComplete | ( | ) |
Check if the greedy algorithm procedure is complete.
|
protectedvirtual |
Load the object state from a file.
| [in] | base_file_name | The base part of the file to load the database from. |
Reimplemented in CAROM::GreedyRandomSampler.
|
protected |
Print the error indicator.
| [in] | errorIndicatorPoint | The vector where the error indicator was obtained. |
| [in] | proc_errors | The error indicator value. |
|
protected |
Print the sampling type.
| [in] | sampling_type | The sampling type. |
|
virtual |
Save the object state to a file.
| [in] | base_file_name | The base part of the file to save the database to. |
Reimplemented in CAROM::GreedyRandomSampler.
|
protected |
Set the error indicator for a convergence point.
| [in] | proc_errors | The error indicator value. |
| void CAROM::GreedySampler::setPointErrorIndicator | ( | double | error, |
| int | vec_size | ||
| ) |
Set the error indicator error of the specified parameter point.
| [in] | error | The error indicator value. |
| [in] | vec_size | The size of the vector the error indicator was obtained from. This is used for normalization. |
| void CAROM::GreedySampler::setPointRelativeError | ( | double | error | ) |
Set the relative error of the specified point.
| [in] | error | The relative error. |
|
protected |
Set the error indicator for a subset point.
| [in] | proc_errors | The error indicator value. |
1.8.5