|
Mungojerrie
1.1
Mungojerrie
|
Go to the documentation of this file.
58 using Node =
unsigned long;
63 using Priority =
short int;
84 using Index = unsigned;
85 using Propositions = std::set<BDD, Util::BddCompare>;
91 source(s), destination(d), action(a), priority(pi), probability(p), reward(r) {}
100 using Edges = std::vector<Index>;
103 struct NodeAttributes{
104 NodeAttributes(std::string nm,
Player pl) :
105 name(nm), player(pl) {}
107 Propositions propositions;
113 using AttributeMap = std::unordered_map<Node,NodeAttributes>;
114 using LabelMap = std::map<std::string, BDD>;
115 using TransitionList = std::vector<Transition>;
116 using NodeCounts = std::map<Player, size_t>;
128 std::unordered_map<Node, Action> strategy;
129 std::unordered_map<Node, double> vals;
135 std::map<Node, Action> strategy;
142 std::map<Node, Action> strategy;
152 Model(Cudd mgr, std::string
const & filename,
153 Verbosity::Level pverbosity = Verbosity::Silent,
162 size_t numNodes(
void)
const {
return attributes.size(); }
192 LabelMap::const_iterator
lookUpLabel(std::string
const & label)
const;
195 Reward reward = 0.0, Priority p = 0);
263 std::unordered_map<Node, Action>
loadStrategyCSV(std::string filename)
const;
270 void printStrategyCSV(std::unordered_map<Node, Action>, std::string filename)
const;
276 void printDot(std::string graphname = std::string(
"Model"), std::string filename = std::string(
"-"))
const;
278 void printPrism(std::string
const & modulename = std::string(
"m"),
279 std::string filename = std::string(
"-"))
const;
287 bool removeUnreachable,
308 std::set<Node>
const & restriction,
309 std::set<Index>
const & forbiddenEdges)
const;
321 std::vector< std::set<Node> >
getWECs(std::set<Node>
const & restriction,
322 std::set<std::pair<Node, Action>>
const & forbiddenEdges)
const;
324 std::vector< std::set<Node> >
getWECs(std::set<Node>
const & restriction)
const;
326 std::vector< std::set<Node> >
getWECs(
void)
const;
328 std::vector< std::set<Node> >
getMECs(std::set<Node>
const & restriction,
329 std::set<std::pair<Node, Action>>
const & forbiddenEdges)
const;
331 std::vector< std::set<Node> >
getMECs(std::set<Node>
const & restriction)
const;
333 std::vector< std::set<Node> >
getMECs(
void)
const;
336 std::unordered_set<Node>
getAttractor(std::set<Node>
const & target,
338 std::set<Node>
const & restriction,
339 std::set<std::pair<Node, Action>>
const & forbiddenEdges)
const;
342 std::unordered_set<Node>
getAttractor(std::set<Node>
const & target,
344 std::set<Node>
const & restriction)
const;
347 std::unordered_set<Node>
getAttractor(std::set<Node>
const & target,
348 Player targetPlayer)
const;
349 std::vector<std::set<Node>>
getSCCs(std::set<Node>
const & init,
350 std::set<Node>
const & restriction,
351 std::set<Index>
const & forbiddenEdges)
const;
353 std::vector<std::set<Node>>
getSCCs(std::set<Node>
const & init,
354 std::set<Node>
const & restriction)
const;
356 std::vector<std::set<Node>>
getSCCs(std::set<Node>
const & restriction)
const;
358 std::vector<std::set<Node>>
getSCCs(
void)
const;
361 std::set<Node>
const & restriction,
362 std::set<Index>
const & forbiddenEdges)
const;
365 std::set<Node>
const & restriction,
366 std::set<Index>
const & forbiddenEdges)
const;
369 std::set<Node>
const & restriction,
370 std::set<Index>
const & forbiddenEdges)
const;
373 std::set<Node>
const & restriction,
374 std::set<Index>
const & forbiddenEdges)
const;
383 std::set<Index>
const & forbiddenEdges)
const;
388 std::set<Node>
const & restriction,
389 std::set<Index>
const & forbiddenEdges)
const;
398 std::set<Index>
const & forbiddenEdges)
const;
403 std::set<Node>
const & restriction,
404 std::set<Index>
const & forbiddenEdges)
const;
407 std::vector< std::set<Node> > getWECsNoCheck(std::set<Node>
const & restriction,
408 std::set<Index>
const & forbiddenEdges)
const;
410 std::vector< std::set<Node> > getMECsNoCheck(std::set<Node>
const & restriction,
411 std::set<Index>
const & forbiddenEdges)
const;
413 std::unordered_set<Node> getAttractorNoCheck(std::set<Node>
const & target,
415 std::set<Node>
const & restriction,
416 std::set<Index>
const & forbiddenEdges)
const;
418 std::unordered_map<Node, Action> getStrategyWECs(std::vector< std::set<Node> >
const & WECs)
const;
420 std::unordered_map<Node, Action> getStrategyWECs(
void)
const;
425 std::unordered_map<Node, double> getSSP(std::set<Node>
const & target,
426 std::set<Node>
const & restriction,
427 std::set<Index>
const & forbiddenEdges)
const;
432 std::unordered_map<Node, double> getSSPORTools(std::set<Node>
const & target,
433 std::set<Node>
const & restriction,
434 std::set<Index>
const & forbiddenEdges)
const;
439 std::unordered_map<Node, double> getSSPIncr(std::set<Node>
const & target,
440 std::set<Node>
const & restriction,
441 std::set<Index>
const & forbiddenEdges)
const;
446 std::unordered_map<Node, double> getSSPPoly(std::set<Node>
const & target,
447 std::set<Node>
const & restriction,
448 std::set<Index>
const & forbiddenEdges)
const;
450 std::unordered_map<Node, double> getProbReachabilityORTools(std::set<Node>
const & target,
451 std::set<Node>
const & restriction,
452 std::set<Index>
const & forbiddenEdges)
const;
454 std::unordered_map<Node, double> getProbReachabilityIncr(std::set<Node>
const & target,
455 std::set<Node>
const & restriction,
456 std::set<Index>
const & forbiddenEdges)
const;
459 std::unordered_map<Node, double> getBDPValueUsingORTools()
const;
462 void addTransition(Transition
const & tran);
464 bool isTrivial(std::set<Node>
const & scc)
const;
466 void incrementCount(
Player player);
468 void decrementCount(
Player player);
471 Verbosity::Level verbosity;
475 ModelOptions::ReachType reachSolver;
476 ModelOptions::SSPType sspSolver;
478 AttributeMap attributes;
479 TransitionList transitions;
483 std::map<Action, std::string> actionNames;
485 static Action constexpr invalid = -1;
486 static Player constexpr probPlayer = -1;
Class to store return value of probMcNaughton.
Definition: Model.hh:139
std::map< Node, double > getSuccessors(Node state, Action action) const
Returns a the decision node successors of state with probabilities.
Definition: Model.cc:788
short int Action
Type of actions.
Definition: Model.hh:73
void addStateReward(Node node, Reward reward)
Adds reward to existing reward for all transitions from a decision node.
Definition: Model.cc:553
void setNodePlayer(Node decisionnode, Player player)
Sets the player of a decision node.
Definition: Model.cc:696
std::string getActionName(Action action) const
Returns the name of an action number.
Definition: Model.cc:671
void printDot(std::string graphname=std::string("Model"), std::string filename=std::string("-")) const
Write model in dot format.
Definition: Model.cc:1230
Class to pass options to Model.
Definition: ModelOptions.hh:52
BDD getNodeLetter(Node decisionnode) const
Returns the letter labeling a decision node.
Definition: Model.cc:649
std::vector< std::set< Node > > getMECs(void) const
Computes the maximal-end-components of model.
Definition: ModelCheck.cc:1701
Player getNodePlayer(Node state) const
Gets the player of a node.
Definition: Model.cc:686
void setBDP()
set model to be a branchign decision process.
Definition: Model.hh:172
int Player
Type of players.
Definition: Model.hh:68
void addDecisionTransition(Node source, Node destination, Action a, Reward reward=0.0, Priority p=0)
Adds a transition to a decision node.
Definition: Model.cc:469
void parseOptions(ModelOptions options)
Parses ModelOptions.
Definition: Model.cc:272
int getNumOfStrategicPlayers(void) const
Returns number of strategic players.
Definition: Model.cc:319
Cudd getManager(void) const
Returns the BDD manager of the model.
Definition: Model.hh:182
std::string getPropositionName(BDD proposition) const
Returns name of an atomic proposition.
Definition: Model.cc:635
void addDecisionNode(Node node, std::string name, Player player=0)
Adds a decision node to the model.
Definition: Model.cc:345
Model pruneToStrategy(std::unordered_map< Node, Action > const &strategy, bool removeUnreachable, bool makeMC) const
Produces a model with all non-strategic actions removed.
Definition: Model.cc:975
void printStrategyCSV(std::unordered_map< Node, Action >, std::string filename) const
Write strategy to CSV in the given filename.
Definition: Model.cc:1117
const_iterator cbegin()
Returns a const_iterator pointing to the first node.
Definition: Model.hh:122
bool isNode(Node node) const
Checks whether a node exists with a given index.
Definition: Model.cc:330
void invertProperty(void)
Inverts property by incrementing all priorities by 1.
Definition: Model.cc:1060
Model::StrategyResults getStrategyReach1Player(std::set< Node > const &target, std::set< Node > const &restriction, std::set< Index > const &forbiddenEdges) const
Computes strategy to reach target for 1-1/2 player model.
Definition: ModelCheck.cc:1322
void addAtomicProposition(BDD proposition, std::string name)
Adds atomic proposition to model.
Definition: Model.cc:622
std::pair< Node, Priority > getSuccessor(Node state, Action action) const
Returns the next decision node and priority given an action through sampling.
Definition: Model.cc:753
Option structure for models.
Model::StrategyResults getStrategy1Player(void) const
Computes strategy for WECs and to reach them for 1-1/2 player models.
Definition: ModelCheck.cc:1393
ModelOptions getOptions(void) const
Returns current options.
Definition: Model.cc:286
size_t numDecisionNodes(void) const
Returns the number of decision nodes in the model.
Definition: Model.cc:309
bool isBDP() const
Returns 1 if the model is a brnaching decision process.
Definition: Model.hh:170
void printPrism(std::string const &modulename=std::string("m"), std::string filename=std::string("-")) const
Write model in PRISM format.
Definition: Model.cc:1336
std::vector< std::set< Node > > getWECs(void) const
Computes the winning-end-components of model.
Definition: ModelCheck.cc:1553
size_t numProbabilisticNodes(void) const
Returns the number of probabilistic nodes in the model.
Definition: Model.cc:298
unsigned long Node
Type of nodes.
Definition: Model.hh:58
const_iterator cend()
Returns a const_iterator pointing "just past the last" node.
Definition: Model.hh:124
Reward getActionStateReward(Node state, Action action) const
Returns reward from transition from a node enabled by an action.
Definition: Model.cc:739
void setActionName(Action action, std::string const &name)
Sets the name of an action.
Definition: Model.cc:681
void addTransitionProbability(Node source, Node destination, Probability probability, Reward reward=0.0)
Adds probability to a probabilistic transition.
Definition: Model.cc:516
void addProbabilisticNode(Node node, std::string name=std::string(""))
Adds a probabilistic node to the model.
Definition: Model.cc:358
Model::AttractorResults getAttractorWithStrat(std::set< Player > targetPlayers, std::set< Node > const &target, std::set< Node > const &restriction, std::set< Index > const &forbiddenEdges) const
Computes the attractor with computed strategy in return value.
Definition: ModelGames.cc:59
friend std::ostream & operator<<(std::ostream &os, Model const &l)
Stream insertion operator overload.
void printActionsCSV(std::string filename) const
Write all available actions to CSV in the given filename.
Definition: Model.cc:1177
NodeCounts getNodeCounts(void) const
Returns the node counts map without probPlayer.
Definition: Model.cc:91
void addProbabilisticTransition(Node source, Node destination, Probability p, Reward r=0.0)
Adds a transition to a probabilistic node.
Definition: Model.cc:437
double Probability
Type of probabilities.
Definition: Model.hh:77
void replaceUnitProbabilityTransitions()
Replaces probabilistic transitions with deterministic ones.
Definition: Model.cc:820
std::unordered_set< Node > getAttractor(std::set< Node > const &target, Player targetPlayer, std::set< Node > const &restriction, std::set< std::pair< Node, Action >> const &forbiddenEdges) const
Computes the attractor for target set and player.
std::vector< std::set< Node > > getSCCs(void) const
Computes the SCCs of the model.
Definition: ModelCheck.cc:270
Set manipulation functions.
Class for return value of getAttractorWithStrat.
Definition: Model.hh:133
LabelMap::const_iterator lookUpLabel(std::string const &label) const
Looks up proposition from label.
Definition: Model.cc:396
Class for return value of getStrategy.
Definition: Model.hh:127
Model::AttractorResults getStrongAttr(Player targetPlayer, std::set< Node > const &target, std::set< Node > const &restriction, std::set< Index > const &forbiddenEdges) const
Computes the strong attractor (2 player attractor where probabilistic nodes helps targetPlayer).
Definition: ModelGames.cc:128
std::unordered_map< Node, double > getProbabilityOfSat1Player(void) const
Computes maximum probabilities of reaching WECs for 1-1/2 player model.
Definition: ModelCheck.cc:1284
AttributeMap::const_iterator const_iterator
Constant iterator type.
Definition: Model.hh:120
Node getInitial(void) const
Returns the initial state of the model.
Definition: Model.hh:219
std::vector< Node > getDecisionNodes(Player player=0) const
Returns the set of decision nodes in the model for one player.
Definition: Model.cc:714
void setVerbosity(Verbosity::Level v)
Sets the verbosity level of the model.
Definition: Model.hh:253
Model::AttractorResults getWeakAttr(Player targetPlayer, std::set< Node > const &target, std::set< Node > const &restriction, std::set< Index > const &forbiddenEdges) const
Computes the weak attractor (attractor that targetPlayer can attract almost surely).
Definition: ModelGames.cc:141
size_t numNodes(void) const
Returns the total number of nodes in the model.
Definition: Model.hh:162
Verbosity-related definitions.
std::string prettyPrintState(int n) const
Processes the name of the product state.
Definition: Model.cc:1321
Model::StrategyResults getStrategy2Player(void) const
Computes strategy and winning sets for quantitative parity games.
Definition: ModelGames.cc:503
Class for MDPs and related structures.
Definition: Model.hh:82
std::string getNodeName(Node node) const
Returns node name.
Definition: Model.cc:368
void sortEdgesByPriority(void)
Sorts edges into and out of nodes by their priorities.
Definition: Model.cc:251
Model::StrategyResults getStrategy(void) const
Computes getStrategy1Player or getStrategy2Player depending on whether the model is 1-1/2 players or ...
Definition: ModelCheck.cc:1426
Model::AttractorResults getUltraWeakAttr(Player targetPlayer, std::set< Node > const &target, std::set< Node > const &restriction, std::set< Index > const &forbiddenEdges) const
Computes the ultra-weak attractor (2 player attractor where probabilistic nodes are adversarial).
Definition: ModelGames.cc:117
Model::StrategyResults getBDPStrategy(void) const
Computes optimal strategy for a BDP.
Definition: ModelCheck.cc:2130
void sanityCheck(void) const
Checks sanity of model.
Definition: Model.cc:864
bool isDecisionNode(Node node) const
Checks whether a decision node exists with a given index.
Definition: Model.cc:336
Propositions getAtomicPropositions(void) const
Returns the set of atomic propositions.
Definition: Model.hh:225
void makeInitial(Node node)
Makes a decision node the initial node of the model.
Definition: Model.cc:609
double Reward
Type of rewards.
Definition: Model.hh:75
bool isGame(void) const
Returns 1 if the model is a stochastic game.
Definition: Model.cc:314
std::unordered_map< Node, double > getProbabilityOfSat(void) const
Computes maximum probabilities of reaching WECs for 1-1/2 player models and probabilities for parity ...
Definition: ModelCheck.cc:1270
void addActionStateReward(Node node, Action action, Reward reward)
Adds reward to existing reward for all transitions from a node enabled by an action.
Definition: Model.cc:580
Class of parity automata.
Definition: Parity.hh:85
Probability getTransitionProbability(Node source, Node destination) const
Returns the probability of a probabilistic transition.
Definition: Model.cc:490
std::vector< Action > getActions(Node state) const
Returns a vector of actions possible from the given node.
Definition: Model.cc:725
Model::PlayerSets probMcNaughton(void) const
Computes strategy and winning sets for qualitative parity games.
Definition: ModelGames.cc:207
std::unordered_map< Node, Action > loadStrategyCSV(std::string filename) const
Loads pure strategy from CSV.
Definition: Model.cc:1067
Model(Cudd mgr, ModelOptions options=ModelOptions{})
Constructor.
Definition: Model.cc:98
void addLabel(Node node, BDD proposition)
Adds an atomic proposition to a node.
Definition: Model.cc:378
Verbosity::Level readVerbosity(void) const
Returns the verbosity level of the model.
Definition: Model.hh:251