diff --git a/src/models/sparse/Ctmc.cpp b/src/models/sparse/Ctmc.cpp index 371d48270..62347c81b 100644 --- a/src/models/sparse/Ctmc.cpp +++ b/src/models/sparse/Ctmc.cpp @@ -11,7 +11,7 @@ namespace storm { Ctmc::Ctmc(storm::storage::SparseMatrix const& rateMatrix, storm::models::sparse::StateLabeling const& stateLabeling, std::unordered_map const& rewardModels, boost::optional> const& optionalChoiceLabeling) - : DeterministicModel(storm::models::ModelType::Ctmc, rateMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { + : DeterministicModel(storm::models::ModelType::Ctmc, rateMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { exitRates = createExitRateVector(this->getTransitionMatrix()); } @@ -19,7 +19,7 @@ namespace storm { Ctmc::Ctmc(storm::storage::SparseMatrix&& rateMatrix, storm::models::sparse::StateLabeling&& stateLabeling, std::unordered_map&& rewardModels, boost::optional>&& optionalChoiceLabeling) - : DeterministicModel(storm::models::ModelType::Ctmc, std::move(rateMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { + : DeterministicModel(storm::models::ModelType::Ctmc, std::move(rateMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { // It is important to refer to the transition matrix here, because the given rate matrix has been move elsewhere. exitRates = createExitRateVector(this->getTransitionMatrix()); } @@ -41,6 +41,8 @@ namespace storm { template class Ctmc; #ifdef STORM_HAVE_CARL + template class Ctmc>; + template class Ctmc; #endif diff --git a/src/models/sparse/DeterministicModel.cpp b/src/models/sparse/DeterministicModel.cpp index d774d5e7f..0fb6de34a 100644 --- a/src/models/sparse/DeterministicModel.cpp +++ b/src/models/sparse/DeterministicModel.cpp @@ -12,7 +12,7 @@ namespace storm { storm::models::sparse::StateLabeling const& stateLabeling, std::unordered_map const& rewardModels, boost::optional> const& optionalChoiceLabeling) - : Model(modelType, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { + : Model(modelType, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { // Intentionally left empty. } @@ -22,13 +22,13 @@ namespace storm { storm::models::sparse::StateLabeling&& stateLabeling, std::unordered_map&& rewardModels, boost::optional>&& optionalChoiceLabeling) - : Model(modelType, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { + : Model(modelType, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { // Intentionally left empty. } template void DeterministicModel::writeDotToStream(std::ostream& outStream, bool includeLabeling, storm::storage::BitVector const* subsystem, std::vector const* firstValue, std::vector const* secondValue, std::vector const* stateColoring, std::vector const* colors, std::vector* scheduler, bool finalizeOutput) const { - Model::writeDotToStream(outStream, includeLabeling, subsystem, firstValue, secondValue, stateColoring, colors, scheduler, false); + Model::writeDotToStream(outStream, includeLabeling, subsystem, firstValue, secondValue, stateColoring, colors, scheduler, false); // Simply iterate over all transitions and draw the arrows with probability information attached. auto rowIt = this->getTransitionMatrix().begin(); @@ -59,6 +59,8 @@ namespace storm { template class DeterministicModel; #ifdef STORM_HAVE_CARL + template class DeterministicModel>; + template class DeterministicModel; #endif diff --git a/src/models/sparse/DeterministicModel.h b/src/models/sparse/DeterministicModel.h index fb3e367df..cc886c401 100644 --- a/src/models/sparse/DeterministicModel.h +++ b/src/models/sparse/DeterministicModel.h @@ -49,7 +49,7 @@ namespace storm { #ifndef WINDOWS DeterministicModel(DeterministicModel&& other) = default; - DeterministicModel& operator=(DeterministicModel&& model) = default; + DeterministicModel& operator=(DeterministicModel&& model) = default; #endif virtual void reduceToStateBasedRewards() override; diff --git a/src/models/sparse/Dtmc.cpp b/src/models/sparse/Dtmc.cpp index 9cc968136..31c222207 100644 --- a/src/models/sparse/Dtmc.cpp +++ b/src/models/sparse/Dtmc.cpp @@ -14,14 +14,14 @@ namespace storm { storm::models::sparse::StateLabeling const& stateLabeling, std::unordered_map const& rewardModels, boost::optional> const& optionalChoiceLabeling) - : DeterministicModel(storm::models::ModelType::Dtmc, probabilityMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { + : DeterministicModel(storm::models::ModelType::Dtmc, probabilityMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { STORM_LOG_THROW(probabilityMatrix.isProbabilistic(), storm::exceptions::InvalidArgumentException, "The probability matrix is invalid."); } template Dtmc::Dtmc(storm::storage::SparseMatrix&& probabilityMatrix, storm::models::sparse::StateLabeling&& stateLabeling, std::unordered_map&& rewardModels, boost::optional>&& optionalChoiceLabeling) - : DeterministicModel(storm::models::ModelType::Dtmc, std::move(probabilityMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { + : DeterministicModel(storm::models::ModelType::Dtmc, std::move(probabilityMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { STORM_LOG_THROW(probabilityMatrix.isProbabilistic(), storm::exceptions::InvalidArgumentException, "The probability matrix is invalid."); } @@ -225,6 +225,8 @@ namespace storm { template class Dtmc; #ifdef STORM_HAVE_CARL + template class Dtmc>; + template class Dtmc; #endif diff --git a/src/models/sparse/MarkovAutomaton.cpp b/src/models/sparse/MarkovAutomaton.cpp index b04c294f7..56a6400d1 100644 --- a/src/models/sparse/MarkovAutomaton.cpp +++ b/src/models/sparse/MarkovAutomaton.cpp @@ -15,7 +15,7 @@ namespace storm { std::vector const& exitRates, std::unordered_map const& rewardModels, boost::optional> const& optionalChoiceLabeling) - : NondeterministicModel(storm::models::ModelType::MarkovAutomaton, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling), markovianStates(markovianStates), exitRates(exitRates), closed(false) { + : NondeterministicModel(storm::models::ModelType::MarkovAutomaton, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling), markovianStates(markovianStates), exitRates(exitRates), closed(false) { this->turnRatesToProbabilities(); } @@ -26,7 +26,7 @@ namespace storm { std::vector const& exitRates, std::unordered_map&& rewardModels, boost::optional>&& optionalChoiceLabeling) - : NondeterministicModel(storm::models::ModelType::MarkovAutomaton, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)), markovianStates(markovianStates), exitRates(std::move(exitRates)), closed(false) { + : NondeterministicModel(storm::models::ModelType::MarkovAutomaton, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)), markovianStates(markovianStates), exitRates(std::move(exitRates)), closed(false) { this->turnRatesToProbabilities(); } @@ -124,7 +124,7 @@ namespace storm { template void MarkovAutomaton::writeDotToStream(std::ostream& outStream, bool includeLabeling, storm::storage::BitVector const* subsystem, std::vector const* firstValue, std::vector const* secondValue, std::vector const* stateColoring, std::vector const* colors, std::vector* scheduler, bool finalizeOutput) const { - NondeterministicModel::writeDotToStream(outStream, includeLabeling, subsystem, firstValue, secondValue, stateColoring, colors, scheduler, false); + NondeterministicModel::writeDotToStream(outStream, includeLabeling, subsystem, firstValue, secondValue, stateColoring, colors, scheduler, false); // Write the probability distributions for all the states. for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) { @@ -205,7 +205,7 @@ namespace storm { template std::size_t MarkovAutomaton::getSizeInBytes() const { - return NondeterministicModel::getSizeInBytes() + markovianStates.getSizeInBytes() + exitRates.size() * sizeof(ValueType); + return NondeterministicModel::getSizeInBytes() + markovianStates.getSizeInBytes() + exitRates.size() * sizeof(ValueType); } template @@ -220,9 +220,11 @@ namespace storm { template class MarkovAutomaton; // template class MarkovAutomaton; -//#ifdef STORM_HAVE_CARL -// template class MarkovAutomaton; -//#endif +#ifdef STORM_HAVE_CARL + template class MarkovAutomaton>; + + template class MarkovAutomaton; +#endif } // namespace sparse } // namespace models diff --git a/src/models/sparse/MarkovAutomaton.h b/src/models/sparse/MarkovAutomaton.h index 98d561964..731b845f3 100644 --- a/src/models/sparse/MarkovAutomaton.h +++ b/src/models/sparse/MarkovAutomaton.h @@ -12,7 +12,7 @@ namespace storm { * This class represents a Markov automaton. */ template> - class MarkovAutomaton : public NondeterministicModel { + class MarkovAutomaton : public NondeterministicModel { public: /*! * Constructs a model from the given data. diff --git a/src/models/sparse/Mdp.cpp b/src/models/sparse/Mdp.cpp index 0ba1e7c28..f6e4b4800 100644 --- a/src/models/sparse/Mdp.cpp +++ b/src/models/sparse/Mdp.cpp @@ -9,42 +9,42 @@ namespace storm { namespace models { namespace sparse { - + template Mdp::Mdp(storm::storage::SparseMatrix const& transitionMatrix, storm::models::sparse::StateLabeling const& stateLabeling, std::unordered_map const& rewardModels, boost::optional> const& optionalChoiceLabeling) - : NondeterministicModel(storm::models::ModelType::Mdp, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { + : NondeterministicModel(storm::models::ModelType::Mdp, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { STORM_LOG_THROW(transitionMatrix.isProbabilistic(), storm::exceptions::InvalidArgumentException, "The probability matrix is invalid."); } - - + + template Mdp::Mdp(storm::storage::SparseMatrix&& transitionMatrix, storm::models::sparse::StateLabeling&& stateLabeling, std::unordered_map&& rewardModels, boost::optional>&& optionalChoiceLabeling) - : NondeterministicModel(storm::models::ModelType::Mdp, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { + : NondeterministicModel(storm::models::ModelType::Mdp, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { STORM_LOG_THROW(transitionMatrix.isProbabilistic(), storm::exceptions::InvalidArgumentException, "The probability matrix is invalid."); } - + template - Mdp Mdp::restrictChoiceLabels(LabelSet const& enabledChoiceLabels) const { + Mdp Mdp::restrictChoiceLabels(LabelSet const& enabledChoiceLabels) const { STORM_LOG_THROW(this->hasChoiceLabeling(), storm::exceptions::InvalidArgumentException, "Restriction to label set is impossible for unlabeled model."); - + std::vector const& choiceLabeling = this->getChoiceLabeling(); - + storm::storage::SparseMatrixBuilder transitionMatrixBuilder(0, this->getTransitionMatrix().getColumnCount(), 0, true, true); std::vector newChoiceLabeling; - + // Check for each choice of each state, whether the choice labels are fully contained in the given label set. uint_fast64_t currentRow = 0; for(uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) { bool stateHasValidChoice = false; for (uint_fast64_t choice = this->getTransitionMatrix().getRowGroupIndices()[state]; choice < this->getTransitionMatrix().getRowGroupIndices()[state + 1]; ++choice) { bool choiceValid = std::includes(enabledChoiceLabels.begin(), enabledChoiceLabels.end(), choiceLabeling[choice].begin(), choiceLabeling[choice].end()); - + // If the choice is valid, copy over all its elements. if (choiceValid) { if (!stateHasValidChoice) { @@ -58,7 +58,7 @@ namespace storm { ++currentRow; } } - + // If no choice of the current state may be taken, we insert a self-loop to the state instead. if (!stateHasValidChoice) { transitionMatrixBuilder.newRowGroup(currentRow); @@ -67,27 +67,29 @@ namespace storm { ++currentRow; } } - - Mdp restrictedMdp(transitionMatrixBuilder.build(), storm::models::sparse::StateLabeling(this->getStateLabeling()), - std::unordered_map(this->getRewardModels()), boost::optional>(newChoiceLabeling)); - + + Mdp restrictedMdp(transitionMatrixBuilder.build(), storm::models::sparse::StateLabeling(this->getStateLabeling()), + std::unordered_map(this->getRewardModels()), boost::optional>(newChoiceLabeling)); + return restrictedMdp; } - + template - Mdp Mdp::restrictActions(storm::storage::BitVector const& enabledActions) const { + Mdp Mdp::restrictActions(storm::storage::BitVector const& enabledActions) const { storm::storage::SparseMatrix restrictedTransitions = this->getTransitionMatrix().restrictRows(enabledActions); std::unordered_map newRewardModels; for (auto const& rewardModel : this->getRewardModels()) { newRewardModels.emplace(rewardModel.first, rewardModel.second.restrictActions(enabledActions)); } - return Mdp(restrictedTransitions, this->getStateLabeling(), newRewardModels, this->getOptionalChoiceLabeling()); + return Mdp(restrictedTransitions, this->getStateLabeling(), newRewardModels, this->getOptionalChoiceLabeling()); } - + template class Mdp; template class Mdp; #ifdef STORM_HAVE_CARL + template class Mdp>; + template class Mdp; #endif diff --git a/src/models/sparse/Mdp.h b/src/models/sparse/Mdp.h index 6354551f9..9bc29bbc9 100644 --- a/src/models/sparse/Mdp.h +++ b/src/models/sparse/Mdp.h @@ -57,7 +57,7 @@ namespace storm { * and which ones need to be ignored. * @return A restricted version of the current MDP that only uses choice labels from the given set. */ - Mdp restrictChoiceLabels(LabelSet const& enabledChoiceLabels) const; + Mdp restrictChoiceLabels(LabelSet const& enabledChoiceLabels) const; /*! * Constructs an MDP by copying the current MDP and restricting the choices of each state to the ones given by the bitvector. @@ -65,7 +65,7 @@ namespace storm { * @param enabledActions A BitVector of lenght numberOfChoices(), which is one iff the action should be kept. * @return A subMDP. */ - Mdp restrictActions(storm::storage::BitVector const& enabledActions) const; + Mdp restrictActions(storm::storage::BitVector const& enabledActions) const; }; } // namespace sparse diff --git a/src/models/sparse/Model.cpp b/src/models/sparse/Model.cpp index 4d4914eed..7c8de2519 100644 --- a/src/models/sparse/Model.cpp +++ b/src/models/sparse/Model.cpp @@ -306,6 +306,8 @@ namespace storm { template class Model; #ifdef STORM_HAVE_CARL + template class Model>; + template class Model; #endif diff --git a/src/models/sparse/NondeterministicModel.cpp b/src/models/sparse/NondeterministicModel.cpp index c5e3e9ecf..9cfbe75f9 100644 --- a/src/models/sparse/NondeterministicModel.cpp +++ b/src/models/sparse/NondeterministicModel.cpp @@ -16,7 +16,7 @@ namespace storm { storm::models::sparse::StateLabeling const& stateLabeling, std::unordered_map const& rewardModels, boost::optional> const& optionalChoiceLabeling) - : Model(modelType, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { + : Model(modelType, transitionMatrix, stateLabeling, rewardModels, optionalChoiceLabeling) { // Intentionally left empty. } @@ -26,7 +26,7 @@ namespace storm { storm::models::sparse::StateLabeling&& stateLabeling, std::unordered_map&& rewardModels, boost::optional>&& optionalChoiceLabeling) - : Model(modelType, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), + : Model(modelType, std::move(transitionMatrix), std::move(stateLabeling), std::move(rewardModels), std::move(optionalChoiceLabeling)) { // Intentionally left empty. } @@ -79,7 +79,7 @@ namespace storm { template void NondeterministicModel::writeDotToStream(std::ostream& outStream, bool includeLabeling, storm::storage::BitVector const* subsystem, std::vector const* firstValue, std::vector const* secondValue, std::vector const* stateColoring, std::vector const* colors, std::vector* scheduler, bool finalizeOutput) const { - Model::writeDotToStream(outStream, includeLabeling, subsystem, firstValue, secondValue, stateColoring, colors, scheduler, false); + Model::writeDotToStream(outStream, includeLabeling, subsystem, firstValue, secondValue, stateColoring, colors, scheduler, false); // Write the probability distributions for all the states. for (uint_fast64_t state = 0; state < this->getNumberOfStates(); ++state) { @@ -151,6 +151,8 @@ namespace storm { template class NondeterministicModel; #ifdef STORM_HAVE_CARL + template class NondeterministicModel>; + template class NondeterministicModel; #endif diff --git a/src/models/sparse/StochasticTwoPlayerGame.cpp b/src/models/sparse/StochasticTwoPlayerGame.cpp index ecbb204c5..fbe79af36 100644 --- a/src/models/sparse/StochasticTwoPlayerGame.cpp +++ b/src/models/sparse/StochasticTwoPlayerGame.cpp @@ -34,9 +34,9 @@ namespace storm { template class StochasticTwoPlayerGame; // template class StochasticTwoPlayerGame; -//#ifdef STORM_HAVE_CARL +#ifdef STORM_HAVE_CARL // template class StochasticTwoPlayerGame; -//#endif +#endif } // namespace sparse } // namespace models diff --git a/src/parser/AutoParser.cpp b/src/parser/AutoParser.cpp index ca01c758f..2ec30fb64 100644 --- a/src/parser/AutoParser.cpp +++ b/src/parser/AutoParser.cpp @@ -10,6 +10,8 @@ #include "src/utility/macros.h" #include "src/exceptions/WrongFormatException.h" +#include "src/adapters/CarlAdapter.h" + #include "src/utility/cstring.h" #include "src/utility/OsDetection.h" @@ -19,7 +21,7 @@ namespace storm { using namespace storm::utility::cstring; template - std::shared_ptr> AutoParser::parseModel(std::string const& transitionsFilename, + std::shared_ptr>> AutoParser::parseModel(std::string const& transitionsFilename, std::string const& labelingFilename, std::string const& stateRewardFilename, std::string const& transitionRewardFilename, @@ -33,22 +35,22 @@ namespace storm { switch (type) { case storm::models::ModelType::Dtmc: { - model.reset(new storm::models::sparse::Dtmc>(std::move(DeterministicModelParser::parseDtmc(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename)))); + model = std::shared_ptr>>(new storm::models::sparse::Dtmc>(std::move(DeterministicModelParser::parseDtmc(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename)))); break; } case storm::models::ModelType::Ctmc: { - model.reset(new storm::models::sparse::Ctmc>(std::move(DeterministicModelParser::parseCtmc(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename)))); + model = std::shared_ptr>>(new storm::models::sparse::Ctmc>(std::move(DeterministicModelParser::parseCtmc(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename)))); break; } case storm::models::ModelType::Mdp: { - model.reset(new storm::models::sparse::Mdp>(std::move(NondeterministicModelParser::parseMdp(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename)))); + model = std::shared_ptr>>(new storm::models::sparse::Mdp>(std::move(NondeterministicModelParser::parseMdp(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename)))); break; } case storm::models::ModelType::MarkovAutomaton: { - model.reset(new storm::models::sparse::MarkovAutomaton>(storm::parser::MarkovAutomatonParser::parseMarkovAutomaton(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename))); + model = std::shared_ptr>>(new storm::models::sparse::MarkovAutomaton>(std::move(storm::parser::MarkovAutomatonParser::parseMarkovAutomaton(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename)))); break; } default: @@ -94,6 +96,10 @@ namespace storm { // Explicitly instantiate the parser. template class AutoParser; + +#ifdef STORM_HAVE_CARL + template class AutoParser; +#endif } // namespace parser } // namespace storm diff --git a/src/parser/AutoParser.h b/src/parser/AutoParser.h index fd144b24e..525795e9d 100644 --- a/src/parser/AutoParser.h +++ b/src/parser/AutoParser.h @@ -47,7 +47,7 @@ namespace storm { * is meaningful, this file will not be parsed. * @return A shared_ptr containing the resulting model. */ - static std::shared_ptr> parseModel(std::string const& transitionsFilename, + static std::shared_ptr>> parseModel(std::string const& transitionsFilename, std::string const& labelingFilename, std::string const& stateRewardFilename = "", std::string const& transitionRewardFilename = "", diff --git a/src/parser/DeterministicModelParser.cpp b/src/parser/DeterministicModelParser.cpp index 34bec0855..18f14428a 100644 --- a/src/parser/DeterministicModelParser.cpp +++ b/src/parser/DeterministicModelParser.cpp @@ -9,6 +9,8 @@ #include "src/parser/AtomicPropositionLabelingParser.h" #include "src/parser/SparseStateRewardParser.h" +#include "src/adapters/CarlAdapter.h" + namespace storm { namespace parser { @@ -62,6 +64,10 @@ namespace storm { } template class DeterministicModelParser; + +#ifdef STORM_HAVE_CARL + template class DeterministicModelParser; +#endif } /* namespace parser */ } /* namespace storm */ diff --git a/src/parser/DeterministicSparseTransitionParser.cpp b/src/parser/DeterministicSparseTransitionParser.cpp index bb91355d4..94b82a4c7 100644 --- a/src/parser/DeterministicSparseTransitionParser.cpp +++ b/src/parser/DeterministicSparseTransitionParser.cpp @@ -16,6 +16,8 @@ #include "src/settings/SettingsManager.h" #include "src/settings/modules/GeneralSettings.h" +#include "src/adapters/CarlAdapter.h" + #include "log4cplus/logger.h" #include "log4cplus/loggingmacros.h" extern log4cplus::Logger logger; @@ -297,5 +299,12 @@ namespace storm { template class DeterministicSparseTransitionParser; template storm::storage::SparseMatrix DeterministicSparseTransitionParser::parseDeterministicTransitionRewards(std::string const& filename, storm::storage::SparseMatrix const& transitionMatrix); template storm::storage::SparseMatrix DeterministicSparseTransitionParser::parse(std::string const& filename, bool isRewardFile, storm::storage::SparseMatrix const& transitionMatrix); + +#ifdef STORM_HAVE_CARL + template class DeterministicSparseTransitionParser; + + template storm::storage::SparseMatrix DeterministicSparseTransitionParser::parseDeterministicTransitionRewards(std::string const& filename, storm::storage::SparseMatrix const& transitionMatrix); + template storm::storage::SparseMatrix DeterministicSparseTransitionParser::parse(std::string const& filename, bool isRewardFile, storm::storage::SparseMatrix const& transitionMatrix); +#endif } // namespace parser } // namespace storm diff --git a/src/parser/MarkovAutomatonParser.cpp b/src/parser/MarkovAutomatonParser.cpp index 683b4142c..6a68abda8 100644 --- a/src/parser/MarkovAutomatonParser.cpp +++ b/src/parser/MarkovAutomatonParser.cpp @@ -6,6 +6,8 @@ #include "src/exceptions/WrongFormatException.h" +#include "src/adapters/CarlAdapter.h" + #include "log4cplus/logger.h" #include "log4cplus/loggingmacros.h" extern log4cplus::Logger logger; @@ -31,7 +33,7 @@ namespace storm { stateRewards.reset(storm::parser::SparseStateRewardParser::parseSparseStateReward(transitionMatrix.getColumnCount(), stateRewardFilename)); } std::unordered_map> rewardModels; - rewardModels.insert(std::make_pair("", storm::models::sparse::StandardRewardModel(stateRewards, boost::optional>(), boost::optional>()))); + rewardModels.insert(std::make_pair("", storm::models::sparse::StandardRewardModel(stateRewards, boost::optional>(), boost::optional>()))); // Since Markov Automata do not support transition rewards no path should be given here. if (transitionRewardFilename != "") { @@ -46,6 +48,10 @@ namespace storm { } template class MarkovAutomatonParser; - + +#ifdef STORM_HAVE_CARL + template class MarkovAutomatonParser; +#endif + } // namespace parser } // namespace storm diff --git a/src/parser/MarkovAutomatonSparseTransitionParser.cpp b/src/parser/MarkovAutomatonSparseTransitionParser.cpp index 539a67739..6bc214cab 100644 --- a/src/parser/MarkovAutomatonSparseTransitionParser.cpp +++ b/src/parser/MarkovAutomatonSparseTransitionParser.cpp @@ -8,7 +8,6 @@ #include "src/utility/cstring.h" #include "src/utility/macros.h" - namespace storm { namespace parser { diff --git a/src/parser/NondeterministicModelParser.cpp b/src/parser/NondeterministicModelParser.cpp index 743d6e9b2..220451c33 100644 --- a/src/parser/NondeterministicModelParser.cpp +++ b/src/parser/NondeterministicModelParser.cpp @@ -10,6 +10,8 @@ #include "src/parser/SparseStateRewardParser.h" #include "src/parser/SparseChoiceLabelingParser.h" +#include "src/adapters/CarlAdapter.h" + namespace storm { namespace parser { @@ -31,7 +33,7 @@ namespace storm { } // Only parse transition rewards if a file is given. - boost::optional> transitionRewards; + boost::optional> transitionRewards; if (!transitionRewardFilename.empty()) { transitionRewards = std::move(storm::parser::NondeterministicSparseTransitionParser::parseNondeterministicTransitionRewards(transitionRewardFilename, transitions)); } @@ -61,6 +63,10 @@ namespace storm { } template class NondeterministicModelParser; - + +#ifdef STORM_HAVE_CARL + template class NondeterministicModelParser; +#endif + } /* namespace parser */ } /* namespace storm */ diff --git a/src/parser/NondeterministicSparseTransitionParser.cpp b/src/parser/NondeterministicSparseTransitionParser.cpp index 646fc0352..3136bc36f 100644 --- a/src/parser/NondeterministicSparseTransitionParser.cpp +++ b/src/parser/NondeterministicSparseTransitionParser.cpp @@ -13,6 +13,8 @@ #include "src/utility/cstring.h" +#include "src/adapters/CarlAdapter.h" + #include "log4cplus/logger.h" #include "log4cplus/loggingmacros.h" extern log4cplus::Logger logger; @@ -189,7 +191,7 @@ namespace storm { // Finally, build the actual matrix, test and return it. storm::storage::SparseMatrix resultMatrix = matrixBuilder.build(); - // Since we cannot do the testing if each transition for which there is a reward in the reward file also exists in the transition matrix during parsing, we have to do it afterwards. + // Since we cannot check if each transition for which there is a reward in the reward file also exists in the transition matrix during parsing, we have to do it afterwards. if (isRewardFile && !resultMatrix.isSubmatrixOf(modelInformation)) { LOG4CPLUS_ERROR(logger, "There are rewards for non existent transitions given in the reward file."); throw storm::exceptions::WrongFormatException() << "There are rewards for non existent transitions given in the reward file."; @@ -336,6 +338,13 @@ namespace storm { template class NondeterministicSparseTransitionParser; template storm::storage::SparseMatrix NondeterministicSparseTransitionParser::parseNondeterministicTransitionRewards(std::string const& filename, storm::storage::SparseMatrix const& modelInformation); template storm::storage::SparseMatrix NondeterministicSparseTransitionParser::parse(std::string const& filename, bool isRewardFile, storm::storage::SparseMatrix const& modelInformation); - + +#ifdef STORM_HAVE_CARL + template class NondeterministicSparseTransitionParser; + + template storm::storage::SparseMatrix NondeterministicSparseTransitionParser::parseNondeterministicTransitionRewards(std::string const& filename, storm::storage::SparseMatrix const& modelInformation); + template storm::storage::SparseMatrix NondeterministicSparseTransitionParser::parse(std::string const& filename, bool isRewardFile, storm::storage::SparseMatrix const& modelInformation); +#endif + } // namespace parser } // namespace storm diff --git a/src/parser/SparseStateRewardParser.cpp b/src/parser/SparseStateRewardParser.cpp index d2424740d..b60856eb8 100644 --- a/src/parser/SparseStateRewardParser.cpp +++ b/src/parser/SparseStateRewardParser.cpp @@ -6,6 +6,9 @@ #include "src/exceptions/FileIoException.h" #include "src/utility/cstring.h" #include "src/parser/MappedFile.h" + +#include "src/adapters/CarlAdapter.h" + #include "log4cplus/logger.h" #include "log4cplus/loggingmacros.h" extern log4cplus::Logger logger; @@ -27,7 +30,7 @@ namespace storm { char const* buf = file.getData(); // Create state reward vector with given state count. - std::vector stateRewards(stateCount); + std::vector stateRewards(stateCount); // Now parse state reward assignments. uint_fast64_t state = 0; @@ -71,5 +74,9 @@ namespace storm { template class SparseStateRewardParser; +#ifdef STORM_HAVE_CARL + template class SparseStateRewardParser; +#endif + } // namespace parser } // namespace storm diff --git a/src/storage/SparseMatrix.cpp b/src/storage/SparseMatrix.cpp index 72e516d1e..88abf66a3 100644 --- a/src/storage/SparseMatrix.cpp +++ b/src/storage/SparseMatrix.cpp @@ -1085,7 +1085,8 @@ namespace storm { } template - bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const { + template + bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const { // Check for matching sizes. if (this->getRowCount() != matrix.getRowCount()) return false; if (this->getColumnCount() != matrix.getColumnCount()) return false; @@ -1093,7 +1094,9 @@ namespace storm { // Check the subset property for all rows individually. for (index_type row = 0; row < this->getRowCount(); ++row) { - for (const_iterator it1 = this->begin(row), ite1 = this->end(row), it2 = matrix.begin(row), ite2 = matrix.end(row); it1 != ite1; ++it1) { + auto it2 = matrix.begin(row); + auto ite2 = matrix.end(row); + for (const_iterator it1 = this->begin(row), ite1 = this->end(row); it1 != ite1; ++it1) { // Skip over all entries of the other matrix that are before the current entry in the current matrix. while (it2 != ite2 && it2->getColumn() < it1->getColumn()) { ++it2; @@ -1169,14 +1172,16 @@ namespace storm { template class SparseMatrix; template std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix); template std::vector SparseMatrix::getPointwiseProductRowSumVector(storm::storage::SparseMatrix const& otherMatrix) const; - - // float + template bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const; + + // float template class MatrixEntry::index_type, float>; template std::ostream& operator<<(std::ostream& out, MatrixEntry const& entry); template class SparseMatrixBuilder; template class SparseMatrix; template std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix); template std::vector SparseMatrix::getPointwiseProductRowSumVector(storm::storage::SparseMatrix const& otherMatrix) const; + template bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const; // int template class MatrixEntry::index_type, int>; @@ -1184,6 +1189,7 @@ namespace storm { template class SparseMatrixBuilder; template class SparseMatrix; template std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix); + template bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const; #ifdef STORM_HAVE_CARL // Rat Function @@ -1196,6 +1202,7 @@ namespace storm { template std::vector SparseMatrix::getPointwiseProductRowSumVector(storm::storage::SparseMatrix const& otherMatrix) const; template std::vector SparseMatrix::getPointwiseProductRowSumVector(storm::storage::SparseMatrix const& otherMatrix) const; template std::vector SparseMatrix::getPointwiseProductRowSumVector(storm::storage::SparseMatrix const& otherMatrix) const; + template bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const; // Intervals template std::vector SparseMatrix::getPointwiseProductRowSumVector(storm::storage::SparseMatrix const& otherMatrix) const; @@ -1205,6 +1212,9 @@ namespace storm { template class SparseMatrix; template std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix); template std::vector SparseMatrix::getPointwiseProductRowSumVector(storm::storage::SparseMatrix const& otherMatrix) const; + template bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const; + + template bool SparseMatrix::isSubmatrixOf(SparseMatrix const& matrix) const; #endif diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index 03de1bd6b..1b5bef847 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -753,7 +753,8 @@ namespace storm { * @param matrix The matrix that possibly is a supermatrix of the current matrix. * @return True iff the current matrix is a submatrix of the given matrix. */ - bool isSubmatrixOf(SparseMatrix const& matrix) const; + template + bool isSubmatrixOf(SparseMatrix const& matrix) const; template friend std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix);