Browse Source
Added support for multi objective formulas
Added support for multi objective formulas
Former-commit-id: 3d98b71049
tempestpy_adaptions
TimQu
9 years ago
19 changed files with 269 additions and 3 deletions
-
8src/logic/CloneVisitor.cpp
-
1src/logic/CloneVisitor.h
-
12src/logic/Formula.cpp
-
5src/logic/Formula.h
-
8src/logic/FormulaInformationVisitor.cpp
-
1src/logic/FormulaInformationVisitor.h
-
1src/logic/FormulaVisitor.h
-
1src/logic/Formulas.h
-
1src/logic/FormulasForwardDeclarations.h
-
15src/logic/FragmentChecker.cpp
-
1src/logic/FragmentChecker.h
-
38src/logic/FragmentSpecification.cpp
-
14src/logic/FragmentSpecification.h
-
78src/logic/MultiObjectiveFormula.cpp
-
35src/logic/MultiObjectiveFormula.h
-
4src/logic/ToExpressionVisitor.cpp
-
1src/logic/ToExpressionVisitor.h
-
17src/parser/FormulaParser.cpp
-
31test/functional/parser/FormulaParserTest.cpp
@ -0,0 +1,78 @@ |
|||
#include "src/logic/MultiObjectiveFormula.h"
|
|||
|
|||
#include "src/logic/FormulaVisitor.h"
|
|||
#include "src/utility/macros.h"
|
|||
#include "src/exceptions/InvalidArgumentException.h"
|
|||
|
|||
namespace storm { |
|||
namespace logic { |
|||
|
|||
MultiObjectiveFormula::MultiObjectiveFormula(std::vector<std::shared_ptr<Formula const>> const& subformulas) : subformulas(subformulas) { |
|||
//Intentionally left empty
|
|||
} |
|||
|
|||
MultiObjectiveFormula::~MultiObjectiveFormula() { |
|||
//Intentionally left empty
|
|||
} |
|||
|
|||
bool MultiObjectiveFormula::isMultiObjectiveFormula() const { |
|||
return true; |
|||
} |
|||
|
|||
bool MultiObjectiveFormula::hasQualitativeResult() const { |
|||
for(auto const& subformula : this->subformulas){ |
|||
if(subformula->hasQuantitativeResult()){ |
|||
return false; |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
bool MultiObjectiveFormula::hasQuantitativeResult() const { |
|||
return !hasQualitativeResult(); |
|||
}; |
|||
|
|||
Formula const& MultiObjectiveFormula::getSubformula(uint_fast64_t index) const { |
|||
STORM_LOG_THROW(index < getNumberOfSubformulas(), storm::exceptions::InvalidArgumentException, "Tried to access subformula with index " << index << " but there are only " << this->getNumberOfSubformulas() << " subformulas."); |
|||
return *this->subformulas[index]; |
|||
} |
|||
|
|||
uint_fast64_t MultiObjectiveFormula::getNumberOfSubformulas() const { |
|||
return this->subformulas.size(); |
|||
} |
|||
|
|||
boost::any MultiObjectiveFormula::accept(FormulaVisitor const& visitor, boost::any const& data) const { |
|||
return visitor.visit(*this, data); |
|||
} |
|||
|
|||
void MultiObjectiveFormula::gatherAtomicExpressionFormulas(std::vector<std::shared_ptr<AtomicExpressionFormula const>>& atomicExpressionFormulas) const { |
|||
for(auto const& subformula : this->subformulas){ |
|||
subformula->gatherAtomicExpressionFormulas(atomicExpressionFormulas); |
|||
} |
|||
} |
|||
|
|||
void MultiObjectiveFormula::gatherAtomicLabelFormulas(std::vector<std::shared_ptr<AtomicLabelFormula const>>& atomicLabelFormulas) const { |
|||
for(auto const& subformula : this->subformulas){ |
|||
subformula->gatherAtomicLabelFormulas(atomicLabelFormulas); |
|||
} |
|||
} |
|||
|
|||
void MultiObjectiveFormula::gatherReferencedRewardModels(std::set<std::string>& referencedRewardModels) const { |
|||
for(auto const& subformula : this->subformulas){ |
|||
subformula->gatherReferencedRewardModels(referencedRewardModels); |
|||
} |
|||
} |
|||
|
|||
std::ostream& MultiObjectiveFormula::writeToStream(std::ostream &out) const { |
|||
out << "multi("; |
|||
for(uint_fast64_t index = 0; index < this->getNumberOfSubformulas(); ++index){ |
|||
if(index>0){ |
|||
out << ", "; |
|||
} |
|||
this->getSubformula(index).writeToStream(out); |
|||
} |
|||
out << ")"; |
|||
return out; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
#ifndef STORM_LOGIC_MULTIOBJECTIVEFORMULA_H_ |
|||
#define STORM_LOGIC_MULTIOBJECTIVEFORMULA_H_ |
|||
|
|||
#include "src/logic/Formula.h" |
|||
|
|||
namespace storm { |
|||
namespace logic { |
|||
class MultiObjectiveFormula : public Formula { |
|||
public: |
|||
MultiObjectiveFormula(std::vector<std::shared_ptr<Formula const>> const& subformulas); |
|||
|
|||
virtual ~MultiObjectiveFormula(); |
|||
|
|||
virtual bool isMultiObjectiveFormula() const override; |
|||
|
|||
virtual bool hasQualitativeResult() const override; |
|||
virtual bool hasQuantitativeResult() const override; |
|||
|
|||
Formula const& getSubformula(uint_fast64_t index) const; |
|||
uint_fast64_t getNumberOfSubformulas() const; |
|||
|
|||
|
|||
virtual boost::any accept(FormulaVisitor const& visitor, boost::any const& data) const override; |
|||
virtual void gatherAtomicExpressionFormulas(std::vector<std::shared_ptr<AtomicExpressionFormula const>>& atomicExpressionFormulas) const override; |
|||
virtual void gatherAtomicLabelFormulas(std::vector<std::shared_ptr<AtomicLabelFormula const>>& atomicLabelFormulas) const override; |
|||
virtual void gatherReferencedRewardModels(std::set<std::string>& referencedRewardModels) const override; |
|||
|
|||
virtual std::ostream& writeToStream(std::ostream& out) const override; |
|||
private: |
|||
std::vector<std::shared_ptr<Formula const>> subformulas; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_LOGIC_MULTIOBJECTIVEFORMULA_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue