Safe Haskell | Safe-Infered |
---|

Bucket algorithms for variable elimination with enough flexibility to also work with influence diagrams.

- data Buckets f = Buckets !(EliminationOrder DV) !(Map DV [f])
- type EliminationOrder dv = [dv]
- class IsBucketItem f where
- scalarItem :: f -> Bool
- itemProduct :: [f] -> f
- itemProjectOut :: DV -> f -> f
- itemContainsVariable :: f -> DV -> Bool

- createBuckets :: IsBucketItem f => [f] -> EliminationOrder DV -> EliminationOrder DV -> Buckets f
- getBucket :: DV -> Buckets f -> [f]
- updateBucket :: IsBucketItem f => DV -> f -> Buckets f -> Buckets f
- addBucket :: IsBucketItem f => Buckets f -> f -> Buckets f
- removeFromBucket :: DV -> Buckets f -> Buckets f
- marginalizeOneVariable :: IsBucketItem f => Buckets f -> DV -> Buckets f

# Types

Used for bucket elimination. Factor are organized by their first DV

Buckets !(EliminationOrder DV) !(Map DV [f]) |

type EliminationOrder dv = [dv]Source

Elimination order

class IsBucketItem f whereSource

Operations needed to process a bucket items

scalarItem :: f -> BoolSource

itemProduct :: [f] -> fSource

itemProjectOut :: DV -> f -> fSource

itemContainsVariable :: f -> DV -> BoolSource

IsBucketItem MAXCPT | |

IsBucketItem CPT | |

IsBucketItem JoinSum |

# Functions

:: IsBucketItem f | |

=> [f] | Factor to use for computing the marginal one |

-> EliminationOrder DV | Variables to eliminate |

-> EliminationOrder DV | Remaining variables |

-> Buckets f |

:: IsBucketItem f | |

=> DV | Variable that was eliminated |

-> f | New factor resulting from this elimination |

-> Buckets f | |

-> Buckets f |

Update bucket

addBucket :: IsBucketItem f => Buckets f -> f -> Buckets fSource

Add a factor to the right bucket

removeFromBucket :: DV -> Buckets f -> Buckets fSource

Remove a variable from the bucket

marginalizeOneVariable :: IsBucketItem f => Buckets f -> DV -> Buckets fSource