jpt.inference.mpe ================= .. py:module:: jpt.inference.mpe Classes ------- .. autoapisummary:: jpt.inference.mpe.MPEState jpt.inference.mpe.BnBNode jpt.inference.mpe.BnBSolution jpt.inference.mpe.MPESolver Module Contents --------------- .. py:class:: MPEState(assignment: jpt.variables.VariableMap) .. py:attribute:: assignment .. py:attribute:: latest_variable :value: None .. py:method:: copy() .. py:method:: assign(variable: Variable or str, value: Any) -> MPEState .. py:method:: __repr__() .. py:class:: BnBNode(solver, state, actual_cost) .. py:attribute:: solver :type: MPESolver .. py:attribute:: old_state :type: MPEState .. py:attribute:: variable :type: jpt.variables.Variable :value: None .. py:attribute:: values :type: Iterator[Any] .. py:attribute:: actual_cost .. py:attribute:: step_cost :value: 0 .. py:attribute:: state :type: MPEState :value: None .. py:method:: _generate_next() .. py:method:: pop() .. py:property:: cost .. py:property:: free_variables .. py:class:: BnBSolution(state: MPEState, cost: float) .. py:attribute:: state .. py:attribute:: cost .. py:class:: MPESolver(distributions: jpt.variables.VariableMap, likelihood_divisor: float = None) Solver for k-MPE inference about n independent variables This algorithm iteratively constructs all ``k`` most probable explanations in descending order by performing a branch-and-bound search in the space of atomic areas of the respective distributions. In constrast to classic BnB search, we do not throw away the pruned states but save them in a priority queue, where we can continue the search for the subsequent 2nd, 3rd, ..., k-th best solution. .. py:attribute:: distributions :type: jpt.variables.VariableMap .. py:attribute:: domains .. py:attribute:: constraints .. py:attribute:: lb .. py:method:: likelihood(solution: BnBSolution) .. py:method:: is_goal_state(state: MPEState) -> bool .. py:method:: variable_order(state: MPEState = None) -> Iterator[jpt.variables.Variable] :param state: The state to start from :return: An iterator over free variables for a state sorted by number of different possible states (lowest amount of values first). .. py:method:: solve(k: int = 0) -> Iterator[List[jpt.variables.ValueAssignment]] Generate ``k`` MPE states with decreasing probability. :return: