The MCApprox Mathematica package

Metric-based State Space Reduction for Markov Chains

Authors: Giovanni Bacci, Giorgio Bacci, Kim G. Larsen, and Radu Mardare

In this tutorial we present the main features of the MCApprox package. This Mathematica package implements an Expectation Maximization method for finding a “good” k-states approximation of any given Markov chain. Here bu “good” we mean that it behavior is certified to be close to the original Markov chain by measn of the bisimilarity pseudometric of Desharnais et al. [1].

Preliminaries

Markov Chains and Probabilistic Bisimulations

Definition (Markov Chain). A (discrete-time) Markov chain (MC) is a tuple M = (M,τ, ℓ) consisting of a finite nonempty set M of states, a transition probability function τ : M → Distr(M) (i.e., for arbitrary m ∈ M, CBA-tutorial_1.gif), and a labelling function ℓ : M → L. Where L is a coutable set of labels.

From a theoretical point of view, it is irrelevant whether the transition probability function of a given MC has rational values or not, However, for algorithmic purposes, here we assume that for arbitrary m,u ∈ M, τ(m,u) ∈ Q ∩ [0,1].

Definition (Probabilistic Bisimulation). Let M = (M,τ, ℓ) be an MC. An equivalence relation R ⊆ M × M is a probabilistic bisimulation if whenever (m,u) ∈ R, ℓ(m) = ℓ(u) and for each R-equivalence class C, CBA-tutorial_2.gif.
Two states m,u ∈ M are bisimilar, written m ∼ u, if they are related by some probabilistic bisimulation.

Bisimilarity Pseudometric

The notion of equivalence can be relaxed by means of a pseudometric, which tells us how far apart from each other two elements are and whenever they are at zero distance they are equivalent. Desharnais et al. [1] defined a bisimilarity pseudometric that measures the behavioral similarity of two non-bisimilar MCs. In this tutorial we present this distance by means of its fixed point characterization given by van Breugel et al. [3].
Consider an MC M = (M,τ, ℓ) and a discount factor λ ∈ (0,1]. The set M × M → [0,1] of [0,1]-valued maps on M × M equipped with the point-wise partial order defined by d ⊆ d’ ⇔ d(m,u) ≤ d’(m,u), for all m,u ∈ S.
We define a fixed point operator CBA-tutorial_3.gif, for d : M × M → [0,1] and m,u ∈ S as

CBA-tutorial_4.gif

Where CBA-tutorial_5.gif deonted the Kantorivich pseudometric over probability distributions in M with underlying space distance d. One may find useful to see CBA-tutorial_6.gif as the optimal value of a Transportation Problem with marginals τ(m) and τ(u) and transpotation costs given by d : M × M → [0,1]

CBA-tutorial_7.gif

CBA-tutorial_8.gif is monotonic, thus, by Tarski’s fixed point theorem, its admits a least fixed point. This fixed point is the bisimilarity pseudometric.

Definition (Bisimilarity psudometric). Let M = (M,τ, ℓ) be an MC and λ ∈ (0,1] be a discount factor, then the λ-discounted bisimilarity pseudometric for M, written CBA-tutorial_9.gif, is the least fixed point of CBA-tutorial_10.gif.

The pseudometric CBA-tutorial_11.gif enjoys the property that two states are at distance zero if and only if they are bisimilar.

Let’s play with some Markov chains

Getting started

The package can be loaded by setting as current directory that of the MCApprox package, then using the commad << (Get) as follows

CBA-tutorial_12.gif

Example 1

Let mcM be the Markov chain MC[{x,y,z},tau, ell] defined as follows

CBA-tutorial_13.gif

CBA-tutorial_14.gif

and let mcN be the Markov chain MC[{x,y},theta,ell] defined as follows

CBA-tutorial_15.gif

CBA-tutorial_16.gif

CBA-tutorial_17.gif

CBA-tutorial_18.gif

CBA-tutorial_19.gif

CBA-tutorial_20.gif

CBA-tutorial_21.gif

CBA-tutorial_22.gif

Example 2

CBA-tutorial_23.gif

CBA-tutorial_24.gif

CBA-tutorial_25.gif

CBA-tutorial_26.gif

CBA-tutorial_27.gif

CBA-tutorial_28.gif

CBA-tutorial_29.gif

CBA-tutorial_30.gif

CBA-tutorial_31.gif

CBA-tutorial_32.gif

CBA-tutorial_33.gif

CBA-tutorial_34.gif

CBA-tutorial_35.gif

CBA-tutorial_36.gif

CBA-tutorial_37.gif

CBA-tutorial_38.gif

Case Study: IPv4 Zero Conf Protocol

We consider the IPv4 Zero Conf protocol discussed in Example 10.5 [2]. For convenience, we report the same presentation of the protocol given in there.

The IPv4 zeroconf protocol is designed for a home local network of appliances (microwave oven, laptop, VCR, DVD player, etc.) each of which is supplied with a network interface to enable mutual communication. Such adhoc networks must be hot-pluggable and self- configuring. Among others, this means that when a new appliance (interface) is connected to the network, it must be configured with a unique IP address automatically. The zeroconf protocol solves this task in the following way. A host that needs to be configured randomly selects an IP address, U say, out of the 65,024 available addresses and broadcasts a message (called probe) saying “Who is using the address U?” If the probe is received by a host that is already using the address U, it replies by a message indicating that U is in use. After receiving this message the host to be configured will restart: it randomly selects a new address, broadcasts a probe, etc.
Due to message loss or a busy host, a probe or a reply message may not arrive at some (or all) other hosts. In order to increase the reliability of the protocol, a host is required to send n probes, each followed by a listening period of r time units. Therefore, the host can start using the selected IP address only after n probes have been sent and no reply has been received during n·r time units. Note that after running the protocol a host may still end up using an IP address already in use by another host, e.g., because all probes were lost. This situation, called address collision, is highly undesirable since it may force a host to kill active TCP/IP connections.

The following is a function that models the above potocol as a Markov chain, given the number of probes and the parameters ‘p’ and ‘q’ respectively for the probabilities of loosing the message or hitting an address that that is free to be used.

CBA-tutorial_39.gif

Here we have to instances of the above protocol with 10 and 2 succesive probes respectively.

CBA-tutorial_40.gif

CBA-tutorial_41.gif

CBA-tutorial_42.gif

In the following we find a (sub-optimal) approximant of the protocol with 10 probes starting the search from an instance of the same protocol with only 2 probes

CBA-tutorial_43.gif

CBA-tutorial_44.gif

CBA-tutorial_45.gif

CBA-tutorial_46.gif

CBA-tutorial_47.gif

CBA-tutorial_48.gif

CBA-tutorial_49.gif

CBA-tutorial_50.gif

CBA-tutorial_51.gif

CBA-tutorial_52.gif

CBA-tutorial_53.gif

CBA-tutorial_54.gif

We can see that both the heuristics give very good results within few iterations. In this case the Averaged Marginal method seems to produce slightly better results, compared to the Averaged Expextation method.

Case Study: Drunkard’s Walk

A man walks along a four - block stretch of Park Avenue. If he is at corner 1, 2, or 3, then he walks to the left with probability p or to the right with probability (1-p). He continues until he reaches corner 4, which is a bar, or corner 0, which is his home. If he reaches either home or the bar, he stays there.

CBA-tutorial_55.gif

CBA-tutorial_56.gif

CBA-tutorial_57.gif

CBA-tutorial_58.gif

CBA-tutorial_59.gif

CBA-tutorial_60.gif

CBA-tutorial_61.gif

CBA-tutorial_62.gif

CBA-tutorial_63.gif

CBA-tutorial_64.gif

CBA-tutorial_65.gif

CBA-tutorial_66.gif

CBA-tutorial_67.gif

CBA-tutorial_68.gif

CBA-tutorial_69.gif

CBA-tutorial_70.gif

Spikey Created with Wolfram Mathematica 9.0