Browse Source

Support abort in model building

tempestpy_adaptions
Matthias Volk 5 years ago
parent
commit
6f62e8d402
  1. 20
      src/storm-parsers/parser/DirectEncodingParser.cpp
  2. 45
      src/storm/builder/ExplicitModelBuilder.cpp
  3. 21
      src/storm/storage/bisimulation/BisimulationDecomposition.cpp

20
src/storm-parsers/parser/DirectEncodingParser.cpp

@ -8,20 +8,23 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include "storm/models/sparse/MarkovAutomaton.h"
#include "storm/models/sparse/Ctmc.h"
#include "storm/adapters/RationalFunctionAdapter.h"
#include "storm/exceptions/AbortException.h"
#include "storm/exceptions/FileIoException.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/exceptions/InvalidArgumentException.h"
#include "storm/exceptions/NotSupportedException.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/settings/SettingsManager.h"
#include "storm/adapters/RationalFunctionAdapter.h"
#include "storm/models/sparse/MarkovAutomaton.h"
#include "storm/models/sparse/Ctmc.h"
#include "storm/utility/constants.h"
#include "storm/utility/builder.h"
#include "storm/utility/macros.h"
#include "storm/utility/file.h"
#include "storm/utility/macros.h"
#include "storm/utility/SignalHandler.h"
namespace storm {
@ -352,6 +355,13 @@ namespace storm {
STORM_LOG_THROW(target < stateSize, storm::exceptions::WrongFormatException, "Target state " << target << " is greater than state size " << stateSize);
builder.addNextValue(row, target, value);
}
if (storm::utility::resources::isTerminate()) {
std::cout << "Parsed " << state << "/" << stateSize << " states before abort." << std::endl;
STORM_LOG_THROW(false, storm::exceptions::AbortException, "Aborted in state space exploration.");
break;
}
} // end state iteration
STORM_LOG_TRACE("Finished parsing");

45
src/storm/builder/ExplicitModelBuilder.cpp

@ -2,41 +2,37 @@
#include <map>
#include "storm/models/sparse/Dtmc.h"
#include "storm/models/sparse/Ctmc.h"
#include "storm/models/sparse/Mdp.h"
#include "storm/models/sparse/MarkovAutomaton.h"
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/settings/modules/BuildSettings.h"
#include "storm/builder/RewardModelBuilder.h"
#include "storm/builder/ChoiceInformationBuilder.h"
#include "storm/exceptions/AbortException.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/generator/PrismNextStateGenerator.h"
#include "storm/generator/JaniNextStateGenerator.h"
#include "storm/models/sparse/Dtmc.h"
#include "storm/models/sparse/Ctmc.h"
#include "storm/models/sparse/Mdp.h"
#include "storm/models/sparse/MarkovAutomaton.h"
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/settings/modules/BuildSettings.h"
#include "storm/storage/jani/Edge.h"
#include "storm/storage/jani/EdgeDestination.h"
#include "storm/storage/expressions/ExpressionManager.h"
#include "storm/storage/jani/Model.h"
#include "storm/storage/jani/Automaton.h"
#include "storm/storage/jani/Location.h"
#include "storm/storage/jani/AutomatonComposition.h"
#include "storm/storage/jani/ParallelComposition.h"
#include "storm/storage/jani/CompositionInformationVisitor.h"
#include "storm/utility/prism.h"
#include "storm/utility/builder.h"
#include "storm/utility/constants.h"
#include "storm/utility/prism.h"
#include "storm/utility/macros.h"
#include "storm/utility/ConstantsComparator.h"
#include "storm/utility/builder.h"
#include "storm/utility/SignalHandler.h"
#include "storm/exceptions/WrongFormatException.h"
#include "storm/exceptions/InvalidArgumentException.h"
#include "storm/exceptions/InvalidOperationException.h"
namespace storm {
namespace builder {
@ -245,11 +241,11 @@ namespace storm {
}
++currentRowGroup;
}
++numberOfExploredStates;
if (generator->getOptions().isShowProgressSet()) {
++numberOfExploredStatesSinceLastMessage;
++numberOfExploredStates;
auto now = std::chrono::high_resolution_clock::now();
auto durationSinceLastMessage = std::chrono::duration_cast<std::chrono::seconds>(now - timeOfLastMessage).count();
if (static_cast<uint64_t>(durationSinceLastMessage) >= generator->getOptions().getShowProgressDelay()) {
@ -260,6 +256,13 @@ namespace storm {
numberOfExploredStatesSinceLastMessage = 0;
}
}
if (storm::utility::resources::isTerminate()) {
auto durationSinceStart = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::high_resolution_clock::now() - timeOfStart).count();
std::cout << "Explored " << numberOfExploredStates << " states in " << durationSinceStart << " seconds before abort." << std::endl;
STORM_LOG_THROW(false, storm::exceptions::AbortException, "Aborted in state space exploration.");
break;
}
}
if (markovianStates) {

21
src/storm/storage/bisimulation/BisimulationDecomposition.cpp

@ -2,25 +2,28 @@
#include <chrono>
#include "storm/exceptions/AbortException.h"
#include "storm/exceptions/IllegalFunctionCallException.h"
#include "storm/exceptions/InvalidOptionException.h"
#include "storm/logic/FormulaInformation.h"
#include "storm/logic/FragmentSpecification.h"
#include "storm/models/sparse/Dtmc.h"
#include "storm/models/sparse/Ctmc.h"
#include "storm/models/sparse/Mdp.h"
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/storage/bisimulation/DeterministicBlockData.h"
#include "storm/modelchecker/propositional/SparsePropositionalModelChecker.h"
#include "storm/modelchecker/results/ExplicitQualitativeCheckResult.h"
#include "storm/settings/SettingsManager.h"
#include "storm/settings/modules/CoreSettings.h"
#include "storm/logic/FormulaInformation.h"
#include "storm/logic/FragmentSpecification.h"
#include "storm/storage/bisimulation/DeterministicBlockData.h"
#include "storm/utility/macros.h"