Skip to content

Commit

Permalink
#428 [SA] when finalStates are dumped in contingencies, reorder them …
Browse files Browse the repository at this point in the history
…in a clean folder

Signed-off-by: Dimitri Baron <[email protected]>
  • Loading branch information
barondim committed Nov 8, 2024
1 parent 7cf7f48 commit dcec1a1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
10 changes: 10 additions & 0 deletions sources/Common/DYNSimulationResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ SimulationResult::getLostEquipementsStreamStr() const {
return lostEquipmentsStream_.str();
}

std::stringstream&
SimulationResult::getOutputIIDMStream() {
return outputIIDMStream_;
}

std::string
SimulationResult::getOutputIIDMStreamStr() const {
return outputIIDMStream_.str();
}

std::string
SimulationResult::getScenarioId() const {
return scenarioId_;
Expand Down
5 changes: 5 additions & 0 deletions sources/Common/DYNSimulationResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class SimulationResult {
*/
std::string getLostEquipementsStreamStr() const;

std::stringstream& getOutputIIDMStream();

std::string getOutputIIDMStreamStr() const;

/**
* @brief getter of the scenario id associated to the simulation
* @return the scenario id associated to the simulation
Expand Down Expand Up @@ -248,6 +252,7 @@ class SimulationResult {
std::stringstream timelineStream_; ///< stream for the timeline associated to the scenario
std::stringstream constraintsStream_; ///< stream for the constraints associated to the scenario
std::stringstream lostEquipmentsStream_; ///< stream for the lost equipments associated to the scenario
std::stringstream outputIIDMStream_;
std::string scenarioId_; ///< id of the scenario
double variation_; ///< variation of the scenario (aka loadLevel when associated to a load increase)
bool success_; ///< @b true if the simulation reached its end, @b false otherwise
Expand Down
23 changes: 21 additions & 2 deletions sources/Launcher/DYNRobustnessAnalysisLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ RobustnessAnalysisLauncher::simulate(const boost::shared_ptr<DYN::Simulation>& s
simulation->terminate();
result.setSuccess(true);
result.setStatus(CONVERGENCE_STATUS);
simulation->dumpIIDMFile(result.getOutputIIDMStream());
} catch (const DYN::Error& e) {
std::cerr << e.what() << std::endl;
Trace::error() << e.what() << Trace::endline;
Expand Down Expand Up @@ -452,6 +453,12 @@ RobustnessAnalysisLauncher::storeOutputs(const SimulationResult& result, std::ma
mapData[lostEquipmentsName.str()] = result.getLostEquipementsStreamStr();
}

if (!result.getOutputIIDMStreamStr().empty()) {
std::stringstream outputIIDMName;
outputIIDMName << "outputIIDM/outputIIDM_" << result.getUniqueScenarioId() << ".xml";
mapData[outputIIDMName.str()] = result.getOutputIIDMStreamStr();
}

if (!result.getLogPath().empty()) {
std::stringstream logName;
logName << "logs/log_" << result.getUniqueScenarioId() << ".log";
Expand Down Expand Up @@ -615,15 +622,26 @@ RobustnessAnalysisLauncher::importResult(const std::string& id) const {

// lost equipments
auto& lostEquipments = ret.getLostEquipementsStream();
while (tmpStr.find("variation:") != 0) {
while (tmpStr.find("outputIIDM:") != 0) {
file >> tmpStr;
if (tmpStr.find("variation:") == 0) {
if (tmpStr.find("outputIIDM:") == 0) {
// case no lost equipments
break;
}
lostEquipments << tmpStr << std::endl;
}

// outputIIDM
auto& outputIIDM = ret.getOutputIIDMStream();
while (tmpStr.find("variation:") != 0) {
file >> tmpStr;
if (tmpStr.find("variation:") == 0) {
// case no output IIDM
break;
}
outputIIDM << tmpStr << std::endl;
}

// variation
double variation;
tmpStr = tmpStr.substr(tmpStr.find(delimiter)+1);
Expand Down Expand Up @@ -708,6 +726,7 @@ RobustnessAnalysisLauncher::exportResult(const SimulationResult& result) const {
file << "timeline:" << std::endl << result.getTimelineStreamStr() << std::endl;
file << "constraints:" << std::endl << result.getConstraintsStreamStr() << std::endl;
file << "lostEquipments:" << std::endl << result.getLostEquipementsStreamStr() << std::endl;
file << "outputIIDM:" << std::endl << result.getOutputIIDMStreamStr() << std::endl;
file << "variation:" <<result.getVariation() << std::endl;
file << "success:" << std::boolalpha << result.getSuccess() << std::endl;
file << "status:" << static_cast<unsigned int>(result.getStatus()) << std::endl;
Expand Down

0 comments on commit dcec1a1

Please sign in to comment.