Browse Source
added constants, added custom iterator to variable set
added constants, added custom iterator to variable set
Former-commit-id: 8f4a1d6aec
tempestpy_adaptions
dehnert
9 years ago
14 changed files with 549 additions and 0 deletions
-
23src/storage/jani/AutomatonComposition.cpp
-
30src/storage/jani/AutomatonComposition.h
-
12src/storage/jani/Composition.cpp
-
20src/storage/jani/Composition.h
-
27src/storage/jani/CompositionVisitor.cpp
-
21src/storage/jani/CompositionVisitor.h
-
35src/storage/jani/Constant.cpp
-
62src/storage/jani/Constant.h
-
33src/storage/jani/ParallelComposition.cpp
-
49src/storage/jani/ParallelComposition.h
-
41src/storage/jani/RenameComposition.cpp
-
42src/storage/jani/RenameComposition.h
-
79src/storage/jani/VariableSet.cpp
-
75src/storage/jani/VariableSet.h
@ -0,0 +1,23 @@ |
|||
#include "src/storage/jani/AutomatonComposition.h"
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
AutomatonComposition::AutomatonComposition(std::string const& name) : name(name) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
boost::any AutomatonComposition::accept(CompositionVisitor& visitor, boost::any const& data) const { |
|||
return visitor.visit(*this, data); |
|||
} |
|||
|
|||
std::string const& AutomatonComposition::getAutomatonName() const { |
|||
return name; |
|||
} |
|||
|
|||
void AutomatonComposition::write(std::ostream& stream) const { |
|||
stream << name; |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
#pragma once |
|||
|
|||
#include "src/storage/jani/Composition.h" |
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
class AutomatonComposition : public Composition { |
|||
public: |
|||
/*! |
|||
* Creates a reference to an automaton to be used in a composition. |
|||
*/ |
|||
AutomatonComposition(std::string const& name); |
|||
|
|||
/*! |
|||
* Retrieves the name of the automaton this composition element refers to. |
|||
*/ |
|||
std::string const& getAutomatonName() const; |
|||
|
|||
virtual boost::any accept(CompositionVisitor& visitor, boost::any const& data) const override; |
|||
|
|||
virtual void write(std::ostream& stream) const override; |
|||
|
|||
private: |
|||
// The name of the automaton this composition element refers to. |
|||
std::string name; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
#include "src/storage/jani/Composition.h"
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
std::ostream& operator<<(std::ostream& stream, Composition const& composition) { |
|||
composition.write(stream); |
|||
return stream; |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
#pragma once |
|||
|
|||
#include <ostream> |
|||
|
|||
#include "src/storage/jani/CompositionVisitor.h" |
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
class Composition { |
|||
public: |
|||
virtual boost::any accept(CompositionVisitor& visitor, boost::any const& data) const = 0; |
|||
|
|||
virtual void write(std::ostream& stream) const = 0; |
|||
|
|||
friend std::ostream& operator<<(std::ostream& stream, Composition const& composition); |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
#include "src/storage/jani/CompositionVisitor.h"
|
|||
|
|||
#include "src/storage/jani/AutomatonComposition.h"
|
|||
#include "src/storage/jani/RenameComposition.h"
|
|||
#include "src/storage/jani/ParallelComposition.h"
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
boost::any CompositionVisitor::visit(AutomatonComposition const& composition, boost::any const& data) { |
|||
return data; |
|||
} |
|||
|
|||
boost::any CompositionVisitor::visit(RenameComposition const& composition, boost::any const& data) { |
|||
return composition.getSubcomposition().accept(*this, data); |
|||
} |
|||
|
|||
boost::any CompositionVisitor::visit(ParallelComposition const& composition, boost::any const& data) { |
|||
return join(composition.getLeftSubcomposition().accept(*this, data), composition.getRightSubcomposition().accept(*this, data)); |
|||
} |
|||
|
|||
boost::any CompositionVisitor::join(boost::any const& first, boost::any const& second) { |
|||
return first; |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
#pragma once |
|||
|
|||
#include <boost/any.hpp> |
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
class AutomatonComposition; |
|||
class RenameComposition; |
|||
class ParallelComposition; |
|||
|
|||
class CompositionVisitor { |
|||
public: |
|||
virtual boost::any visit(AutomatonComposition const& composition, boost::any const& data); |
|||
virtual boost::any visit(RenameComposition const& composition, boost::any const& data); |
|||
virtual boost::any visit(ParallelComposition const& composition, boost::any const& data); |
|||
virtual boost::any join(boost::any const& first, boost::any const& second); |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
#include "src/storage/jani/Constant.h"
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
Constant::Constant(std::string const& name, boost::optional<storm::expressions::Expression> const& expression) : name(name), expression(expression) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
bool Constant::isDefined() const { |
|||
return static_cast<bool>(expression); |
|||
} |
|||
|
|||
void Constant::define(storm::expressions::Expression const& expression) { |
|||
this->expression = expression; |
|||
} |
|||
|
|||
storm::expressions::Type const& Constant::getType() const { |
|||
return variable.getType(); |
|||
} |
|||
|
|||
bool Constant::isBooleanConstant() const { |
|||
return getType().isBooleanType(); |
|||
} |
|||
|
|||
bool Constant::isIntegerConstant() const { |
|||
return getType().isIntegerType(); |
|||
} |
|||
|
|||
bool Constant::isRealConstant() const { |
|||
return getType().isRationalType(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,62 @@ |
|||
#pragma once |
|||
|
|||
#include <string> |
|||
|
|||
#include <boost/optional.hpp> |
|||
|
|||
#include "src/storage/expressions/Variable.h" |
|||
#include "src/storage/expressions/Expression.h" |
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
class Constant { |
|||
public: |
|||
/*! |
|||
* Creates a constant. |
|||
*/ |
|||
Constant(std::string const& name, boost::optional<storm::expressions::Expression> const& expression = boost::none); |
|||
|
|||
/*! |
|||
* Retrieves whether the constant is defined in the sense that it has a defining expression. |
|||
*/ |
|||
bool isDefined() const; |
|||
|
|||
/*! |
|||
* Defines the constant with the given expression. |
|||
*/ |
|||
void define(storm::expressions::Expression const& expression); |
|||
|
|||
/*! |
|||
* Retrieves the type of the constant. |
|||
*/ |
|||
storm::expressions::Type const& getType() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the constant is a boolean constant. |
|||
*/ |
|||
bool isBooleanConstant() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the constant is an integer constant. |
|||
*/ |
|||
bool isIntegerConstant() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the constant is a real constant. |
|||
*/ |
|||
bool isRealConstant() const; |
|||
|
|||
private: |
|||
// The name of the constant. |
|||
std::string name; |
|||
|
|||
// The expression variable associated with the constant. |
|||
storm::expressions::Variable variable; |
|||
|
|||
// The expression defining the constant (if any). |
|||
boost::optional<storm::expressions::Expression> expression; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
#include "src/storage/jani/ParallelComposition.h"
|
|||
|
|||
#include <boost/algorithm/string/join.hpp>
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
ParallelComposition::ParallelComposition(std::shared_ptr<Composition> const& leftSubcomposition, std::shared_ptr<Composition> const& rightSubcomposition, std::set<std::string> const& alphabet) : leftSubcomposition(leftSubcomposition), rightSubcomposition(rightSubcomposition) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
Composition const& ParallelComposition::getLeftSubcomposition() const { |
|||
return *leftSubcomposition; |
|||
} |
|||
|
|||
Composition const& ParallelComposition::getRightSubcomposition() const { |
|||
return *rightSubcomposition; |
|||
} |
|||
|
|||
std::set<std::string> const& ParallelComposition::getSynchronizationAlphabet() const { |
|||
return alphabet; |
|||
} |
|||
|
|||
boost::any ParallelComposition::accept(CompositionVisitor& visitor, boost::any const& data) const { |
|||
return visitor.visit(*this, data); |
|||
} |
|||
|
|||
void ParallelComposition::write(std::ostream& stream) const { |
|||
stream << this->getLeftSubcomposition() << " |[" << boost::algorithm::join(alphabet, ", ") << "]| " << this->getRightSubcomposition(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,49 @@ |
|||
#pragma once |
|||
|
|||
#include <set> |
|||
#include <memory> |
|||
|
|||
#include "src/storage/jani/Composition.h" |
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
class ParallelComposition : public Composition { |
|||
public: |
|||
/*! |
|||
* Creates a parallel composition of the two subcompositions. |
|||
*/ |
|||
ParallelComposition(std::shared_ptr<Composition> const& leftSubcomposition, std::shared_ptr<Composition> const& rightSubcomposition, std::set<std::string> const& alphabet = {}); |
|||
|
|||
/*! |
|||
* Retrieves the left subcomposition. |
|||
*/ |
|||
Composition const& getLeftSubcomposition() const; |
|||
|
|||
/*! |
|||
* Retrieves the right subcomposition. |
|||
*/ |
|||
Composition const& getRightSubcomposition() const; |
|||
|
|||
/*! |
|||
* Retrieves the alphabet of actions over which to synchronize the automata. |
|||
*/ |
|||
std::set<std::string> const& getSynchronizationAlphabet() const; |
|||
|
|||
virtual boost::any accept(CompositionVisitor& visitor, boost::any const& data) const override; |
|||
|
|||
virtual void write(std::ostream& stream) const override; |
|||
|
|||
private: |
|||
// The left subcomposition. |
|||
std::shared_ptr<Composition> leftSubcomposition; |
|||
|
|||
// The right subcomposition. |
|||
std::shared_ptr<Composition> rightSubcomposition; |
|||
|
|||
// The alphabet of actions over which to synchronize. |
|||
std::set<std::string> alphabet; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
#include "src/storage/jani/RenameComposition.h"
|
|||
|
|||
#include <vector>
|
|||
#include <sstream>
|
|||
|
|||
#include <boost/algorithm/string/join.hpp>
|
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
RenameComposition::RenameComposition(std::shared_ptr<Composition> const& subcomposition, std::map<std::string, boost::optional<std::string>> const& renaming) : subcomposition(subcomposition), renaming(renaming) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
Composition const& RenameComposition::getSubcomposition() const { |
|||
return *subcomposition; |
|||
} |
|||
|
|||
boost::any RenameComposition::accept(CompositionVisitor& visitor, boost::any const& data) const { |
|||
return visitor.visit(*this, data); |
|||
} |
|||
|
|||
void RenameComposition::write(std::ostream& stream) const { |
|||
std::vector<std::string> renamingStrings; |
|||
|
|||
for (auto const& entry : renaming) { |
|||
std::stringstream stream; |
|||
stream << entry.first << " -> "; |
|||
if (entry.second) { |
|||
stream << entry.second; |
|||
} else { |
|||
stream << "tau"; |
|||
} |
|||
} |
|||
|
|||
stream << "(" << subcomposition << ") / {" << boost::join(renamingStrings, ", ") << "}"; |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,42 @@ |
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
#include <map> |
|||
|
|||
#include <boost/optional.hpp> |
|||
|
|||
#include "src/storage/jani/Composition.h" |
|||
|
|||
namespace storm { |
|||
namespace jani { |
|||
|
|||
class RenameComposition : public Composition { |
|||
public: |
|||
RenameComposition(std::shared_ptr<Composition> const& subcomposition, std::map<std::string, boost::optional<std::string>> const& renaming = {}); |
|||
|
|||
/*! |
|||
* Retrieves the subcomposition of this rename composition. |
|||
*/ |
|||
Composition const& getSubcomposition() const; |
|||
|
|||
/*! |
|||
* Retrieves the renaming of actions. If some action name is mapped to none, this indicates the action is to |
|||
* be renamed to the silent action. |
|||
*/ |
|||
std::map<std::string, boost::optional<std::string>> const& getRenaming() const; |
|||
|
|||
virtual boost::any accept(CompositionVisitor& visitor, boost::any const& data) const override; |
|||
|
|||
virtual void write(std::ostream& stream) const override; |
|||
|
|||
private: |
|||
// The subcomposition. |
|||
std::shared_ptr<Composition> subcomposition; |
|||
|
|||
// The renaming to perform. If one cation is mapped to none, this means that the action is to be renamed to |
|||
// the silent action. |
|||
std::map<std::string, boost::optional<std::string>> renaming; |
|||
}; |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue