Dakota  Version 6.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
SysCallApplicInterface Class Reference

Derived application interface class which spawns simulation codes using system calls. More...

Inheritance diagram for SysCallApplicInterface:
ProcessApplicInterface ApplicationInterface Interface GridApplicInterface

Public Member Functions

 SysCallApplicInterface (const ProblemDescDB &problem_db)
 constructor
 
 ~SysCallApplicInterface ()
 destructor
 
- Public Member Functions inherited from ProcessApplicInterface
 ProcessApplicInterface (const ProblemDescDB &problem_db)
 constructor
 
 ~ProcessApplicInterface ()
 destructor
 
- Public Member Functions inherited from ApplicationInterface
 ApplicationInterface (const ProblemDescDB &problem_db)
 constructor
 
 ~ApplicationInterface ()
 destructor
 
- Public Member Functions inherited from Interface
 Interface ()
 default constructor More...
 
 Interface (ProblemDescDB &problem_db)
 standard constructor for envelope More...
 
 Interface (const Interface &interface_in)
 copy constructor More...
 
virtual ~Interface ()
 destructor More...
 
Interface operator= (const Interface &interface_in)
 assignment operator More...
 
virtual int minimum_points (bool constraint_flag) const
 returns the minimum number of points required to build a particular ApproximationInterface (used by DataFitSurrModels).
 
virtual int recommended_points (bool constraint_flag) const
 returns the recommended number of points required to build a particular ApproximationInterface (used by DataFitSurrModels).
 
virtual void approximation_function_indices (const IntSet &approx_fn_indices)
 set the (currently active) approximation function index set
 
virtual void update_approximation (const Variables &vars, const IntResponsePair &response_pr)
 updates the anchor point for an approximation
 
virtual void update_approximation (const RealMatrix &samples, const IntResponseMap &resp_map)
 updates the current data points for an approximation
 
virtual void update_approximation (const VariablesArray &vars_array, const IntResponseMap &resp_map)
 updates the current data points for an approximation
 
virtual void append_approximation (const Variables &vars, const IntResponsePair &response_pr)
 appends a single point to an existing approximation
 
virtual void append_approximation (const RealMatrix &samples, const IntResponseMap &resp_map)
 appends multiple points to an existing approximation
 
virtual void append_approximation (const VariablesArray &vars_array, const IntResponseMap &resp_map)
 appends multiple points to an existing approximation
 
virtual void build_approximation (const RealVector &c_l_bnds, const RealVector &c_u_bnds, const IntVector &di_l_bnds, const IntVector &di_u_bnds, const RealVector &dr_l_bnds, const RealVector &dr_u_bnds)
 builds the approximation
 
virtual void export_approximation ()
 export the approximation to disk
 
virtual void rebuild_approximation (const BoolDeque &rebuild_deque)
 rebuilds the approximation after a data update
 
virtual void pop_approximation (bool save_surr_data)
 removes data from last append from the approximation
 
virtual void push_approximation ()
 retrieves approximation data from a previous state (negates pop)
 
virtual bool push_available ()
 queries the approximation for the ability to retrieve a previous increment
 
virtual void finalize_approximation ()
 finalizes the approximation by applying all trial increments
 
virtual void store_approximation (size_t index=_NPOS)
 move the current approximation into storage for later combination; the index of the stored approximation can be passed to allow replacement instead of augmentation (default is push_back)
 
virtual void restore_approximation (size_t index=_NPOS)
 return an approximation from storage; the index identifies a particular stored data set (default is pop_back from stored)
 
virtual void remove_stored_approximation (size_t index=_NPOS)
 remove a stored approximation, due to redundancy with the current approximation, prior to combination (default for no index is pop_back)
 
virtual void combine_approximation (short corr_type)
 combine the current approximation with previously stored data sets
 
virtual Real2DArray cv_diagnostics (const StringArray &metric_types, unsigned num_folds)
 approximation cross-validation quality metrics per response function
 
virtual RealArray challenge_diagnostics (const String &metric_type, const RealMatrix &challenge_pts)
 approximation challenge data metrics per response function
 
virtual void clear_current ()
 clears current data from an approximation interface
 
virtual void clear_all ()
 clears all data from an approximation interface
 
virtual void clear_popped ()
 clears bookkeeping for popped data sets from an approximation interface
 
virtual SharedApproxDatashared_approximation ()
 retrieve the SharedApproxData within an ApproximationInterface
 
virtual std::vector
< Approximation > & 
approximations ()
 retrieve the Approximations within an ApproximationInterface
 
virtual const
Pecos::SurrogateData & 
approximation_data (size_t index)
 retrieve the approximation data from a particular Approximation within an ApproximationInterface
 
virtual const RealVectorArray & approximation_coefficients (bool normalized=false)
 retrieve the approximation coefficients from each Approximation within an ApproximationInterface
 
virtual void approximation_coefficients (const RealVectorArray &approx_coeffs, bool normalized=false)
 set the approximation coefficients within each Approximation within an ApproximationInterface
 
virtual const RealVector & approximation_variances (const Variables &vars)
 retrieve the approximation variances from each Approximation within an ApproximationInterface
 
void assign_rep (Interface *interface_rep, bool ref_count_incr=true)
 assign letter or replace existing letter with a new one More...
 
unsigned short interface_type () const
 returns the interface type
 
const String & interface_id () const
 returns the interface identifier
 
int evaluation_id () const
 returns the value of the (total) evaluation id counter for the interface
 
void fine_grained_evaluation_counters (size_t num_fns)
 set fineGrainEvalCounters to true and initialize counters if needed
 
void init_evaluation_counters (size_t num_fns)
 initialize fine grained evaluation counters, sizing if needed
 
void set_evaluation_reference ()
 set evaluation count reference points for the interface
 
void print_evaluation_summary (std::ostream &s, bool minimal_header, bool relative_count) const
 print an evaluation summary for the interface
 
bool multi_proc_eval () const
 returns a flag signaling the use of multiprocessor evaluation partitions
 
bool iterator_eval_dedicated_master () const
 returns a flag signaling the use of a dedicated master processor at the iterator-evaluation scheduling level
 
bool is_null () const
 function to check interfaceRep (does this envelope contain a letter?)
 
void eval_tag_prefix (const String &eval_id_str, bool append_iface_id=true)
 set the evaluation tag prefix (does not recurse) More...
 

Protected Member Functions

void wait_local_evaluations (PRPQueue &prp_queue)
 
void test_local_evaluations (PRPQueue &prp_queue)
 
int synchronous_local_analysis (int analysis_id)
 
void init_communicators_checks (int max_eval_concurrency)
 
void set_communicators_checks (int max_eval_concurrency)
 
void map_bookkeeping (pid_t pid, int fn_eval_id)
 bookkeeping of process and evaluation ids for asynchronous maps
 
pid_t create_evaluation_process (bool block_flag)
 Spawn the evaluation by managing the input filter, analysis drivers, and output filter. Called from derived_map() & derived_map_asynch().
 
- Protected Member Functions inherited from ProcessApplicInterface
void derived_map (const Variables &vars, const ActiveSet &set, Response &response, int fn_eval_id)
 Called by map() and other functions to execute the simulation in synchronous mode. The portion of performing an evaluation that is specific to a derived class.
 
void derived_map_asynch (const ParamResponsePair &pair)
 Called by map() and other functions to execute the simulation in asynchronous mode. The portion of performing an asynchronous evaluation that is specific to a derived class.
 
const StringArray & analysis_drivers () const
 retrieve the analysis drivers specification for application interfaces
 
void file_cleanup () const
 
void remove_params_results_files (const bfs::path &params_path, const bfs::path &results_path) const
 Remove (potentially autotagged for multiple programs) parameters and results files with passed root names.
 
void autotag_files (const bfs::path &params_path, const bfs::path &results_path, const String &eval_id_tag) const
 Utility to automatically tag parameters and results files with passed root names (the files may already need per-program tagging) More...
 
void synchronous_local_analyses (int start, int end, int step)
 execute analyses synchronously on the local processor More...
 
void define_filenames (const String &eval_id_tag)
 define modified filenames from user input by handling Unix temp file and optionally tagging with given eval_id_tag
 
void write_parameters_files (const Variables &vars, const ActiveSet &set, const Response &response, const int id)
 write the parameters data and response request data to one or more parameters files (using one or more invocations of write_parameters_file()) in either standard or aprepro format
 
void read_results_files (Response &response, const int id, const String &eval_id_tag)
 read the response object from one or more results files using full eval_id_tag passed
 
bfs::path get_workdir_name ()
 construct a work directory name (tmp or named), with optional tag
 
void prepare_process_environment ()
 set PATH, environment variables, and change directory prior to fork/system/spawn More...
 
void reset_process_environment ()
 reset PATH and current directory after system/spawn (workdir case) More...
 
- Protected Member Functions inherited from ApplicationInterface
void init_communicators (const IntArray &message_lengths, int max_eval_concurrency)
 allocate communicator partitions for concurrent evaluations within an iterator and concurrent multiprocessor analyses within an evaluation.
 
void set_communicators (const IntArray &message_lengths, int max_eval_concurrency)
 set the local parallel partition data for an interface (the partitions are already allocated in ParallelLibrary).
 
void init_serial ()
 
int asynch_local_evaluation_concurrency () const
 return asynchLocalEvalConcurrency
 
short interface_synchronization () const
 return interfaceSynchronization
 
bool evaluation_cache () const
 return evalCacheFlag
 
void map (const Variables &vars, const ActiveSet &set, Response &response, bool asynch_flag=false)
 Provides a "mapping" of variables to responses using a simulation. Protected due to Interface letter-envelope idiom. More...
 
void manage_failure (const Variables &vars, const ActiveSet &set, Response &response, int failed_eval_id)
 manages a simulation failure using abort/retry/recover/continuation
 
const IntResponseMap & synch ()
 executes a blocking schedule for asynchronous evaluations in the beforeSynchCorePRPQueue and returns all jobs More...
 
const IntResponseMap & synch_nowait ()
 executes a nonblocking schedule for asynchronous evaluations in the beforeSynchCorePRPQueue and returns a partial set of completed jobs More...
 
void serve_evaluations ()
 run on evaluation servers to serve the iterator master More...
 
void stop_evaluation_servers ()
 used by the iterator master to terminate evaluation servers More...
 
bool check_multiprocessor_analysis (bool warn)
 checks on multiprocessor analysis configuration
 
bool check_asynchronous (bool warn, int max_eval_concurrency)
 checks on asynchronous configuration (for direct interfaces)
 
bool check_multiprocessor_asynchronous (bool warn, int max_eval_concurrency)
 checks on asynchronous settings for multiprocessor partitions
 
void master_dynamic_schedule_analyses ()
 blocking dynamic schedule of all analyses within a function evaluation using message passing More...
 
void serve_analyses_synch ()
 serve the master analysis scheduler and manage one synchronous analysis job at a time More...
 
- Protected Member Functions inherited from Interface
 Interface (BaseConstructor, const ProblemDescDB &problem_db)
 constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139) More...
 
 Interface (NoDBBaseConstructor, size_t num_fns, short output_level)
 constructor initializes the base class part of letter classes (NoDBBaseConstructor used for on the fly instantiations without a DB)
 
void init_algebraic_mappings (const Variables &vars, const Response &response)
 Define algebraicACVIndices, algebraicACVIds, and algebraicFnIndices.
 
void asv_mapping (const ActiveSet &total_set, ActiveSet &algebraic_set, ActiveSet &core_set)
 define the evaluation requirements for algebraic_mappings() (algebraic_set) and the core Application/Approximation mapping (core_set) from the total Interface evaluation requirements (total_set)
 
void asv_mapping (const ActiveSet &algebraic_set, ActiveSet &total_set)
 map an algebraic ASV back to original total ordering for asynch recovery
 
void algebraic_mappings (const Variables &vars, const ActiveSet &algebraic_set, Response &algebraic_response)
 evaluate the algebraic_response using the AMPL solver library and the data extracted from the algebraic_mappings file
 
void response_mapping (const Response &algebraic_response, const Response &core_response, Response &total_response)
 combine the response from algebraic_mappings() with the response from derived_map() to create the total response More...
 
String final_eval_id_tag (int fn_eval_id)
 form and return the final evaluation ID tag, appending iface ID if needed
 

Private Member Functions

bool system_call_file_test (const bfs::path &root_file)
 detect completion of a function evaluation through existence of the necessary results file(s)
 
void spawn_evaluation_to_shell (bool block_flag)
 spawn a complete function evaluation More...
 
void spawn_input_filter_to_shell (bool block_flag)
 spawn the input filter portion of a function evaluation More...
 
void spawn_analysis_to_shell (int analysis_id, bool block_flag)
 spawn a single analysis as part of a function evaluation More...
 
void spawn_output_filter_to_shell (bool block_flag)
 spawn the output filter portion of a function evaluation More...
 

Private Attributes

IntSet sysCallSet
 set of function evaluation id's for active asynchronous system call evaluations
 
IntShortMap failCountMap
 map linking function evaluation id's to number of response read failures
 

Additional Inherited Members

- Protected Attributes inherited from ProcessApplicInterface
bool fileTagFlag
 flags tagging of parameter/results files
 
bool fileSaveFlag
 flags retention of parameter/results files
 
bool commandLineArgs
 flag indicating use of passing of filenames as command line arguments to the analysis drivers and input/output filters
 
bool apreproFlag
 flag indicating use of the APREPRO (the Sandia "A PRE PROcessor" utility) format for parameter files
 
unsigned short resultsFileFormat
 results file format
 
bool multipleParamsFiles
 flag indicating the need for separate parameters files for multiple analysis drivers
 
std::string iFilterName
 the name of the input filter (input_filter user specification)
 
std::string oFilterName
 the name of the output filter (output_filter user specification)
 
std::vector< String > programNames
 the names of the analysis code programs (analysis_drivers user specification)
 
std::string specifiedParamsFileName
 the name of the parameters file from user specification
 
std::string paramsFileName
 the parameters file name actually used (modified with tagging or temp files); only valid from define_filenames to write_parameters_files
 
std::string paramsFileWritten
 actual, qualified name of the params file written, possibly with workdir
 
std::string specifiedResultsFileName
 the name of the results file from user specification
 
std::string resultsFileName
 the results file name actually used (modified with tagging or temp files); only valid from define_filenames to write_parameters_files
 
std::string resultsFileWritten
 actual, qualified name of the results file written, possibly with workdir
 
std::string fullEvalId
 complete evalIdTag, possibly including hierarchical tagging and final eval id, but not program numbers, for passing to write_parameters_files
 
bool allowExistingResults
 by default analysis code interfaces delete results files if they exist; user may override with this flag and we'll try to gather and only fork if needed
 
std::map< int, PathTriplefileNameMap
 Maps function evaluation ID to triples (parameters, results, and workdir) paths used in spawning function evaluations. Workdir will be empty if not created specifically for this eval.
 
bool useWorkdir
 whether to use a work_directory
 
std::string workDirName
 work_directory name, if specified...
 
bool dirTag
 whether to tag the working directory
 
bool dirSave
 whether dir_save was specified
 
