Browse Source
PRISM classes almost adapted to new expression classes. TODO: source file of PRISM program.
PRISM classes almost adapted to new expression classes. TODO: source file of PRISM program.
Former-commit-id: 929a78684d
tempestpy_adaptions
dehnert
11 years ago
9 changed files with 387 additions and 567 deletions
-
189src/storage/prism/Module.cpp
-
160src/storage/prism/Module.h
-
175src/storage/prism/Program.h
-
51src/storage/prism/RewardModel.cpp
-
73src/storage/prism/RewardModel.h
-
38src/storage/prism/StateReward.cpp
-
76src/storage/prism/StateReward.h
-
41src/storage/prism/TransitionReward.cpp
-
151src/storage/prism/TransitionReward.h
@ -1,88 +1,81 @@ |
|||||
/* |
|
||||
* RewardModel.h |
|
||||
* |
|
||||
* Created on: 04.01.2013 |
|
||||
* Author: Christian Dehnert |
|
||||
*/ |
|
||||
|
|
||||
#ifndef STORM_IR_REWARDMODEL_H_ |
|
||||
#define STORM_IR_REWARDMODEL_H_ |
|
||||
|
#ifndef STORM_STORAGE_PRISM_REWARDMODEL_H_ |
||||
|
#define STORM_STORAGE_PRISM_REWARDMODEL_H_ |
||||
|
|
||||
#include <string> |
#include <string> |
||||
#include <vector> |
#include <vector> |
||||
|
|
||||
#include "StateReward.h" |
|
||||
#include "TransitionReward.h" |
|
||||
|
#include "src/storage/prism/StateReward.h" |
||||
|
#include "src/storage/prism/TransitionReward.h" |
||||
|
|
||||
namespace storm { |
namespace storm { |
||||
namespace ir { |
|
||||
|
|
||||
/*! |
|
||||
* A class representing a reward model. |
|
||||
*/ |
|
||||
|
namespace prism { |
||||
class RewardModel { |
class RewardModel { |
||||
public: |
public: |
||||
/*! |
/*! |
||||
* Default constructor. Creates an empty reward model. |
|
||||
*/ |
|
||||
RewardModel(); |
|
||||
|
|
||||
/*! |
|
||||
* Creates a reward module with the given name, state and transition rewards. |
|
||||
|
* Creates a reward model with the given name, state and transition rewards. |
||||
* |
* |
||||
* @param rewardModelName The name of the reward model. |
* @param rewardModelName The name of the reward model. |
||||
* @param stateRewards A vector of state-based rewards. |
* @param stateRewards A vector of state-based rewards. |
||||
* @param transitionRewards A vector of transition-based rewards. |
* @param transitionRewards A vector of transition-based rewards. |
||||
*/ |
*/ |
||||
RewardModel(std::string const& rewardModelName, std::vector<storm::ir::StateReward> const& stateRewards, std::vector<storm::ir::TransitionReward> const& transitionRewards); |
|
||||
|
RewardModel(std::string const& rewardModelName, std::vector<storm::prism::StateReward> const& stateRewards, std::vector<storm::prism::TransitionReward> const& transitionRewards); |
||||
|
|
||||
|
// Create default implementations of constructors/assignment. |
||||
|
RewardModel() = default; |
||||
|
RewardModel(RewardModel const& otherVariable) = default; |
||||
|
RewardModel& operator=(RewardModel const& otherVariable)= default; |
||||
|
RewardModel(RewardModel&& otherVariable) = default; |
||||
|
RewardModel& operator=(RewardModel&& otherVariable) = default; |
||||
|
|
||||
/*! |
/*! |
||||
* Retrieves a string representation of this reward model. |
|
||||
|
* Retrieves the name of the reward model. |
||||
* |
* |
||||
* @return a string representation of this reward model. |
|
||||
|
* @return The name of the reward model. |
||||
*/ |
*/ |
||||
std::string toString() const; |
|
||||
|
std::string const& getName() const; |
||||
|
|
||||
/*! |
/*! |
||||
* Check, if there are any state rewards. |
|
||||
|
* Retrieves whether there are any state rewards. |
||||
* |
* |
||||
* @return True, iff there are any state rewards. |
|
||||
|
* @return True iff there are any state rewards. |
||||
*/ |
*/ |
||||
bool hasStateRewards() const; |
bool hasStateRewards() const; |
||||
|
|
||||
/*! |
/*! |
||||
* Retrieves a vector of state rewards associated with this reward model. |
|
||||
|
* Retrieves all state rewards associated with this reward model. |
||||
* |
* |
||||
* @return A vector containing the state rewards associated with this reward model. |
|
||||
|
* @return The state rewards associated with this reward model. |
||||
*/ |
*/ |
||||
std::vector<storm::ir::StateReward> const& getStateRewards() const; |
|
||||
|
std::vector<storm::prism::StateReward> const& getStateRewards() const; |
||||
|
|
||||
/*! |
/*! |
||||
* Check, if there are any transition rewards. |
|
||||
|
* Retrieves whether there are any transition rewards. |
||||
* |
* |
||||
* @return True, iff there are any transition rewards associated with this reward model. |
|
||||
|
* @return True iff there are any transition rewards. |
||||
*/ |
*/ |
||||
bool hasTransitionRewards() const; |
bool hasTransitionRewards() const; |
||||
|
|
||||
/*! |
/*! |
||||
* Retrieves a vector of transition rewards associated with this reward model. |
|
||||
|
* Retrieves all transition rewards associated with this reward model. |
||||
* |
* |
||||
* @return A vector of transition rewards associated with this reward model. |
|
||||
|
* @return The transition rewards associated with this reward model. |
||||
*/ |
*/ |
||||
std::vector<storm::ir::TransitionReward> const& getTransitionRewards() const; |
|
||||
|
std::vector<storm::prism::TransitionReward> const& getTransitionRewards() const; |
||||
|
|
||||
|
friend std::ostream& operator<<(std::ostream& stream, RewardModel const& rewardModel); |
||||
|
|
||||
private: |
private: |
||||
// The name of the reward model. |
// The name of the reward model. |
||||
std::string rewardModelName; |
std::string rewardModelName; |
||||
|
|
||||
// The state-based rewards associated with this reward model. |
// The state-based rewards associated with this reward model. |
||||
std::vector<storm::ir::StateReward> stateRewards; |
|
||||
|
std::vector<storm::prism::StateReward> stateRewards; |
||||
|
|
||||
// The transition-based rewards associated with this reward model. |
// The transition-based rewards associated with this reward model. |
||||
std::vector<storm::ir::TransitionReward> transitionRewards; |
|
||||
|
std::vector<storm::prism::TransitionReward> transitionRewards; |
||||
}; |
}; |
||||
|
|
||||
} // namespace ir |
|
||||
|
} // namespace prism |
||||
} // namespace storm |
} // namespace storm |
||||
|
|
||||
#endif /* STORM_IR_REWARDMODEL_H_ */ |
|
||||
|
#endif /* STORM_STORAGE_PRISM_REWARDMODEL_H_ */ |
@ -1,38 +1,22 @@ |
|||||
/*
|
|
||||
* StateReward.cpp |
|
||||
* |
|
||||
* Created on: 12.01.2013 |
|
||||
* Author: Christian Dehnert |
|
||||
*/ |
|
||||
|
|
||||
#include <sstream>
|
|
||||
|
|
||||
#include "StateReward.h"
|
|
||||
|
#include "src/storage/prism/StateReward.h"
|
||||
|
|
||||
namespace storm { |
namespace storm { |
||||
namespace ir { |
|
||||
|
|
||||
StateReward::StateReward() : statePredicate(), rewardValue() { |
|
||||
|
namespace prism { |
||||
|
StateReward::StateReward(storm::expressions::Expression const& statePredicateExpression, storm::expressions::Expression const& rewardValueExpression) : statePredicateExpression(statePredicateExpression), rewardValueExpression(rewardValueExpression) { |
||||
// Nothing to do here.
|
// Nothing to do here.
|
||||
} |
} |
||||
|
|
||||
StateReward::StateReward(storm::expressions::Expression const& statePredicate, storm::expressions::Expression const& rewardValue) : statePredicate(statePredicate), rewardValue(rewardValue) { |
|
||||
// Nothing to do here.
|
|
||||
|
storm::expressions::Expression const& StateReward::getStatePredicateExpression() const { |
||||
|
return this->statePredicateExpression; |
||||
} |
} |
||||
|
|
||||
std::string StateReward::toString() const { |
|
||||
std::stringstream result; |
|
||||
result << "\t" << statePredicate << ": " << rewardValue << ";"; |
|
||||
return result.str(); |
|
||||
|
storm::expressions::Expression const& StateReward::getRewardValueExpression() const { |
||||
|
return this->rewardValueExpression; |
||||
} |
} |
||||
|
|
||||
storm::expressions::Expression const& StateReward::getStatePredicate() const { |
|
||||
return this->statePredicate; |
|
||||
|
std::ostream& operator<<(std::ostream& stream, StateReward const& stateReward) { |
||||
|
stream << "\t" << stateReward.getStatePredicateExpression() << ": " << stateReward.getRewardValueExpression() << ";"; |
||||
|
return stream; |
||||
} |
} |
||||
|
|
||||
storm::expressions::Expression const& StateReward::getRewardValue() const { |
|
||||
return this->rewardValue; |
|
||||
} |
|
||||
|
|
||||
} // namespace ir
|
|
||||
|
} // namespace prism
|
||||
} // namespace storm
|
} // namespace storm
|
@ -1,85 +1,53 @@ |
|||||
/* |
|
||||
* StateReward.h |
|
||||
* |
|
||||
* Created on: Jan 10, 2013 |
|
||||
* Author: Christian Dehnert |
|
||||
*/ |
|
||||
|
|
||||
#ifndef STORM_IR_STATEREWARD_H_ |
|
||||
#define STORM_IR_STATEREWARD_H_ |
|
||||
|
|
||||
#include <memory> |
|
||||
|
#ifndef STORM_STORAGE_PRISM_STATEREWARD_H_ |
||||
|
#define STORM_STORAGE_PRISM_STATEREWARD_H_ |
||||
|
|
||||
#include "src/storage/expressions/Expression.h" |
#include "src/storage/expressions/Expression.h" |
||||
|
|
||||
namespace storm { |
namespace storm { |
||||
namespace ir { |
|
||||
|
|
||||
/*! |
|
||||
* A class representing a state reward. |
|
||||
*/ |
|
||||
|
namespace prism { |
||||
class StateReward { |
class StateReward { |
||||
public: |
public: |
||||
/*! |
/*! |
||||
* Default constructor. Creates an empty state reward. |
|
||||
*/ |
|
||||
StateReward(); |
|
||||
|
|
||||
/*! |
|
||||
* Creates a state reward for the states satisfying the given expression with the value given |
|
||||
* by a second expression. |
|
||||
* |
|
||||
* @param statePredicate The predicate that states earning this state-based reward need to |
|
||||
* satisfy. |
|
||||
* @param rewardValue An expression specifying the values of the rewards to attach to the |
|
||||
* states. |
|
||||
*/ |
|
||||
StateReward(storm::expressions::Expression const& statePredicate, storm::expressions::Expression const& rewardValue); |
|
||||
|
|
||||
/*! |
|
||||
* Performs a deep-copy of the given reward. |
|
||||
* |
|
||||
* @param otherReward The reward to copy. |
|
||||
*/ |
|
||||
StateReward(StateReward const& otherReward) = default; |
|
||||
|
|
||||
/*! |
|
||||
* Performs a deep-copy of the given reward and assigns it to the current one. |
|
||||
|
* Creates a state reward for the states satisfying the given expression with the value given by a second |
||||
|
* expression. |
||||
* |
* |
||||
* @param otherReward The reward to assign. |
|
||||
|
* @param statePredicateExpression The predicate that states earning this state-based reward need to satisfy. |
||||
|
* @param rewardValueExpression An expression specifying the values of the rewards to attach to the states. |
||||
*/ |
*/ |
||||
StateReward& operator=(StateReward const& otherReward) = default; |
|
||||
|
StateReward(storm::expressions::Expression const& statePredicateExpression, storm::expressions::Expression const& rewardValueExpression); |
||||
|
|
||||
/*! |
|
||||
* Retrieves a string representation of this state reward. |
|
||||
* |
|
||||
* @return A string representation of this state reward. |
|
||||
*/ |
|
||||
std::string toString() const; |
|
||||
|
// Create default implementations of constructors/assignment. |
||||
|
StateReward() = default; |
||||
|
StateReward(StateReward const& otherVariable) = default; |
||||
|
StateReward& operator=(StateReward const& otherVariable)= default; |
||||
|
StateReward(StateReward&& otherVariable) = default; |
||||
|
StateReward& operator=(StateReward&& otherVariable) = default; |
||||
|
|
||||
/*! |
/*! |
||||
* Retrieves the state predicate that is associated with this state reward. |
* Retrieves the state predicate that is associated with this state reward. |
||||
* |
* |
||||
* @return The state predicate that is associated with this state reward. |
* @return The state predicate that is associated with this state reward. |
||||
*/ |
*/ |
||||
storm::expressions::Expression const& getStatePredicate() const; |
|
||||
|
storm::expressions::Expression const& getStatePredicateExpression() const; |
||||
|
|
||||
/*! |
/*! |
||||
* Retrieves the reward value associated with this state reward. |
* Retrieves the reward value associated with this state reward. |
||||
* |
* |
||||
* @return The reward value associated with this state reward. |
* @return The reward value associated with this state reward. |
||||
*/ |
*/ |
||||
storm::expressions::Expression const& getRewardValue() const; |
|
||||
|
storm::expressions::Expression const& getRewardValueExpression() const; |
||||
|
|
||||
|
friend std::ostream& operator<<(std::ostream& stream, StateReward const& stateReward); |
||||
|
|
||||
private: |
private: |
||||
// The predicate that characterizes the states that obtain this reward. |
// The predicate that characterizes the states that obtain this reward. |
||||
storm::expressions::Expression statePredicate; |
|
||||
|
storm::expressions::Expression statePredicateExpression; |
||||
|
|
||||
// The expression that specifies the value of the reward obtained. |
// The expression that specifies the value of the reward obtained. |
||||
storm::expressions::Expression rewardValue; |
|
||||
|
storm::expressions::Expression rewardValueExpression; |
||||
}; |
}; |
||||
|
|
||||
} // namespace ir |
|
||||
|
} // namespace prism |
||||
} // namespace storm |
} // namespace storm |
||||
|
|
||||
#endif /* STORM_IR_STATEREWARD_H_ */ |
|
||||
|
#endif /* STORM_STORAGE_PRISM_STATEREWARD_H_ */ |
@ -1,42 +1,27 @@ |
|||||
/*
|
|
||||
* TransitionReward.cpp |
|
||||
* |
|
||||
* Created on: 12.01.2013 |
|
||||
* Author: Christian Dehnert |
|
||||
*/ |
|
||||
|
|
||||
#include <sstream>
|
|
||||
|
|
||||
#include "TransitionReward.h"
|
|
||||
|
#include "src/storage/prism/TransitionReward.h"
|
||||
|
|
||||
namespace storm { |
namespace storm { |
||||
namespace ir { |
|
||||
|
|
||||
TransitionReward::TransitionReward() : commandName(), statePredicate(), rewardValue() { |
|
||||
// Nothing to do here.
|
|
||||
} |
|
||||
|
|
||||
TransitionReward::TransitionReward(std::string const& commandName, storm::expressions::Expression const& statePredicate, storm::expressions::Expression const& rewardValue) : commandName(commandName), statePredicate(statePredicate), rewardValue(rewardValue) { |
|
||||
|
namespace prism { |
||||
|
TransitionReward::TransitionReward(std::string const& commandName, storm::expressions::Expression const& statePredicateExpression, storm::expressions::Expression const& rewardValueExpression) : commandName(commandName), statePredicateExpression(statePredicateExpression), rewardValueExpression(rewardValueExpression) { |
||||
// Nothing to do here.
|
// Nothing to do here.
|
||||
} |
} |
||||
|
|
||||
std::string TransitionReward::toString() const { |
|
||||
std::stringstream result; |
|
||||
result << "\t[" << commandName << "] " << statePredicate << ": " << rewardValue << ";"; |
|
||||
return result.str(); |
|
||||
} |
|
||||
|
|
||||
std::string const& TransitionReward::getActionName() const { |
std::string const& TransitionReward::getActionName() const { |
||||
return this->commandName; |
return this->commandName; |
||||
} |
} |
||||
|
|
||||
storm::expressions::Expression const& TransitionReward::getStatePredicate() const { |
|
||||
return this->statePredicate; |
|
||||
|
storm::expressions::Expression const& TransitionReward::getStatePredicateExpression() const { |
||||
|
return this->statePredicateExpression; |
||||
|
} |
||||
|
|
||||
|
storm::expressions::Expression const& TransitionReward::getRewardValueExpression() const { |
||||
|
return this->rewardValueExpression; |
||||
} |
} |
||||
|
|
||||
storm::expressions::Expression const& TransitionReward::getRewardValue() const { |
|
||||
return this->rewardValue; |
|
||||
|
std::ostream& operator<<(std::ostream& stream, TransitionReward const& transitionReward) { |
||||
|
stream << "\t[" << transitionReward.getActionName() << "] " << transitionReward.getStatePredicateExpression() << ": " << transitionReward.getRewardValueExpression() << ";"; |
||||
|
return stream; |
||||
} |
} |
||||
|
|
||||
} // namespace ir
|
|
||||
|
} // namespace prism
|
||||
} // namespace storm
|
} // namespace storm
|
@ -1,99 +1,66 @@ |
|||||
/* |
|
||||
* TransitionReward.h |
|
||||
* |
|
||||
* Created on: Jan 10, 2013 |
|
||||
* Author: Christian Dehnert |
|
||||
*/ |
|
||||
|
|
||||
#ifndef STORM_IR_TRANSITIONREWARD_H_ |
|
||||
#define STORM_IR_TRANSITIONREWARD_H_ |
|
||||
|
|
||||
#include <memory> |
|
||||
|
#ifndef STORM_STORAGE_PRISM_TRANSITIONREWARD_H_ |
||||
|
#define STORM_STORAGE_PRISM_TRANSITIONREWARD_H_ |
||||
|
|
||||
#include "src/storage/expressions/Expression.h" |
#include "src/storage/expressions/Expression.h" |
||||
|
|
||||
namespace storm { |
namespace storm { |
||||
|
namespace prism { |
||||
|
class TransitionReward { |
||||
|
public: |
||||
|
/*! |
||||
|
* Creates a transition reward for the transitions with the given name emanating from states satisfying the |
||||
|
* given expression with the value given by another expression. |
||||
|
* |
||||
|
* @param actionName The name of the command that obtains this reward. |
||||
|
* @param statePredicateExpression The predicate that needs to hold before taking a transition with the previously |
||||
|
* specified name in order to obtain the reward. |
||||
|
* @param rewardValueExpression An expression specifying the values of the rewards to attach to the transitions. |
||||
|
*/ |
||||
|
TransitionReward(std::string const& actionName, storm::expressions::Expression const& statePredicateExpression, storm::expressions::Expression const& rewardValueExpression); |
||||
|
|
||||
|
// Create default implementations of constructors/assignment. |
||||
|
TransitionReward() = default; |
||||
|
TransitionReward(TransitionReward const& otherVariable) = default; |
||||
|
TransitionReward& operator=(TransitionReward const& otherVariable)= default; |
||||
|
TransitionReward(TransitionReward&& otherVariable) = default; |
||||
|
TransitionReward& operator=(TransitionReward&& otherVariable) = default; |
||||
|
|
||||
|
/*! |
||||
|
* Retrieves the action name that is associated with this transition reward. |
||||
|
* |
||||
|
* @return The action name that is associated with this transition reward. |
||||
|
*/ |
||||
|
std::string const& getActionName() const; |
||||
|
|
||||
|
/*! |
||||
|
* Retrieves the state predicate expression that is associated with this state reward. |
||||
|
* |
||||
|
* @return The state predicate expression that is associated with this state reward. |
||||
|
*/ |
||||
|
storm::expressions::Expression const& getStatePredicateExpression() const; |
||||
|
|
||||
|
/*! |
||||
|
* Retrieves the reward value expression associated with this state reward. |
||||
|
* |
||||
|
* @return The reward value expression associated with this state reward. |
||||
|
*/ |
||||
|
storm::expressions::Expression const& getRewardValueExpression() const; |
||||
|
|
||||
|
friend std::ostream& operator<<(std::ostream& stream, TransitionReward const& transitionReward); |
||||
|
|
||||
namespace ir { |
|
||||
|
|
||||
/*! |
|
||||
* A class representing a transition reward. |
|
||||
*/ |
|
||||
class TransitionReward { |
|
||||
public: |
|
||||
/*! |
|
||||
* Default constructor. Creates an empty transition reward. |
|
||||
*/ |
|
||||
TransitionReward(); |
|
||||
|
|
||||
/*! |
|
||||
* Creates a transition reward for the transitions with the given name emanating from states |
|
||||
* satisfying the given expression with the value given by another expression. |
|
||||
* |
|
||||
* @param commandName The name of the command that obtains this reward. |
|
||||
* @param statePredicate The predicate that needs to hold before taking a transition with the |
|
||||
* previously specified name in order to obtain the reward. |
|
||||
* @param rewardValue An expression specifying the values of the rewards to attach to the |
|
||||
* transitions. |
|
||||
*/ |
|
||||
TransitionReward(std::string const& commandName, storm::expressions::Expression const& statePredicate, storm::expressions::Expression const& rewardValue); |
|
||||
|
|
||||
/*! |
|
||||
* Performs a deep-copy of the given transition reward. |
|
||||
* |
|
||||
* @param otherReward The transition reward to copy. |
|
||||
*/ |
|
||||
TransitionReward(TransitionReward const& otherReward) = default; |
|
||||
|
|
||||
/*! |
|
||||
* Performs a deep-copy of the given transition reward and assigns it to the current one. |
|
||||
* |
|
||||
* @param otherReward The reward to assign. |
|
||||
*/ |
|
||||
TransitionReward& operator=(TransitionReward const& otherReward) = default; |
|
||||
|
|
||||
/*! |
|
||||
* Retrieves a string representation of this transition reward. |
|
||||
* |
|
||||
* @return A string representation of this transition reward. |
|
||||
*/ |
|
||||
std::string toString() const; |
|
||||
|
|
||||
/*! |
|
||||
* Retrieves the action name that is associated with this transition reward. |
|
||||
* |
|
||||
* @return The action name that is associated with this transition reward. |
|
||||
*/ |
|
||||
std::string const& getActionName() const; |
|
||||
|
|
||||
/*! |
|
||||
* Retrieves the state predicate that is associated with this state reward. |
|
||||
* |
|
||||
* @return The state predicate that is associated with this state reward. |
|
||||
*/ |
|
||||
storm::expressions::Expression const& getStatePredicate() const; |
|
||||
|
|
||||
/*! |
|
||||
* Retrieves the reward value associated with this state reward. |
|
||||
* |
|
||||
* @return The reward value associated with this state reward. |
|
||||
*/ |
|
||||
storm::expressions::Expression const& getRewardValue() const; |
|
||||
|
|
||||
private: |
|
||||
// The name of the command this transition-based reward is attached to. |
|
||||
std::string commandName; |
|
||||
|
|
||||
// A predicate that needs to be satisfied by states for the reward to be obtained (by taking |
|
||||
// a corresponding command transition). |
|
||||
storm::expressions::Expression statePredicate; |
|
||||
|
|
||||
// The expression specifying the value of the reward obtained along the transitions. |
|
||||
storm::expressions::Expression rewardValue; |
|
||||
}; |
|
||||
|
|
||||
} // namespace ir |
|
||||
|
|
||||
|
private: |
||||
|
// The name of the command this transition-based reward is attached to. |
||||
|
std::string commandName; |
||||
|
|
||||
|
// A predicate that needs to be satisfied by states for the reward to be obtained (by taking |
||||
|
// a corresponding command transition). |
||||
|
storm::expressions::Expression statePredicateExpression; |
||||
|
|
||||
|
// The expression specifying the value of the reward obtained along the transitions. |
||||
|
storm::expressions::Expression rewardValueExpression; |
||||
|
}; |
||||
|
|
||||
|
} // namespace prism |
||||
} // namespace storm |
} // namespace storm |
||||
|
|
||||
#endif /* STORM_IR_TRANSITIONREWARD_H_ */ |
|
||||
|
#endif /* STORM_STORAGE_PRISM_TRANSITIONREWARD_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue