예제 #1
0
  analysis::Problem ProblemRecord_Impl::problem() const {
    InputVariableRecordVector inputVariableRecords = this->inputVariableRecords();
    WorkflowRecordVector workflowRecords = this->workflowRecords();

    analysis::WorkflowStepVector workflow;

    // mesh InputVariables and WorkItems together to form overall workflow
    int ivrIndex(0); // index into input variable records
    int wrIndex(0);  // index into workflow records
    int wIndex(0);   // index into workflow
    int ivrN = inputVariableRecords.size();
    int wrN = workflowRecords.size();
    OptionalInt ivrWIndex; // saved index into workflow for next input variable
    OptionalInt wrWIndex;  // saved index into workflow for next workflow record
    if (!inputVariableRecords.empty()) {
      ivrWIndex = inputVariableRecords[ivrIndex].variableVectorIndex();
    }
    if (!workflowRecords.empty()) {
      wrWIndex = workflowRecords[wrIndex].workflowIndex();
    }
    for (int i = 0, n = ivrN + wrN; i < n; ++i) {
      if (!wrWIndex || (ivrWIndex && (*ivrWIndex < *wrWIndex))) {
        // InputVariable is next
        BOOST_ASSERT(*ivrWIndex == wIndex); // saved and expected index into workflow match
        BOOST_ASSERT(ivrIndex < ivrN);      // there is an input variable record to deserialize
        workflow.push_back(WorkflowStep(inputVariableRecords[ivrIndex].inputVariable()));
        ++ivrIndex; // go to next input variable record
        ++wIndex;   // and next index into workflow
        BOOST_ASSERT(wIndex == int(workflow.size())); // next index into workflow should match current size
        if (ivrIndex < ivrN) {
          ivrWIndex = inputVariableRecords[ivrIndex].variableVectorIndex();
        }
        else {
          ivrWIndex.reset(); // no more input variables to deserialize
        }
      }
      else {
        // Workflow is next
        BOOST_ASSERT(wrWIndex);
        int temp = *wrWIndex; // for debugging
        BOOST_ASSERT(temp == wIndex); // saved index into workflow should match expected value
        BOOST_ASSERT(wrIndex < wrN);  // there is a workflow record to deserialize
        std::vector<runmanager::WorkItem> workItems = workflowRecords[wrIndex].workflow().toWorkItems();
        workflow.insert(workflow.end(),workItems.begin(),workItems.end());
        ++wrIndex; // go to next workflow record
        wIndex += workItems.size(); // update next expected workflow index
        BOOST_ASSERT(wIndex == int(workflow.size())); // next index into workflow should match current size
        if (wrIndex < wrN) {
          wrWIndex = workflowRecords[wrIndex].workflowIndex();
        }
        else {
          wrWIndex.reset(); // no more workflow records to deserialize
        }
      }
    }

    analysis::FunctionVector responses;
    FunctionRecordVector responseRecords = this->responseRecords();
    BOOST_FOREACH(const FunctionRecord responseRecord,responseRecords) {
      responses.push_back(responseRecord.function());
    }