refine_plan.models.state_factor

Classes for representing state factors in Markov models.

Author: Charlie Street Owner: Charlie Street

Module Contents

Classes

StateFactor

Class representing a generic state factor.

BoolStateFactor

A subclass of StateFactor which can only take values True and False.

IntStateFactor

A subclass of StateFactor purely for integer state factors.

class refine_plan.models.state_factor.StateFactor(name, values)

Bases: object

Class representing a generic state factor.

The state factor values are converted into list indexes when writing out in the PRISM language.

_name

The name of the state factor

_values

The valid values for that state factor

_hash_val

A caching variable for the object’s hash

get_value(idx)

Get the state factor value at a given index.

Parameters:

idx – The index

Returns:

The corresponding state factor value

Throws:

_bad_idx_exception: Thrown if an invalid index provided

get_idx(value)

Get the index for a state factor value.

Parameters:

value – The state factor value

Returns:

The corresponding index

Throws:

_bad_val_exception: Raised if an invalid state factor value is given

is_valid_value(value)

Test if a value is valid for the state factor.

Parameters:

value – The value to test

Returns:

True if in self._values, False otherwise

get_valid_values()

Return the valid list of values for the state factor.

Returns:

The state factor values

get_name()

Return the name of the state factor.

Returns:

The state factor name

to_prism_string(initial_value=None)

Write the state factor out in PRISM format.

Parameters:

initial_value – The initial value of that state factor, if applicable.

Returns:

The PRISM string for this state factor

Raises:

bad_init_exception – Raised if initial_value is not valid value

class refine_plan.models.state_factor.BoolStateFactor(name)

Bases: StateFactor

A subclass of StateFactor which can only take values True and False.

Same as superclass.
class refine_plan.models.state_factor.IntStateFactor(name, min, max)

Bases: StateFactor

A subclass of StateFactor purely for integer state factors.

Here, the values and indexes are the same thing.

Same as superclass.
get_value(idx)

Identity function as indexes and values are the same here.

Parameters:

idx – The index

Returns:

The corresponding state factor value

Throws:

_bad_idx_exception: Thrown if an invalid index provided

get_idx(value)

Identity function as indexes and values are the same here.

Parameters:

value – The state factor value

Returns:

The corresponding index

Throws:

_bad_val_exception: Raised if an invalid state factor value is given