Browse Source

initial support for partitions

tempestpy_adaptions
Sebastian Junges 8 years ago
parent
commit
c377050428
  1. 4
      src/storm-gspn/storage/gspn/GSPN.cpp
  2. 7
      src/storm-gspn/storage/gspn/GSPN.h
  3. 36
      src/storm-gspn/storage/gspn/GspnBuilder.cpp
  4. 2
      src/storm-gspn/storage/gspn/GspnBuilder.h
  5. 18
      src/storm-gspn/storage/gspn/TransitionPartition.h

4
src/storm-gspn/storage/gspn/GSPN.cpp

@ -27,8 +27,8 @@ namespace storm {
return tId;
}
GSPN::GSPN(std::string const& name, std::vector<Place> const& places, std::vector<ImmediateTransition<WeightType>> const& itransitions, std::vector<TimedTransition<RateType>> const& ttransitions)
: name(name), places(places), immediateTransitions(itransitions), timedTransitions(ttransitions)
GSPN::GSPN(std::string const& name, std::vector<Place> const& places, std::vector<ImmediateTransition<WeightType>> const& itransitions, std::vector<TimedTransition<RateType>> const& ttransitions, std::vector<TransitionPartition> const& partitions)
: name(name), places(places), immediateTransitions(itransitions), timedTransitions(ttransitions), partitions(partitions)
{
}

7
src/storm-gspn/storage/gspn/GSPN.h

@ -10,6 +10,7 @@
#include "storm-gspn/storage/gspn/Marking.h"
#include "storm-gspn/storage/gspn/Place.h"
#include "storm-gspn/storage/gspn/TimedTransition.h"
#include "storm-gspn/storage/gspn/TransitionPartition.h"
namespace storm {
namespace gspn {
@ -27,7 +28,8 @@ namespace storm {
typedef double WeightType;
GSPN(std::string const& name, std::vector<Place> const& places, std::vector<ImmediateTransition<WeightType>> const& itransitions, std::vector<TimedTransition<RateType>> const& ttransitions);
GSPN(std::string const& name, std::vector<Place> const& places, std::vector<ImmediateTransition<WeightType>> const& itransitions,
std::vector<TimedTransition<RateType>> const& ttransitions, std::vector<TransitionPartition> const& partitions);
/*!
* Returns the number of places in this gspn.
@ -176,7 +178,8 @@ namespace storm {
// set containing all timed transitions
std::vector<storm::gspn::TimedTransition<RateType>> timedTransitions;
std::vector<storm::gspn::TransitionPartition> partitions;
};
}
}

36
src/storm-gspn/storage/gspn/GspnBuilder.cpp

@ -29,8 +29,27 @@ namespace storm {
auto newId = GSPN::immediateTransitionIdToTransitionId(immediateTransitions.size());
trans.setName(name);
trans.setPriority(priority);
trans.setWeight(weight);
trans.setID(newId);
// ensure that the first partition is for the 'general/weighted' transitions
if(partitions.count(priority) == 0) {
TransitionPartition newPart;
newPart.priority = priority;
partitions.at(priority).push_back(newPart);
}
if(storm::utility::isZero(weight)) {
trans.setWeight(storm::utility::one<double>());
TransitionPartition newPart;
newPart.priority = priority;
newPart.transitions = {newId};
partitions.at(priority).push_back(newPart);
} else {
trans.setWeight(weight);
partitions.at(priority).front().transitions.push_back(newId);
}
immediateTransitions.push_back(trans);
return newId;
@ -131,7 +150,20 @@ namespace storm {
storm::gspn::GSPN* GspnBuilder::buildGspn() const {
return new GSPN(gspnName, places, immediateTransitions, timedTransitions);
std::vector<TransitionPartition> orderedPartitions;
for(auto const& priorityPartitions : partitions) {
for (auto const& partition : priorityPartitions.second) {
// sanity check
assert(partition.priority == priorityPartitions.first);
if(partition.nrTransitions() > 0) {
orderedPartitions.push_back(partition);
}
}
}
return new GSPN(gspnName, places, immediateTransitions, timedTransitions, orderedPartitions);
}
}
}

2
src/storm-gspn/storage/gspn/GspnBuilder.h

@ -102,6 +102,8 @@ namespace storm {
std::string gspnName = "_gspn_";
std::map<uint64_t, std::vector<storm::gspn::TransitionPartition>> partitions;
// set containing all immediate transitions
std::vector<storm::gspn::ImmediateTransition<WeightType>> immediateTransitions;

18
src/storm-gspn/storage/gspn/TransitionPartition.h

@ -0,0 +1,18 @@
#pragma once
#include <vector>
namespace storm {
namespace gspn {
struct TransitionPartition {
std::vector<uint64_t> transitions;
uint64_t priority;
uint64_t nrTransitions() const {
return transitions.size();
}
};
}
}
Loading…
Cancel
Save