Browse Source
			
			
			Removed some unnecessary boost stuff from IR expressions. Separated header and source file for all non-expression IR entities (expressions are still to come). Added comments for these classes.
			
			
				main
			
			
		
		Removed some unnecessary boost stuff from IR expressions. Separated header and source file for all non-expression IR entities (expressions are still to come). Added comments for these classes.
	
		
	
			
			
				main
			
			
		
				 36 changed files with 892 additions and 399 deletions
			
			
		- 
					46src/ir/Assignment.cpp
- 
					70src/ir/Assignment.h
- 
					41src/ir/BooleanVariable.cpp
- 
					55src/ir/BooleanVariable.h
- 
					43src/ir/Command.cpp
- 
					60src/ir/Command.h
- 
					9src/ir/IR.h
- 
					39src/ir/IntegerVariable.cpp
- 
					61src/ir/IntegerVariable.h
- 
					46src/ir/Module.cpp
- 
					70src/ir/Module.h
- 
					67src/ir/Program.cpp
- 
					114src/ir/Program.h
- 
					42src/ir/RewardModel.cpp
- 
					67src/ir/RewardModel.h
- 
					35src/ir/StateReward.cpp
- 
					51src/ir/StateReward.h
- 
					35src/ir/TransitionReward.cpp
- 
					53src/ir/TransitionReward.h
- 
					45src/ir/Update.cpp
- 
					61src/ir/Update.h
- 
					38src/ir/Variable.cpp
- 
					68src/ir/Variable.h
- 
					7src/ir/expressions/BinaryBooleanFunctionExpression.h
- 
					7src/ir/expressions/BinaryNumericalFunctionExpression.h
- 
					7src/ir/expressions/BinaryRelationExpression.h
- 
					7src/ir/expressions/BooleanConstantExpression.h
- 
					5src/ir/expressions/BooleanLiteral.h
- 
					5src/ir/expressions/ConstantExpression.h
- 
					5src/ir/expressions/DoubleConstantExpression.h
- 
					5src/ir/expressions/DoubleLiteral.h
- 
					5src/ir/expressions/IntegerConstantExpression.h
- 
					5src/ir/expressions/IntegerLiteral.h
- 
					6src/ir/expressions/UnaryBooleanFunctionExpression.h
- 
					6src/ir/expressions/UnaryNumericalFunctionExpression.h
- 
					5src/ir/expressions/VariableExpression.h