bfs::path curWorkdir
 active working directory for this evaluation; valid only from define_filenames to create_evaluation_process
 
bfs::path createdDir
 non-empty if created for this eval; valid only from define_filenames to write_parameters_files
 
StringArray linkFiles
 template directory (if specified)
 
StringArray copyFiles
 template files (if specified)
 
bool templateReplace
 whether to replace existing files
 

Detailed Description

Derived application interface class which spawns simulation codes using system calls.

system() is part of the C API and can be used on both Windows and Unix systems.

Member Function Documentation

void wait_local_evaluations ( PRPQueue &  prp_queue)
inlineprotectedvirtual

Check for completion of active asynch jobs (tracked with sysCallSet). Wait for at least one completion and complete all jobs that have returned. This satisifies a "fairness" principle, in the sense that a completed job will always be processed (whereas accepting only a single completion could always accept the same completion - the case of very inexpensive fn. evals. - and starve some servers).

Reimplemented from ApplicationInterface.

References ApplicationInterface::completionSet, and SysCallApplicInterface::test_local_evaluations().

void test_local_evaluations ( PRPQueue &  prp_queue)
protectedvirtual
int synchronous_local_analysis ( int  analysis_id)
inlineprotectedvirtual

This code provides the derived function used by ApplicationInterface::serve_analyses_synch().

Reimplemented from ApplicationInterface.

References SysCallApplicInterface::spawn_analysis_to_shell().

void init_communicators_checks ( int  max_eval_concurrency)
inlineprotectedvirtual

No derived interface plug-ins, so perform construct-time checks. However, process init issues as warnings since some contexts (e.g., HierarchSurrModel) initialize more configurations than will be used.

Reimplemented from ApplicationInterface.

References ApplicationInterface::check_multiprocessor_analysis().

void set_communicators_checks ( int  max_eval_concurrency)
inlineprotectedvirtual

Process run-time issues as hard errors.

Reimplemented from ApplicationInterface.

References Dakota::abort_handler(), and ApplicationInterface::check_multiprocessor_analysis().

void spawn_evaluation_to_shell ( bool  block_flag)
private
void spawn_input_filter_to_shell ( bool  block_flag)
private

spawn the input filter portion of a function evaluation

Put the input filter to the shell. This function is used when multiple analysis drivers are spread between processors. No need to check for a Null input filter, as this is checked externally. Use of nonblocking shells is supported in this fn, although its use is currently prevented externally.

References CommandShell::asynch_flag(), ProcessApplicInterface::commandLineArgs, Dakota::flush(), ProcessApplicInterface::iFilterName, ProcessApplicInterface::paramsFileName, ProcessApplicInterface::prepare_process_environment(), ProcessApplicInterface::reset_process_environment(), ProcessApplicInterface::resultsFileName, CommandShell::suppress_output_flag(), and ApplicationInterface::suppressOutput.

Referenced by SysCallApplicInterface::create_evaluation_process().

void spawn_analysis_to_shell ( int  analysis_id,
bool  block_flag 
)
private
void spawn_output_filter_to_shell ( bool  block_flag)
private

spawn the output filter portion of a function evaluation

Put the output filter to the shell. This function is used when multiple analysis drivers are spread between processors. No need to check for a Null output filter, as this is checked externally. Use of nonblocking shells is supported in this fn, although its use is currently prevented externally.

References CommandShell::asynch_flag(), ProcessApplicInterface::commandLineArgs, Dakota::flush(), ProcessApplicInterface::oFilterName, ProcessApplicInterface::paramsFileName, ProcessApplicInterface::prepare_process_environment(), ProcessApplicInterface::reset_process_environment(), ProcessApplicInterface::resultsFileName, CommandShell::suppress_output_flag(), and ApplicationInterface::suppressOutput.

Referenced by SysCallApplicInterface::create_evaluation_process().


The documentation for this class was generated from the following files: