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

#include <Problem.hpp>

+ Inheritance diagram for openstudio::analysis::Problem:

Public Member Functions

Constructors and Destructors
 Problem (const std::string &name, const std::vector< WorkflowStep > &workflow=std::vector< WorkflowStep >())
 
 Problem (const std::string &name, const std::vector< WorkflowStep > &workflow, const std::vector< Function > &responses)
 
 Problem (const std::string &name, const std::vector< Variable > &variables, const std::vector< Function > &responses, const runmanager::Workflow &simulationWorkflow)
 Construct from variables (order will be preserved), response functions, and simulation workflow. More...
 
 Problem (const std::string &name, const std::vector< Variable > &variables, const runmanager::Workflow &simulationWorkflow)
 
 Problem (const UUID &uuid, const UUID &versionUUID, const std::string &name, const std::string &displayName, const std::string &description, const std::vector< WorkflowStep > &workflow, const std::vector< Function > &responses)
 Constructor provided for deserialization; not for general use. More...
 
virtual ~Problem ()
 
Getters and Queries
std::vector< WorkflowStepworkflow () const
 Returns the vector of WorkflowSteps that defines how this Problem will generate parametrically related DataPoints. More...
 
boost::optional< int > getWorkflowStepIndexByJobType (const runmanager::JobType &jobType) const
 If there is a runmanager::WorkItem of jobType in workflow(), returns the index of the first such runmanager::WorkItem. More...
 
int numWorkflowSteps () const
 
std::vector< InputVariablevariables () const
 Returns this problem's (ordered) list of input variables, that is, individual model parameters. More...
 
InputVariable getVariable (int index) const
 Returns the variable at index, where index refers to the vector returned by variables(). More...
 
boost::optional< int > getVariableIndexByUUID (const UUID &uuid) const
 Returns the index of the InputVariable with uuid, where index refers to the vector returned by variables(). More...
 
boost::optional< InputVariablegetVariableByUUID (const UUID &uuid) const
 
int numVariables () const
 Returns the number of variables in this problem. More...
 
int numContinuousVariables () const
 Returns the number of variables in this problem that derive from ContinuousVariable. More...
 
int numDiscreteVariables () const
 Returns the number of variables in this problem that derive from DiscreteVariable. More...
 
int numStaticTransformations () const
 Returns the number of discrete variables that have 0-1 measures selected. More...
 
bool allVariablesAreContinuous () const
 Returns true if numContinuousVariables() == numVariables(). More...
 
bool allVariablesAreContinuousOrStaticTransformations () const
 Returns true if all DiscreteVariables have either zero or one measure selected. More...
 
bool allVariablesAreDiscrete () const
 Returns true if numContinuousVariables() == 0. More...
 
std::vector< Functionresponses () const
 Returns this problem's response functions. More...
 
boost::optional< FunctiongetResponseByUUID (const UUID &uuid) const
 
int numResponses () const
 Returns the number of response functions associated with this problem. More...
 
boost::optional
< FileReferenceType > 
inputFileType () const
 Returns the input file type expected by workflow(). More...
 
bool isValid (const DataPoint &dataPoint) const
 Returns true if dataPoint.variableValues() make sense in the context of this Problem. More...
 
bool fileTypesAreCompatible (const WorkflowStep &childStep, const boost::optional< FileReferenceType > &proposedInputFileType, const boost::optional< FileReferenceType > &proposedOutputFileType) const
 Returns true if childStep is in this Problem, and proposedInputFileType and proposedOutputFileType would be acceptable in that position. More...
 
bool fileTypesAreCompatible (const InputVariable &childVariable, const boost::optional< FileReferenceType > &proposedInputFileType, const boost::optional< FileReferenceType > &proposedOutputFileType) const
 Returns true if childVariable is in this Problem, and proposedInputFileType and proposedOutputFileType would be acceptable in that position. More...
 
Getters and Queries for Discrete Problems
std::vector< QVariant > getVariableValues (const std::vector< Measure > &measures) const
 Converts measures to a vector of variable values stored in QVariant format. More...
 
std::vector< QVariant > getVariableValues (const std::vector< boost::optional< Measure > > &measures) const
 Converts measures to a vector of variable values stored in QVariant format, including null QVariant values (of the correct type, int or double) as necessary. More...
 
std::vector< boost::optional
< Measure > > 
getMeasures (const std::vector< QVariant > &variableValues) const
 Converts variableValues to a vector of Measures, leaving gaps for continuous variables by inserting boost::nones in the appropriate locations. More...
 
std::vector< boost::optional
< Measure > > 
getDiscretePerturbations (const std::vector< QVariant > &variableValues) const
 
boost::optional< int > combinatorialSize (bool selectedOnly) const
 If allVariablesAreDiscrete(), returns the number of DataPoints that would have to be simulated to populate the full mesh for this problem. More...
 
Setters
bool push (const WorkflowStep &step)
 
bool insert (int index, const WorkflowStep &step)
 
bool erase (const WorkflowStep &step)
 
bool swap (const WorkflowStep &step1, const WorkflowStep &step2)
 
bool setWorkflow (const std::vector< WorkflowStep > &workflow)
 
void clearWorkflow ()
 
void pushResponse (const Function &response)
 
bool insertResponse (int index, const Function &response)
 
bool eraseResponse (const Function &response)
 
bool swapResponses (const Function &response1, const Function &response2)
 
void setResponseFunctions (const std::vector< Function > &responses)
 
void clearResponseFunctions ()
 
Actions
bool updateMeasure (const BCLMeasure &newVersion, const std::vector< ruleset::OSArgument > &newArguments, bool keepOldArgumentsIfNewEmpty)
 Updates objects using BCLMeasures with the same UUID as newVersion to use newVersion. More...
 
std::string dakotaInFileDescription (const DakotaAlgorithm &algorithm) const
 Returns a description of this problem for using in dakota.in files. More...
 
boost::optional< DataPointcreateDataPoint (const std::vector< QVariant > &variableValues) const
 Constructs a new (incomplete) DataPoint for this problem using variableValues (if possible). More...
 
boost::optional< DataPointcreateDataPoint (const std::vector< Measure > &measures) const
 Returns a DataPoint if measures can be transformed into a valid set of variableValues. More...
 
boost::optional< DataPointcreateDataPoint (const DakotaParametersFile &params, const DakotaAlgorithm &algorithm) const
 Attempts to create a new DataPoint from params. More...
 
runmanager::Workflow createWorkflow (const DataPoint &dataPoint, const openstudio::path &rubyIncludeDirectory=openstudio::path()) const
 Returns the runmanager::Workflow created by instantiating all of the InputVariable WorkflowSteps as runmanager::WorkItems using the variable values specified in dataPoint. More...
 
void updateDataPoint (DataPoint &dataPoint, const runmanager::Job &completedJob) const
 Updates dataPoint post-simulation. More...
 
std::vector< WorkflowStepJobgetJobsByWorkflowStep (const DataPoint &dataPoint, bool optimize=false) const
 Returns the jobs stored in dataPoint broken down by WorkflowStep. More...
 
boost::optional< std::string > getDakotaResultsFile (const DataPoint &dataPoint) const
 Returns the DAKOTA results file string corresponding to dataPoint, if dataPoint completed successfully. More...
 
Dakota Algorithm Helpers
std::vector< int > getContinuousDesignVariableIndices (const DakotaAlgorithm &dakotaAlgorithm) const
 Returns the indices into variables() that correspond to variables that DAKOTA will treat as continuous design variables. More...
 
std::vector< int > getDiscreteDesignVariableIndices (const DakotaAlgorithm &dakotaAlgorithm) const
 Returns the indices into variables() that correspond to variables that DAKOTA will treat as discrete design variables. More...
 
std::map
< UncertaintyDescriptionType,
std::vector< int > > 
getUncertainVariableIndices (const DakotaAlgorithm &dakotaAlgorithm) const
 Returns the indices into variables() that correspond to variables that DAKOTA will treat as uncertain variables, broken down by UncertaintyDescriptionType. 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 boost::optional< ProblemOptionalProblem
 
typedef std::vector< ProblemProblemVector
 

Detailed Description

Problem is an AnalysisObject that contains a (building energy) problem formulation stated as a vector of workflow steps (input variables or runmanager::WorkItems), and a vector of response functions.

Each WorkflowStep operates on an IDF or OSM model, either returning a modified model or producing other outputs (reports and pieces of data generated for their own sake, or for the calculation of response function values). The problem formulation is not meant to be free standing, but is meant to be solved in the context of an Analysis, using an analysisdriver::AnalysisDriver. For this reason, Problem is designed to create runmanager::Workflows that set up and simulate DataPoints, and then to digest the final results.

Constructor & Destructor Documentation

openstudio::analysis::Problem::Problem ( const std::string &  name,
const std::vector< WorkflowStep > &  workflow = std::vector< WorkflowStep >() 
)
openstudio::analysis::Problem::Problem ( const std::string &  name,
const std::vector< WorkflowStep > &  workflow,
const std::vector< Function > &  responses 
)
openstudio::analysis::Problem::Problem ( const std::string &  name,
const std::vector< Variable > &  variables,
const std::vector< Function > &  responses,
const runmanager::Workflow &  simulationWorkflow 
)

Construct from variables (order will be preserved), response functions, and simulation workflow.

If any of the following requirements are violated, an openstudio::Exception is thrown:

  • The simulationWorkflow must be convertible to std::vector<runmanager::WorkItem>.
  • The input and output file types must be consistent throughout the resulting chain of WorkflowSteps.