| @ -0,0 +1,46 @@ | |||
| /*
 | |||
|  * Assignment.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "Assignment.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| Assignment::Assignment() : variableName(), expression() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| Assignment::Assignment(std::string variableName, std::shared_ptr<storm::ir::expressions::BaseExpression> expression) | |||
| 	: variableName(variableName), expression(expression) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Returns the name of the variable associated with this assignment.
 | |||
| std::string const& Assignment::getVariableName() const { | |||
| 	return variableName; | |||
| } | |||
| 
 | |||
| // Returns the expression associated with this assignment.
 | |||
| std::shared_ptr<storm::ir::expressions::BaseExpression> const& Assignment::getExpression() const { | |||
| 	return expression; | |||
| } | |||
| 
 | |||
| // Build a string representation of the assignment.
 | |||
| std::string Assignment::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << "(" << variableName << "' = " << expression->toString() << ")"; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,41 @@ | |||
| /*
 | |||
|  * BooleanVariable.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "BooleanVariable.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| BooleanVariable::BooleanVariable() : Variable() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| BooleanVariable::BooleanVariable(std::string variableName, | |||
| 		std::shared_ptr<storm::ir::expressions::BaseExpression> initialValue) | |||
| 		: Variable(variableName,  initialValue) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the variable.
 | |||
| std::string BooleanVariable::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << getVariableName() << ": bool"; | |||
| 	if (this->getInitialValue() != nullptr) { | |||
| 		result << " init " << this->getInitialValue()->toString(); | |||
| 	} | |||
| 	result << ";"; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,43 @@ | |||
| /*
 | |||
|  * Command.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "Command.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| Command::Command() : commandName(), guardExpression(), updates() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| Command::Command(std::string commandName, std::shared_ptr<storm::ir::expressions::BaseExpression> guardExpression, std::vector<storm::ir::Update> updates) | |||
| 		: commandName(commandName), guardExpression(guardExpression), updates(updates) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the command.
 | |||
| std::string Command::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << "[" << commandName << "] " << guardExpression->toString() << " -> "; | |||
| 	for (uint_fast64_t i = 0; i < updates.size(); ++i) { | |||
| 		result << updates[i].toString(); | |||
| 		if (i < updates.size() - 1) { | |||
| 			result << " + "; | |||
| 		} | |||
| 	} | |||
| 	result << ";"; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,39 @@ | |||
| /*
 | |||
|  * IntegerVariable.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "IntegerVariable.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| IntegerVariable::IntegerVariable() : lowerBound(), upperBound() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| IntegerVariable::IntegerVariable(std::string variableName, std::shared_ptr<storm::ir::expressions::BaseExpression> lowerBound, std::shared_ptr<storm::ir::expressions::BaseExpression> upperBound, std::shared_ptr<storm::ir::expressions::BaseExpression> initialValue) : Variable(variableName, initialValue), lowerBound(lowerBound), upperBound(upperBound) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the variable.
 | |||
| std::string IntegerVariable::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << this->getVariableName() << ": [" << lowerBound->toString() << ".." << upperBound->toString() << "]"; | |||
| 	if (this->getInitialValue() != nullptr) { | |||
| 		result << " init " + this->getInitialValue()->toString(); | |||
| 	} | |||
| 	result << ";"; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,46 @@ | |||
| /*
 | |||
|  * Module.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "Module.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| Module::Module() : moduleName(), booleanVariables(), integerVariables(), commands() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| Module::Module(std::string moduleName, std::map<std::string, storm::ir::BooleanVariable> booleanVariables, std::map<std::string, storm::ir::IntegerVariable> integerVariables, std::vector<storm::ir::Command> commands) | |||
| 	: moduleName(moduleName), booleanVariables(booleanVariables), integerVariables(integerVariables), commands(commands) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the variable.
 | |||
| std::string Module::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << "module " << moduleName << std::endl; | |||
| 	for (auto variable : booleanVariables) { | |||
| 		result << "\t" << variable.second.toString() << std::endl; | |||
| 	} | |||
| 	for (auto variable : integerVariables) { | |||
| 		result << "\t" << variable.second.toString() << std::endl; | |||
| 	} | |||
| 	for (auto command : commands) { | |||
| 		result << "\t" << command.toString() << std::endl; | |||
| 	} | |||
| 	result << "endmodule" << std::endl; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,67 @@ | |||
| /*
 | |||
|  * Program.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "Program.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| Program::Program() : modelType(UNDEFINED), booleanUndefinedConstantExpressions(), integerUndefinedConstantExpressions(), doubleUndefinedConstantExpressions(), modules(), rewards() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| Program::Program(ModelType modelType, std::map<std::string, std::shared_ptr<storm::ir::expressions::BooleanConstantExpression>> booleanUndefinedConstantExpressions, std::map<std::string, std::shared_ptr<storm::ir::expressions::IntegerConstantExpression>> integerUndefinedConstantExpressions, std::map<std::string, std::shared_ptr<storm::ir::expressions::DoubleConstantExpression>> doubleUndefinedConstantExpressions, std::vector<storm::ir::Module> modules, std::map<std::string, storm::ir::RewardModel> rewards, std::map<std::string, std::shared_ptr<storm::ir::expressions::BaseExpression>> labels) | |||
| 	: modelType(modelType), booleanUndefinedConstantExpressions(booleanUndefinedConstantExpressions), integerUndefinedConstantExpressions(integerUndefinedConstantExpressions), doubleUndefinedConstantExpressions(doubleUndefinedConstantExpressions), modules(modules), rewards(rewards), labels(labels) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the program.
 | |||
| std::string Program::toString() const { | |||
| 	std::stringstream result; | |||
| 	switch (modelType) { | |||
| 	case UNDEFINED: result << "undefined"; break; | |||
| 	case DTMC: result << "dtmc"; break; | |||
| 	case CTMC: result << "ctmc"; break; | |||
| 	case MDP: result << "mdp"; break; | |||
| 	case CTMDP: result << "ctmdp"; break; | |||
| 	} | |||
| 	result << std::endl; | |||
| 
 | |||
| 	for (auto element : booleanUndefinedConstantExpressions) { | |||
| 		result << "const bool " << element.first << ";" << std::endl; | |||
| 	} | |||
| 	for (auto element : integerUndefinedConstantExpressions) { | |||
| 		result << "const int " << element.first << ";" << std::endl; | |||
| 	} | |||
| 	for (auto element : doubleUndefinedConstantExpressions) { | |||
| 		result << "const double " << element.first << ";" << std::endl; | |||
| 	} | |||
| 	result << std::endl; | |||
| 
 | |||
| 	for (auto mod : modules) { | |||
| 		result << mod.toString() << std::endl; | |||
| 	} | |||
| 
 | |||
| 	for (auto rewardModel : rewards) { | |||
| 		result << rewardModel.second.toString() << std::endl; | |||
| 	} | |||
| 
 | |||
| 	for (auto label : labels) { | |||
| 		result << "label " << label.first << " = " << label.second->toString() <<";" << std::endl; | |||
| 	} | |||
| 
 | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namepsace storm
 | |||
| @ -0,0 +1,42 @@ | |||
| /*
 | |||
|  * RewardModel.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "RewardModel.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| RewardModel::RewardModel() : rewardModelName(), stateRewards(), transitionRewards() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| RewardModel::RewardModel(std::string rewardModelName, std::vector<storm::ir::StateReward> stateRewards, std::vector<storm::ir::TransitionReward> transitionRewards) : rewardModelName(rewardModelName), stateRewards(stateRewards), transitionRewards(transitionRewards) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the reward model.
 | |||
| std::string RewardModel::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << "rewards \"" << rewardModelName << "\"" << std::endl; | |||
| 	for (auto reward : stateRewards) { | |||
| 		result << reward.toString() << std::endl; | |||
| 	} | |||
| 	for (auto reward : transitionRewards) { | |||
| 		result << reward.toString() << std::endl; | |||
| 	} | |||
| 	result << "endrewards" << std::endl; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,35 @@ | |||
| /*
 | |||
|  * StateReward.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "StateReward.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| StateReward::StateReward() : statePredicate(), rewardValue() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| StateReward::StateReward(std::shared_ptr<storm::ir::expressions::BaseExpression> statePredicate, std::shared_ptr<storm::ir::expressions::BaseExpression> rewardValue) : statePredicate(statePredicate), rewardValue(rewardValue) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the state reward.
 | |||
| std::string StateReward::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << "\t" << statePredicate->toString() << ": " << rewardValue->toString() << ";"; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,35 @@ | |||
| /*
 | |||
|  * TransitionReward.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "TransitionReward.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| TransitionReward::TransitionReward() : commandName(), statePredicate(), rewardValue() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| TransitionReward::TransitionReward(std::string commandName, std::shared_ptr<storm::ir::expressions::BaseExpression> statePredicate, std::shared_ptr<storm::ir::expressions::BaseExpression> rewardValue) : commandName(commandName), statePredicate(statePredicate), rewardValue(rewardValue) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the transition reward.
 | |||
| std::string TransitionReward::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << "\t[" << commandName << "] " << statePredicate->toString() << ": " << rewardValue->toString() << ";"; | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,45 @@ | |||
| /*
 | |||
|  * Update.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "Update.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| Update::Update() : likelihoodExpression(), assignments() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| Update::Update(std::shared_ptr<storm::ir::expressions::BaseExpression> likelihoodExpression, std::map<std::string, storm::ir::Assignment> assignments) | |||
| 	: likelihoodExpression(likelihoodExpression), assignments(assignments) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Build a string representation of the update.
 | |||
| std::string Update::toString() const { | |||
| 	std::stringstream result; | |||
| 	result << likelihoodExpression->toString() << " : "; | |||
| 	uint_fast64_t i = 0; | |||
| 	for (auto assignment : assignments) { | |||
| 		result << assignment.second.toString(); | |||
| 		++i; | |||
| 		if (i < assignments.size() - 1) { | |||
| 			result << " & "; | |||
| 		} | |||
| 
 | |||
| 	} | |||
| 	return result.str(); | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
| @ -0,0 +1,38 @@ | |||
| /*
 | |||
|  * Variable.cpp | |||
|  * | |||
|  *  Created on: 12.01.2013 | |||
|  *      Author: Christian Dehnert | |||
|  */ | |||
| 
 | |||
| #include "Variable.h"
 | |||
| 
 | |||
| #include <sstream>
 | |||
| 
 | |||
| namespace storm { | |||
| 
 | |||
| namespace ir { | |||
| 
 | |||
| // Initializes all members with their default constructors.
 | |||
| Variable::Variable() : variableName(), initialValue() { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Initializes all members according to the given values.
 | |||
| Variable::Variable(std::string variableName, std::shared_ptr<storm::ir::expressions::BaseExpression> initialValue) : variableName(variableName), initialValue(initialValue) { | |||
| 	// Nothing to do here.
 | |||
| } | |||
| 
 | |||
| // Return the name of the variable.
 | |||
| std::string const& Variable::getVariableName() const { | |||
| 	return variableName; | |||
| } | |||
| 
 | |||
| // Return the expression for the initial value of the variable.
 | |||
| std::shared_ptr<storm::ir::expressions::BaseExpression> const& Variable::getInitialValue() const { | |||
| 	return initialValue; | |||
| } | |||
| 
 | |||
| } // namespace ir
 | |||
| 
 | |||
| } // namespace storm
 | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue