OpenStudioCore:analysis
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Related Functions | List of all members
openstudio::analysis::Analysis Class Reference

#include <Analysis.hpp>

+ Inheritance diagram for openstudio::analysis::Analysis:

Public Member Functions

Constructors and Destructors
 Analysis (const std::string &name, const Problem &problem, const FileReferenceType &seedType)
 Constructor for an OSM or IDF analysis with seed model not yet specified. More...
 
 Analysis (const std::string &name, const Problem &problem, const FileReference &seed)
 Constructor for OSM analysis (weather file sepecified in seed model::Model). More...
 
 Analysis (const std::string &name, const Problem &problem, const FileReference &seed, const FileReference &weatherFile)
 Constructor for IDF analysis (specify weather file directly). More...
 
 Analysis (const std::string &name, const Problem &problem, const Algorithm &algorithm, const FileReference &seed)
 Constructor for OSM analysis (weather file sepecified in seed model::Model). More...
 
 Analysis (const std::string &name, const Problem &problem, const Algorithm &algorithm, const FileReference &seed, const FileReference &weatherFile)
 Constructor for IDF analysis (specify weather file directly). More...
 
 Analysis (const UUID &uuid, const UUID &versionUUID, const std::string &name, const std::string &displayName, const std::string &description, const Problem &problem, const boost::optional< Algorithm > &algorithm, const FileReference &seed, const boost::optional< FileReference > &weatherFile, const std::vector< DataPoint > &dataPoints, bool resultsAreInvalid, bool dataPointsAreInvalid)
 Constructor provided for deserialization; not for general use. More...
 
virtual ~Analysis ()
 
Getters and Queries
Problem problem () const
 
boost::optional< Algorithmalgorithm () const
 
FileReference seed () const
 Returns the FileReference that points to this analysis's seed model. More...
 
boost::optional< FileReference > weatherFile () const
 
std::vector< DataPointdataPoints () const
 Returns all DataPoints in this Analysis. More...
 
std::vector< DataPointdataPointsToQueue () const
 Returns all selected, incomplete DataPoints. More...
 
std::vector< DataPointcompleteDataPoints () const
 
std::vector< DataPointsuccessfulDataPoints () const
 
std::vector< DataPointfailedDataPoints () const
 
std::vector< DataPointdataPointsNeedingDetails () const
 Return all complete DataPoints with runType() == DataPointRunType::CloudDetailed and an empty directory(). More...
 
std::vector< DataPointgetDataPoints (const std::vector< QVariant > &variableValues) const
 Get the DataPoints with matching variableValues. More...
 
std::vector< DataPointgetDataPoints (const std::vector< boost::optional< Measure > > &measures) const
 Get the DataPoints defined by measures. More...
 
std::vector< DataPointgetDataPoints (const std::string &tag) const
 
boost::optional< DataPointgetDataPoint (const std::vector< Measure > &measures) const
 Get the DataPoint defined by measures, if it exists. More...
 
boost::optional< DataPointgetDataPointByUUID (const UUID &uuid) const
 
boost::optional< DataPointgetDataPointByUUID (const DataPoint &dataPoint) const
 
bool resultsAreInvalid () const
 Flag flips to true if underlying structure of analysis changes and there are any completeDataPoints(). More...
 
bool dataPointsAreInvalid () const
 Flag flips to true if structure of problem's variables changes and there are dataPoints(). More...
 
Setters
bool setProblem (Problem &problem)
 
bool setAlgorithm (Algorithm &algorithm)
 
void clearAlgorithm ()
 
bool setSeed (const FileReference &newSeed)
 Set seed to newSeed. More...
 
bool clearSeed (const FileReferenceType &seedType)
 Set seed to blank model of seedType. More...
 
bool setWeatherFile (const FileReference &newWeatherFile)
 
void clearWeatherFile ()
 
bool addDataPoint (DataPoint &dataPoint)
 Adds a DataPoint to this analysis and returns true if the data point is not already in the analysis and if not dataPointsAreInvalid. More...
 
bool addDataPoint (const std::vector< Measure > &measures)
 Adds a DataPoint to this analysis and returns true if measures are valid for problem(), the resulting DataPoint is not yet in this Analysis, and if not dataPointsAreInvalid. More...
 
bool removeDataPoint (const DataPoint &dataPoint)
 Removes dataPoint from this analysis. More...
 
void removeAllDataPoints ()
 Removes all dataPoints from this analysis, resets dataPointsAreInvalid flag, and reinitializes algorithm(), if it exists. More...
 
bool clearResults (DataPoint &dataPoint)
 Resets dataPoint to not point to any output data and to be incomplete and not failed. More...
 
void clearAllResults ()
 Resets all data points to not point to any output data and to be incomplete and not failed. More...
 
Actions
bool setDataPointRunInformation (DataPoint &dataPoint, const runmanager::Job &topLevelJob, const std::vector< openstudio::path > &dakotaParametersFiles)
 Sets run information on a DataPoint. More...
 
void updateDataPoint (DataPoint &dataPoint, const runmanager::Job &completedJob)
 Updates an existing DataPoint in this analysis. More...
 
void initializeDakotaAlgorithm (DakotaAlgorithm &dakotaAlgorithm, const runmanager::Job &dakotaJob)
 Register Dakota's restart file location so that the analysis can be restarted if necessary. More...
 
void updateDakotaAlgorithm (const runmanager::Job &completedDakotaJob)
 Updates the DakotaAlgorithm being used by this analysis. More...
 
void updateInputPathData (const openstudio::path &originalBase, const openstudio::path &newBase)
 Relocate input path data from originalBase to newBase. More...
 
- Public Member Functions inherited from openstudio::analysis::AnalysisObject
virtual ~AnalysisObject ()
 
AnalysisObject clone () const
 Deep copy. More...
 
std::string name () const
 
std::string displayName () const
 
std::string description () const
 
openstudio::UUID uuid () const
 
openstudio::UUID versionUUID () const
 
bool isDirty () const
 Returns true if this object has been changed since its dirty flag was last cleared. More...
 
bool operator== (const AnalysisObject &other) const
 Compare impls. More...
 
bool operator!= (const AnalysisObject &other) const
 
bool uuidEqual (const AnalysisObject &other) const
 
bool uuidAndVersionEqual (const AnalysisObject &other) const
 
boost::optional< AnalysisObjectparent () const
 
void setName (const std::string &newName)
 
void setDisplayName (const std::string &newDisplayName)
 
void setDescription (const std::string &newDescription)
 
bool clearDirtyFlag ()
 Call this method to reset the dirty flag of this object and all its children. More...
 
bool connect (const char *signal, const QObject *receiver, const char *slot, Qt::ConnectionType type=Qt::AutoConnection) const
 Connect signal from this AnalysisObject to slot on receiver. More...
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *slot=nullptr) const
 
template<typename T >
cast () const
 Cast to type T. More...
 
template<typename T >
boost::optional< T > optionalCast () const
 Cast to boost::optional<T>. More...
 

Related Functions

(Note that these are not member functions.)

typedef std::vector< AnalysisAnalysisVector
 
boost::optional< DakotaAlgorithmgetDakotaAlgorithm (const Analysis &analysis)
 
boost::optional
< OpenStudioAlgorithm
getOpenStudioAlgorithm (const Analysis &analysis)
 
typedef boost::optional< AnalysisOptionalAnalysis
 

Serialization

Methods to save to json format.

See AnalysisObject.hpp, openstudio::analysis::loadJSON for the de-serialization methods.

bool saveJSON (const openstudio::path &p, const AnalysisSerializationOptions &options, bool overwrite=false) const
 
std::ostream & toJSON (std::ostream &os, const AnalysisSerializationOptions &options) const
 
std::string toJSON (const AnalysisSerializationOptions &options) const
 
static boost::optional< AnalysisloadJSON (const openstudio::path &p, const openstudio::path &newProjectDir=openstudio::path())
 
static boost::optional< AnalysisloadJSON (std::istream &json, const openstudio::path &newProjectDir=openstudio::path())
 
static boost::optional< AnalysisloadJSON (const std::string &json, const openstudio::path &newProjectDir=openstudio::path())
 

Detailed Description

Analysis is a AnalysisObject that contains an entire analysis.

It is constructed from a Problem, an optional Algorithm, an optional seed FileReference (an OSM or IDF file), and an optional weather FileReference (needed for IDF seeds). Analysis::addDataPoint can be used to add custom (not dictated by an Algorithm) DataPoints to the Analysis. (Note that new DataPoints should be created using Problem::createDataPoint.) An analysisdriver::AnalysisDriver can be used to run the Analysis.

Constructor & Destructor Documentation

openstudio::analysis::Analysis::Analysis ( const std::string &  name,
const Problem problem,
const FileReferenceType &  seedType 
)

Constructor for an OSM or IDF analysis with seed model not yet specified.

If the seed model is never specified before the analysis is run, the AnalysisDriver will create a blank energy model of seedType (must be OSM or IDF) to serve as a default starting point.

openstudio::analysis::Analysis::Analysis ( const std::string &  name,
const Problem problem,
const FileReference &  seed 
)

Constructor for OSM analysis (weather file sepecified in seed model::Model).

As no algorithm is specified, the user must add incomplete DataPoints by hand. A call to analysisdriver::AnalysisDriver::run will then run these custom points.

openstudio::analysis::Analysis::Analysis ( const std::string &  name,
const Problem problem,
const FileReference &  seed,
const FileReference &  weatherFile 
)

Constructor for IDF analysis (specify weather file directly).

As no algorithm is specified, the user must add incomplete DataPoints by hand. A call to analysisdriver::AnalysisDriver::run will then run these custom points.

openstudio::analysis::Analysis::Analysis ( const std::string &  name,
const Problem problem,
const Algorithm algorithm,
const FileReference &  seed 
)

Constructor for OSM analysis (weather file sepecified in seed model::Model).

Algorithm is used to populate the Analysis with incomplete DataPoints , either automatically using analysisdriver::AnalysisDriver, or with a user call to OpenStudioAlgorithm::createNextIteration.

openstudio::analysis::Analysis::Analysis ( const std::string &  name,
const Problem problem,
const Algorithm algorithm,
const FileReference &  seed,
const FileReference &  weatherFile 
)

Constructor for IDF analysis (specify weather file directly).

Algorithm is used to populate the Analysis with incomplete DataPoints , either automatically using analysisdriver::AnalysisDriver, or with a user call to Algorithm::createNextIteration.

openstudio::analysis::Analysis::Analysis ( const UUID &  uuid,
const UUID &  versionUUID,
const std::string &  name,
const std::string &  displayName,
const std::string &  description,
const Problem problem,
const boost::optional< Algorithm > &  algorithm,
const FileReference &  seed,
const boost::optional< FileReference > &  weatherFile,
const std::vector< DataPoint > &  dataPoints,
bool  resultsAreInvalid,
bool  dataPointsAreInvalid 
)

Constructor provided for deserialization; not for general use.

virtual openstudio::analysis::Analysis::~Analysis ( )
inlinevirtual

Member Function Documentation

bool openstudio::analysis::Analysis::addDataPoint ( DataPoint dataPoint)

Adds a DataPoint to this analysis and returns true if the data point is not already in the analysis and if not dataPointsAreInvalid.

Returns false otherwise. Throws an openstudio::Exception if dataPoint.variableValues() are not valid for problem(). Should be called before running a given workflow. Usually called by Algorithm, but may also be called directly by a user to run custom analyses.

bool openstudio::analysis::Analysis::addDataPoint ( const std::vector< Measure > &  measures)

Adds a DataPoint to this analysis and returns true if measures are valid for problem(), the resulting DataPoint is not yet in this Analysis, and if not dataPointsAreInvalid.

boost::optional<Algorithm> openstudio::analysis::Analysis::algorithm ( ) const
void openstudio::analysis::Analysis::clearAlgorithm ( )
void openstudio::analysis::Analysis::clearAllResults ( )

Resets all data points to not point to any output data and to be incomplete and not failed.

bool openstudio::analysis::Analysis::clearResults ( DataPoint dataPoint)

Resets dataPoint to not point to any output data and to be incomplete and not failed.

bool openstudio::analysis::Analysis::clearSeed ( const FileReferenceType &  seedType)

Set seed to blank model of seedType.

Fails if seedType is not OSM or IDF or is incompatible with current data.

void openstudio::analysis::Analysis::clearWeatherFile ( )
std::vector<DataPoint> openstudio::analysis::Analysis::completeDataPoints ( ) const
std::vector<DataPoint> openstudio::analysis::Analysis::dataPoints ( ) const

Returns all DataPoints in this Analysis.

bool openstudio::analysis::Analysis::dataPointsAreInvalid ( ) const

Flag flips to true if structure of problem's variables changes and there are dataPoints().

New data points cannot be added when analysis is in this state (dataPointsAreInvalid() == true).

std::vector<DataPoint> openstudio::analysis::Analysis::dataPointsNeedingDetails ( ) const

Return all complete DataPoints with runType() == DataPointRunType::CloudDetailed and an empty directory().

std::vector<DataPoint> openstudio::analysis::Analysis::dataPointsToQueue ( ) const

Returns all selected, incomplete DataPoints.

std::vector<DataPoint> openstudio::analysis::Analysis::failedDataPoints ( ) const
boost::optional<DataPoint> openstudio::analysis::Analysis::getDataPoint ( const std::vector< Measure > &  measures) const

Get the DataPoint defined by measures, if it exists.

Similar to getDataPoints, but without accepting boost::optionals on input (and therefore SWIG-friendlier, but more limited in use).

boost::optional<DataPoint> openstudio::analysis::Analysis::getDataPointByUUID ( const UUID &  uuid) const
boost::optional<DataPoint> openstudio::analysis::Analysis::getDataPointByUUID ( const DataPoint dataPoint) const
std::vector<DataPoint> openstudio::analysis::Analysis::getDataPoints ( const std::vector< QVariant > &  variableValues) const

Get the DataPoints with matching variableValues.

VariableValues may contain Null QVariants of the correct type, which means that any value at that position should be returned.

std::vector<DataPoint> openstudio::analysis::Analysis::getDataPoints ( const std::vector< boost::optional< Measure > > &  measures) const

Get the DataPoints defined by measures.

Perturbations must be translatable into a valid set of variableValues for the problem().

std::vector<DataPoint> openstudio::analysis::Analysis::getDataPoints ( const std::string &  tag) const
void openstudio::analysis::Analysis::initializeDakotaAlgorithm ( DakotaAlgorithm dakotaAlgorithm,
const runmanager::Job &  dakotaJob 
)

Register Dakota's restart file location so that the analysis can be restarted if necessary.

static boost::optional<Analysis> openstudio::analysis::Analysis::loadJSON ( const openstudio::path &  p,
const openstudio::path &  newProjectDir = openstudio::path() 
)
static
static boost::optional<Analysis> openstudio::analysis::Analysis::loadJSON ( std::istream &  json,
const openstudio::path &  newProjectDir = openstudio::path() 
)
static
static boost::optional<Analysis> openstudio::analysis::Analysis::loadJSON ( const std::string &  json,
const openstudio::path &  newProjectDir = openstudio::path() 
)
static
Problem openstudio::analysis::Analysis::problem ( ) const
void openstudio::analysis::Analysis::removeAllDataPoints ( )

Removes all dataPoints from this analysis, resets dataPointsAreInvalid flag, and reinitializes algorithm(), if it exists.

bool openstudio::analysis::Analysis::removeDataPoint ( const DataPoint dataPoint)

Removes dataPoint from this analysis.

Returns false if dataPoint is not in this analysis by UUID.

bool openstudio::analysis::Analysis::resultsAreInvalid ( ) const

Flag flips to true if underlying structure of analysis changes and there are any completeDataPoints().

bool openstudio::analysis::Analysis::saveJSON ( const openstudio::path &  p,
const AnalysisSerializationOptions options,
bool  overwrite = false 
) const
FileReference openstudio::analysis::Analysis::seed ( ) const

Returns the FileReference that points to this analysis's seed model.

If no specific model has been specified, seed().path() will be "*.osm" or "*.idf".

bool openstudio::analysis::Analysis::setAlgorithm ( Algorithm algorithm)
bool openstudio::analysis::Analysis::setDataPointRunInformation ( DataPoint dataPoint,
const runmanager::Job &  topLevelJob,
const std::vector< openstudio::path > &  dakotaParametersFiles 
)

Sets run information on a DataPoint.

Returns false if dataPoint is not in this analysis by UUID. Intention is for this method to be called by AnalysisDriver as soon as the dataPoint's topLevelJob has been queued.

bool openstudio::analysis::Analysis::setProblem ( Problem problem)
bool openstudio::analysis::Analysis::setSeed ( const FileReference &  newSeed)

Set seed to newSeed.

bool openstudio::analysis::Analysis::setWeatherFile ( const FileReference &  newWeatherFile)
std::vector<DataPoint> openstudio::analysis::Analysis::successfulDataPoints ( ) const
std::ostream& openstudio::analysis::Analysis::toJSON ( std::ostream &  os,
const AnalysisSerializationOptions options 
) const
std::string openstudio::analysis::Analysis::toJSON ( const AnalysisSerializationOptions options) const
void openstudio::analysis::Analysis::updateDakotaAlgorithm ( const runmanager::Job &  completedDakotaJob)

Updates the DakotaAlgorithm being used by this analysis.

Thows an openstudio::Exception if DakotaAlgorithm is not being used by this analysis, or if completedJob is not complete, or does not correspond to the proper Dakota job. Should be called when the given Dakota job completes.

void openstudio::analysis::Analysis::updateDataPoint ( DataPoint dataPoint,
const runmanager::Job &  completedJob 
)

Updates an existing DataPoint in this analysis.

Throws an openstudio::Exception if DataPoint is not in this analysis, or if completedJob is not complete, or was not spawned by algorithm() acting on problem(). Should be called after a given workflow has been run.

void openstudio::analysis::Analysis::updateInputPathData ( const openstudio::path &  originalBase,
const openstudio::path &  newBase 
)

Relocate input path data from originalBase to newBase.

Only updates file paths used to set up an analysis; paths that point to analysis results should be fixed up by a separate import process.

boost::optional<FileReference> openstudio::analysis::Analysis::weatherFile ( ) const

Friends And Related Function Documentation

typedef std::vector<Analysis> AnalysisVector
related
boost::optional< DakotaAlgorithm > getDakotaAlgorithm ( const Analysis analysis)
related
boost::optional< OpenStudioAlgorithm > getOpenStudioAlgorithm ( const Analysis analysis)
related
typedef boost::optional<Analysis> OptionalAnalysis
related