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

Base class for the interface class hierarchy. More...

Inheritance diagram for Interface:
ApplicationInterface ApproximationInterface DirectApplicInterface ProcessApplicInterface MatlabInterface PythonInterface ScilabInterface TestDriverInterface ParallelDirectApplicInterface SerialDirectApplicInterface ProcessHandleApplicInterface SysCallApplicInterface

Public Member Functions

 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 void map (const Variables &vars, const ActiveSet &set, Response &response, bool asynch_flag=false)
 the function evaluator: provides a "mapping" from the variables to the responses.
 
virtual const IntResponseMap & synch ()
 recovers data from a series of asynchronous evaluations (blocking)
 
virtual const IntResponseMap & synch_nowait ()
 recovers data from a series of asynchronous evaluations (nonblocking)
 
virtual void serve_evaluations ()
 evaluation server function for multiprocessor executions
 
virtual void stop_evaluation_servers ()
 send messages from iterator rank 0 to terminate evaluation servers
 
virtual 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.
 
virtual 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).
 
virtual void init_serial ()
 reset certain defaults for serial interface objects.
 
virtual int asynch_local_evaluation_concurrency () const
 return the user-specified concurrency for asynch local evaluations
 
virtual short interface_synchronization () const
 return the user-specified interface synchronization
 
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
 
virtual const StringArray & analysis_drivers () const
 retrieve the analysis drivers specification for application interfaces
 
virtual bool evaluation_cache () const
 return flag indicating usage of the global evaluation cache
 
virtual void file_cleanup () const
 clean up any interface parameter/response files when aborting
 
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

 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
 

Protected Attributes

unsigned short interfaceType
 the interface type: enum for system, fork, direct, grid, or approximation
 
String interfaceId
 the interface specification identifier string from the DAKOTA input file
 
bool algebraicMappings
 flag for the presence of algebraic_mappings that define the subset of an Interface's parameter to response mapping that is explicit and algebraic.
 
bool coreMappings
 flag for the presence of non-algebraic mappings that define the core of an Interface's parameter to response mapping (using analysis_drivers for ApplicationInterface or functionSurfaces for ApproximationInterface).
 
short outputLevel
 output verbosity level: {SILENT,QUIET,NORMAL,VERBOSE,DEBUG}_OUTPUT
 
int currEvalId
 identifier for the current evaluation, which may differ from the evaluation counters in the case of evaluation scheduling; used on iterator master as well as server processors. Currently, this is set prior to all invocations of derived_map() for all processors.
 
bool fineGrainEvalCounters
 controls use of fn val/grad/hess counters for detailed evaluation report
 
int evalIdCntr
 total interface evaluation counter
 
int newEvalIdCntr
 new (non-duplicate) interface evaluation counter
 
int evalIdRefPt
 iteration reference point for evalIdCntr
 
int newEvalIdRefPt
 iteration reference point for newEvalIdCntr
 
IntArray fnValCounter
 number of value evaluations by resp fn
 
IntArray fnGradCounter
 number of gradient evaluations by resp fn
 
IntArray fnHessCounter
 number of Hessian evaluations by resp fn
 
IntArray newFnValCounter
 number of new value evaluations by resp fn
 
IntArray newFnGradCounter
 number of new gradient evaluations by resp fn
 
IntArray newFnHessCounter
 number of new Hessian evaluations by resp fn
 
IntArray fnValRefPt
 iteration reference point for fnValCounter
 
IntArray fnGradRefPt
 iteration reference point for fnGradCounter
 
IntArray fnHessRefPt
 iteration reference point for fnHessCounter
 
IntArray newFnValRefPt
 iteration reference point for newFnValCounter
 
IntArray newFnGradRefPt
 iteration reference point for newFnGradCounter
 
IntArray newFnHessRefPt
 iteration reference point for newFnHessCounter
 
IntResponseMap rawResponseMap
 Set of responses returned after either a blocking or nonblocking schedule of asynchronous evaluations. More...
 
StringArray fnLabels
 response function descriptors (used in print_evaluation_summary() and derived direct interface classes); initialized in map() functions due to potential updates after construction
 
bool multiProcEvalFlag
 flag for multiprocessor evaluation partitions (evalComm)
 
bool ieDedMasterFlag
 flag for dedicated master partitioning at the iterator level
 
String evalTagPrefix
 set of period-delimited evaluation ID tags to use in evaluation tagging
 
bool appendIfaceId
 whether to append the interface ID to the prefix during map (default true)
 

Private Member Functions

Interfaceget_interface (ProblemDescDB &problem_db)
 Used by the envelope to instantiate the correct letter class. More...
 
int algebraic_function_type (String)
 Used by algebraic mappings to determine the correct AMPL function evaluation call to make.
 

Private Attributes

StringArray algebraicVarTags
 set of variable tags from AMPL stub.col
 
SizetArray algebraicACVIndices
 set of indices mapping AMPL algebraic variables to DAKOTA all continuous variables
 
SizetArray algebraicACVIds
 set of ids mapping AMPL algebraic variables to DAKOTA all continuous variables
 
StringArray algebraicFnTags
 set of function tags from AMPL stub.row
 
IntArray algebraicFnTypes
 function type: > 0 = objective, < 0 = constraint |value|-1 is the objective (constraint) index when making AMPL objval (conival) calls
 
SizetArray algebraicFnIndices
 set of indices mapping AMPL algebraic objective functions to DAKOTA response functions
 
RealArray algebraicConstraintWeights
 set of weights for computing Hessian matrices for algebraic constraints;
 
int numAlgebraicResponses
 number of algebraic responses (objectives+constraints)
 
InterfaceinterfaceRep
 pointer to the letter (initialized only for the envelope)
 
int referenceCount
 number of objects sharing interfaceRep
 
ASL * asl
 pointer to an AMPL solver library (ASL) object
 

Detailed Description

Base class for the interface class hierarchy.

The Interface class hierarchy provides the part of a Model that is responsible for mapping a set of Variables into a set of Responses. The mapping is performed using either a simulation-based application interface or a surrogate-based approximation interface. For memory efficiency and enhanced polymorphism, the interface hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (Interface) serves as the envelope and one of the derived classes (selected in Interface::get_interface()) serves as the letter.

Constructor & Destructor Documentation

Interface ( )

default constructor

used in Model envelope class instantiations

Interface ( ProblemDescDB problem_db)

standard constructor for envelope

Used in Model instantiation to build the envelope. This constructor only needs to extract enough data to properly execute get_interface, since Interface::Interface(BaseConstructor, problem_db) builds the actual base class data inherited by the derived interfaces.

References Dakota::abort_handler(), Interface::get_interface(), and Interface::interfaceRep.

Interface ( const Interface interface_in)

copy constructor

Copy constructor manages sharing of interfaceRep and incrementing of referenceCount.

References Interface::interfaceRep, and Interface::referenceCount.

~Interface ( )
virtual

destructor

Destructor decrements referenceCount and only deletes interfaceRep if referenceCount is zero.

References Interface::interfaceRep, and Interface::referenceCount.

Interface ( BaseConstructor  ,
const ProblemDescDB problem_db 
)
protected

constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)

This constructor is the one which must build the base class data for all inherited interfaces. get_interface() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid the recursion of the base class constructor calling get_interface() again). Since this is the letter and the letter IS the representation, interfaceRep is set to NULL (an uninitialized pointer causes problems in ~Interface).

References Dakota::abort_handler(), Interface::algebraic_function_type(), Interface::algebraicConstraintWeights, Interface::algebraicFnTags, Interface::algebraicFnTypes, Interface::algebraicMappings, Interface::algebraicVarTags, Interface::asl, ProblemDescDB::get_string(), Interface::outputLevel, and Dakota::strends().

Member Function Documentation

Interface operator= ( const Interface interface_in)

assignment operator

Assignment operator decrements referenceCount for old interfaceRep, assigns new interfaceRep, and increments referenceCount for new interfaceRep.

References Interface::interfaceRep, and Interface::referenceCount.

void assign_rep ( Interface interface_rep,
bool  ref_count_incr = true 
)

assign letter or replace existing letter with a new one

Similar to the assignment operator, the assign_rep() function decrements referenceCount for the old interfaceRep and assigns the new interfaceRep. It is different in that it is used for publishing derived class letters to existing envelopes, as opposed to sharing representations among multiple envelopes (in particular, assign_rep is passed a letter object and operator= is passed an envelope object). Letter assignment supports two models as governed by ref_count_incr:

  • ref_count_incr = true (default): the incoming letter belongs to another envelope. In this case, increment the reference count in the normal manner so that deallocation of the letter is handled properly.
  • ref_count_incr = false: the incoming letter is instantiated on the fly and has no envelope. This case is modeled after get_interface(): a letter is dynamically allocated using new and passed into assign_rep, the letter's reference count is not incremented, and the letter is not remotely deleted (its memory management is passed over to the envelope).

References Dakota::abort_handler(), Interface::interfaceRep, and Interface::referenceCount.

Referenced by DataFitSurrModel::DataFitSurrModel(), parallel_interface_plugin(), LibraryEnvironment::plugin_interface(), and run_dakota().

void eval_tag_prefix ( const String &  eval_id_str,
bool  append_iface_id = true 
)

set the evaluation tag prefix (does not recurse)

default implementation just sets the list of eval ID tags; derived classes containing additional models or interfaces should override (currently no use cases)

References Interface::appendIfaceId, Interface::eval_tag_prefix(), Interface::evalTagPrefix, and Interface::interfaceRep.

Referenced by NestedModel::derived_evaluate(), SimulationModel::eval_tag_prefix(), and Interface::eval_tag_prefix().

void response_mapping ( const Response algebraic_response,
const Response core_response,
Response total_response 
)
protected
Interface * get_interface ( ProblemDescDB problem_db)
private

Used by the envelope to instantiate the correct letter class.

used only by the envelope constructor to initialize interfaceRep to the appropriate derived type.

References ProblemDescDB::get_string(), ProblemDescDB::get_ushort(), and Interface::interface_type().

Referenced by Interface::Interface().

Member Data Documentation

IntResponseMap rawResponseMap
protected

Set of responses returned after either a blocking or nonblocking schedule of asynchronous evaluations.

The map is a full/partial set of completions which are identified through their evalIdCntr key. The raw set is postprocessed (i.e., finite diff grads merged) in Model::synchronize() where it becomes responseMap.

Referenced by ApplicationInterface::asynchronous_local_evaluations(), ApplicationInterface::process_asynch_local(), ApplicationInterface::process_synch_local(), ApplicationInterface::receive_evaluation(), ApplicationInterface::synch(), ApproximationInterface::synch(), ApplicationInterface::synch_nowait(), ApproximationInterface::synch_nowait(), ApplicationInterface::test_local_backfill(), and ApplicationInterface::test_receives_backfill().


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