Deprecated:
openstudio::analysis::Problem::Problem ( const std::string &  name,
const std::vector< Variable > &  variables,
const runmanager::Workflow &  simulationWorkflow 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

openstudio::analysis::Problem::Problem ( const UUID &  uuid,
const UUID &  versionUUID,
const std::string &  name,
const std::string &  displayName,
const std::string &  description,
const std::vector< WorkflowStep > &  workflow,
const std::vector< Function > &  responses 
)

Constructor provided for deserialization; not for general use.

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

Member Function Documentation

bool openstudio::analysis::Problem::allVariablesAreContinuous ( ) const
bool openstudio::analysis::Problem::allVariablesAreContinuousOrStaticTransformations ( ) const

Returns true if all DiscreteVariables have either zero or one measure selected.

Such discrete variables can be thought of as model transformations, rather than variables, and can be hidden from DakotaAlgorithms.

bool openstudio::analysis::Problem::allVariablesAreDiscrete ( ) const

Returns true if numContinuousVariables() == 0.

void openstudio::analysis::Problem::clearResponseFunctions ( )
void openstudio::analysis::Problem::clearWorkflow ( )
boost::optional<int> openstudio::analysis::Problem::combinatorialSize ( bool  selectedOnly) const

If allVariablesAreDiscrete(), returns the number of DataPoints that would have to be simulated to populate the full mesh for this problem.

If selectedOnly, the returned value represents the computational effort necessary to run DesignOfExperiments. If not selectedOnly, the returned value represents the maximum size of the problem, if all discrete possibilities were to be turned on.

boost::optional<DataPoint> openstudio::analysis::Problem::createDataPoint ( const std::vector< QVariant > &  variableValues) const

Constructs a new (incomplete) DataPoint for this problem using variableValues (if possible).

The size and contents of variableValues must be compatible with variables() for this operation to be successful.

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

Returns a DataPoint if measures can be transformed into a valid set of variableValues.

Only works if allVariablesAreDiscrete().

boost::optional<DataPoint> openstudio::analysis::Problem::createDataPoint ( const DakotaParametersFile params,
const DakotaAlgorithm algorithm 
) const

Attempts to create a new DataPoint from params.

Returns that DataPoint if possible; returns boost::none otherwise. Not for general use. AnalysisDriver uses this method to translate requests from DAKOTA.

runmanager::Workflow openstudio::analysis::Problem::createWorkflow ( const DataPoint dataPoint,
const openstudio::path &  rubyIncludeDirectory = openstudio::path() 
) const

Returns the runmanager::Workflow created by instantiating all of the InputVariable WorkflowSteps as runmanager::WorkItems using the variable values specified in dataPoint.

std::string openstudio::analysis::Problem::dakotaInFileDescription ( const DakotaAlgorithm algorithm) const

Returns a description of this problem for using in dakota.in files.

bool openstudio::analysis::Problem::erase ( const WorkflowStep step)
bool openstudio::analysis::Problem::eraseResponse ( const Function response)
bool openstudio::analysis::Problem::fileTypesAreCompatible ( const WorkflowStep childStep,
const boost::optional< FileReferenceType > &  proposedInputFileType,
const boost::optional< FileReferenceType > &  proposedOutputFileType 
) const

Returns true if childStep is in this Problem, and proposedInputFileType and proposedOutputFileType would be acceptable in that position.

Returns false otherwise.

bool openstudio::analysis::Problem::fileTypesAreCompatible ( const InputVariable childVariable,
const boost::optional< FileReferenceType > &  proposedInputFileType,
const boost::optional< FileReferenceType > &  proposedOutputFileType 
) const

Returns true if childVariable is in this Problem, and proposedInputFileType and proposedOutputFileType would be acceptable in that position.

Returns false otherwise.

std::vector<int> openstudio::analysis::Problem::getContinuousDesignVariableIndices ( const DakotaAlgorithm dakotaAlgorithm) const

Returns the indices into variables() that correspond to variables that DAKOTA will treat as continuous design variables.

boost::optional<std::string> openstudio::analysis::Problem::getDakotaResultsFile ( const DataPoint dataPoint) const

Returns the DAKOTA results file string corresponding to dataPoint, if dataPoint completed successfully.

Returns boost::none otherwise.

std::vector<int> openstudio::analysis::Problem::getDiscreteDesignVariableIndices ( const DakotaAlgorithm dakotaAlgorithm) const

Returns the indices into variables() that correspond to variables that DAKOTA will treat as discrete design variables.

std::vector<boost::optional<Measure> > openstudio::analysis::Problem::getDiscretePerturbations ( const std::vector< QVariant > &  variableValues) const
Deprecated:
Forwards to re-named method getMeasures.
std::vector<WorkflowStepJob> openstudio::analysis::Problem::getJobsByWorkflowStep ( const DataPoint dataPoint,
bool  optimize = false 
) const

Returns the jobs stored in dataPoint broken down by WorkflowStep.

Can be used to extract errors and warnings on a per-WorkflowStep basis. If optimize, steps that evaluate to null jobs are removed from the return vector.

std::vector<boost::optional<Measure> > openstudio::analysis::Problem::getMeasures ( const std::vector< QVariant > &  variableValues) const

Converts variableValues to a vector of Measures, leaving gaps for continuous variables by inserting boost::nones in the appropriate locations.

boost::optional<Function> openstudio::analysis::Problem::getResponseByUUID ( const UUID &  uuid) const
std::map<UncertaintyDescriptionType,std::vector<int> > openstudio::analysis::Problem::getUncertainVariableIndices ( const DakotaAlgorithm dakotaAlgorithm) const

Returns the indices into variables() that correspond to variables that DAKOTA will treat as uncertain variables, broken down by UncertaintyDescriptionType.

InputVariable openstudio::analysis::Problem::getVariable ( int  index) const

Returns the variable at index, where index refers to the vector returned by variables().

boost::optional<InputVariable> openstudio::analysis::Problem::getVariableByUUID ( const UUID &  uuid) const
boost::optional<int> openstudio::analysis::Problem::getVariableIndexByUUID ( const UUID &  uuid) const

Returns the index of the InputVariable with uuid, where index refers to the vector returned by variables().

std::vector<QVariant> openstudio::analysis::Problem::getVariableValues ( const std::vector< Measure > &  measures) const

Converts measures to a vector of variable values stored in QVariant format.

(In this case, all of the QVariants will be of type int.)

std::vector<QVariant> openstudio::analysis::Problem::getVariableValues ( const std::vector< boost::optional< Measure > > &  measures) const

Converts measures to a vector of variable values stored in QVariant format, including null QVariant values (of the correct type, int or double) as necessary.

boost::optional<int> openstudio::analysis::Problem::getWorkflowStepIndexByJobType ( const runmanager::JobType &  jobType) const

If there is a runmanager::WorkItem of jobType in workflow(), returns the index of the first such runmanager::WorkItem.

Otherwise evaluates to false.

boost::optional<FileReferenceType> openstudio::analysis::Problem::inputFileType ( ) const

Returns the input file type expected by workflow().

bool openstudio::analysis::Problem::insert ( int  index,
const WorkflowStep step 
)
bool openstudio::analysis::Problem::insertResponse ( int  index,
const Function response 
)
bool openstudio::analysis::Problem::isValid ( const DataPoint dataPoint) const

Returns true if dataPoint.variableValues() make sense in the context of this Problem.

int openstudio::analysis::Problem::numContinuousVariables ( ) const

Returns the number of variables in this problem that derive from ContinuousVariable.

int openstudio::analysis::Problem::numDiscreteVariables ( ) const

Returns the number of variables in this problem that derive from DiscreteVariable.

int openstudio::analysis::Problem::numResponses ( ) const

Returns the number of response functions associated with this problem.

int openstudio::analysis::Problem::numStaticTransformations ( ) const

Returns the number of discrete variables that have 0-1 measures selected.

Such variables can be thought of as static model tranformations, rather than as true variables, since they have the same effect every time.

int openstudio::analysis::Problem::numVariables ( ) const

Returns the number of variables in this problem.

int openstudio::analysis::Problem::numWorkflowSteps ( ) const
bool openstudio::analysis::Problem::push ( const WorkflowStep step)
void openstudio::analysis::Problem::pushResponse ( const Function response)
std::vector<Function> openstudio::analysis::Problem::responses ( ) const

Returns this problem's response functions.

A response function is typically a simulation output like site energy use (GJ) that is expected to be dependent on the variables' values, and is important to the design or research question at hand (which is often centered around some aspect of building performance).

void openstudio::analysis::Problem::setResponseFunctions ( const std::vector< Function > &  responses)
bool openstudio::analysis::Problem::setWorkflow ( const std::vector< WorkflowStep > &  workflow)
bool openstudio::analysis::Problem::swap ( const WorkflowStep step1,
const WorkflowStep step2 
)
bool openstudio::analysis::Problem::swapResponses ( const Function response1,
const Function response2 
)
void openstudio::analysis::Problem::updateDataPoint ( DataPoint dataPoint,
const runmanager::Job &  completedJob 
) const

Updates dataPoint post-simulation.

If the completedJob is successful, it is mined for relevant files and other data, which then becomes accessible through dataPoint.

bool openstudio::analysis::Problem::updateMeasure ( const BCLMeasure &  newVersion,
const std::vector< ruleset::OSArgument > &  newArguments,
bool  keepOldArgumentsIfNewEmpty 
)

Updates objects using BCLMeasures with the same UUID as newVersion to use newVersion.

Merges argument designations and values with newArguments if (not newArguments.empty()) or (not keepOldArgumentsIfNewEmpty). Returns true if operation proceeds smoothly. Returns false if any old versions have to be left in place (perhaps because of input/output file type conflicts).

std::vector<InputVariable> openstudio::analysis::Problem::variables ( ) const

Returns this problem's (ordered) list of input variables, that is, individual model parameters.

After this Problem is attached to a seed model using the Analysis class, setting each of the variables to a specific value fully defines a building energy model that is parametrically related to all other models constructed in the same way, making it possible to search, explore and visualize a particular design space.

std::vector<WorkflowStep> openstudio::analysis::Problem::workflow ( ) const

Returns the vector of WorkflowSteps that defines how this Problem will generate parametrically related DataPoints.

Friends And Related Function Documentation

typedef boost::optional<Problem> OptionalProblem
related
typedef std::vector<Problem> ProblemVector
related