Safe Haskell | Safe-Infered |
---|

Tools to build influence diagrams

- type InfluenceDiagram = DirectedSG EdgeKind IDValue
- type DecisionFactor = PrivateCPT Vector DVI
- class Instantiable d v r | d -> r where
- (=:) :: d -> v -> r

- data DEV
- data UV
- data DV
- data TDV s
- type IDMonad g a = NetworkMonad g EdgeKind IDValue a
- t :: a
- (~~) :: (Initializable v, DirectedGraph g, Distribution d) => IDMonad g v -> d -> IDMonad g ()
- chance :: (Bounded a, Enum a, NamedGraph g) => String -> a -> IDMonad g (TDV a)
- decisionNode :: (Bounded a, Enum a, NamedGraph g) => String -> a -> IDMonad g DEV
- utilityNode :: NamedGraph g => String -> IDMonad g UV
- proba :: (ChanceVariable c, DirectedGraph g) => c -> IDMonad g c
- decision :: (DirectedGraph g, BayesianDiscreteVariable dv) => DEV -> [dv] -> IDMonad g DEV
- utility :: (DirectedGraph g, BayesianDiscreteVariable dv) => UV -> [dv] -> IDMonad g UV
- cpt :: (DirectedGraph g, BayesianDiscreteVariable vb, ChanceVariable c) => c -> [vb] -> IDMonad g c
- d :: DEV -> PorD
- p :: ChanceVariable c => c -> PorD
- noDependencies :: [DV]
- decisionsOrder :: InfluenceDiagram -> [ChancesOrDecision]
- solveInfluenceDiagram :: InfluenceDiagram -> [DecisionFactor]
- runID :: IDMonad DirectedSG a -> (a, InfluenceDiagram)
- policyNetwork :: [DecisionFactor] -> InfluenceDiagram -> SBN CPT
- decisionToInstantiation :: DecisionFactor -> [DVISet]
- type DVISet = [DVI]
- data DVI

# Type

type InfluenceDiagram = DirectedSG EdgeKind IDValueSource

Influence diagram

type DecisionFactor = PrivateCPT Vector DVISource

class Instantiable d v r | d -> r whereSource

(Bounded b, Enum b) => Instantiable DV b DVI | |

Instantiable CV Double CVI | |

Instantiable DEV Int DVI | |

Instantiable DN Double CVI | |

(Bounded b, Enum b) => Instantiable (TDV b) b DVI |

Decision variable

Eq DEV | |

Ord DEV | |

Show DEV | |

BayesianDiscreteVariable DEV | |

BayesianVariable DEV | |

Initializable DEV | |

Instantiable DEV Int DVI |

A discrete variable

A typed discrete variable

# Building

Synonym for undefined because it is clearer to use t to set the Enum bounds of a variable

:: (Initializable v, DirectedGraph g, Distribution d) | |

=> IDMonad g v | Discrete variable in the graph |

-> d | List of values |

-> IDMonad g () |

chance :: (Bounded a, Enum a, NamedGraph g) => String -> a -> IDMonad g (TDV a)Source

Create a chance node

decisionNode :: (Bounded a, Enum a, NamedGraph g) => String -> a -> IDMonad g DEVSource

Create a decision node

utilityNode :: NamedGraph g => String -> IDMonad g UVSource

Create an utility node

proba :: (ChanceVariable c, DirectedGraph g) => c -> IDMonad g cSource

Define that a chance node is a probability (not conditional) Values are ordered like FFF FFT FTF FTT TFF TFT TTF TTT and same for other enumeration keeping enumeration order

decision :: (DirectedGraph g, BayesianDiscreteVariable dv) => DEV -> [dv] -> IDMonad g DEVSource

Define a decision dependence

utility :: (DirectedGraph g, BayesianDiscreteVariable dv) => UV -> [dv] -> IDMonad g UVSource

Define a utility dependence

cpt :: (DirectedGraph g, BayesianDiscreteVariable vb, ChanceVariable c) => c -> [vb] -> IDMonad g cSource

Define that a chance node is a conditional probability and define the parent variables

noDependencies :: [DV]Source

Used to define a root decision which is not dependent on any past node

# Solving

decisionsOrder :: InfluenceDiagram -> [ChancesOrDecision]Source

List of decision vertices in reverse temporal order (corresponding to elimination order)

solveInfluenceDiagram :: InfluenceDiagram -> [DecisionFactor]Source

Solve an influence diagram. A DecisionFactor is generated for each decision variable. A decision factor is containing a variable instantiation instead of a double. This instantiation is giving the decision to take for each value of the parents.

runID :: IDMonad DirectedSG a -> (a, InfluenceDiagram)Source

Run an influence monad

policyNetwork :: [DecisionFactor] -> InfluenceDiagram -> SBN CPTSource

Create a policy network from an influence diagram and its solution. A policy network is a Bayesian network where the decision nodes have been replaced with probability nodes where the probability is 1 when the configuration is corresponding to the decision and 0 otherwise.

decisionToInstantiation :: DecisionFactor -> [DVISet]Source

Convert a decision policy to a set of possible instantiations It is the only way to access to the content of a decision factor.

# Testing

Discrete Variable instantiation. A variable and its value

Eq DVI | |

Show DVI | |

Show MAXCPT | |

Show DecisionFactor | |

BayesianDiscreteVariable DVI | |

BayesianVariable DVI | |

IsBucketItem MAXCPT | |

MultiDimTable MAXCPT | |

MultiDimTable DecisionFactor | |

Factor MAXCPT | |

LabeledVertex DVI | |

InstantiationValue DVI Int | |

(Bounded b, Enum b) => Instantiable DV b DVI | |

Instantiable DEV Int DVI | |

SampleGeneration DV DVI DV Int | |

(Bounded b, Enum b) => Instantiable (TDV b) b DVI | |

Graph g => Show (Sample g [DVI]) | |

Show (DirectedSG () MAXCPT) | |

FactorElement (Double, PossibleInstantiations) |