class_docstr: Class for performing approximate inference using Max-Product Linear Programming method.
  
  We derive message passing updates that result in monotone decrease of the dual of the
  MAP LP Relaxation.
  
  Parameters
  ----------
  model: MarkovNetwork for which inference is to be performed.
  
  Examples
  --------
  >>> import numpy as np
  >>> from pgmpy.models import MarkovNetwork
  >>> from pgmpy.inference import Mplp
  >>> from pgmpy.factors.discrete import DiscreteFactor
  >>> student = MarkovNetwork()
  >>> student.add_edges_from([('A', 'B'), ('B', 'C'), ('C', 'D'), ('E', 'F')])
  >>> factor_a = DiscreteFactor(['A'], cardinality=[2], values=np.array([0.54577, 1.8323]))
  >>> factor_b = DiscreteFactor(['B'], cardinality=[2], values=np.array([0.93894, 1.065]))
  >>> factor_c = DiscreteFactor(['C'], cardinality=[2], values=np.array([0.89205, 1.121]))
  >>> factor_d = DiscreteFactor(['D'], cardinality=[2], values=np.array([0.56292, 1.7765]))
  >>> factor_e = DiscreteFactor(['E'], cardinality=[2], values=np.array([0.47117, 2.1224]))
  >>> factor_f = DiscreteFactor(['F'], cardinality=[2], values=np.array([1.5093, 0.66257]))
  >>> factor_a_b = DiscreteFactor(['A', 'B'], cardinality=[2, 2],
  ...                             values=np.array([1.3207, 0.75717, 0.75717, 1.3207]))
  >>> factor_b_c = DiscreteFactor(['B', 'C'], cardinality=[2, 2],
  ...                             values=np.array([0.00024189, 4134.2, 4134.2, 0.00024189]))
  >>> factor_c_d = DiscreteFactor(['C', 'D'], cardinality=[2, 2],
  ...                             values=np.array([0.0043227, 231.34, 231.34, 0.0043227]))
  >>> factor_d_e = DiscreteFactor(['E', 'F'], cardinality=[2, 2],
  ...                             values=np.array([31.228, 0.032023, 0.032023, 31.228]))
  >>> student.add_factors(factor_a, factor_b, factor_c, factor_d, factor_e, factor_f, factor_a_b,
  ...                     factor_b_c, factor_c_d, factor_d_e)
  >>> mplp = Mplp(student)
class_docstr_tok: ["Class","for","performing","approximate","inference","using","Max-Product","Linear","Programming","method",".","We","derive","message","passing","updates","that","result","in","monotone","decrease","of","the","dual","of","the","MAP","LP","Relaxation",".","Parameters","--","--","--","--","--","model",":","MarkovNetwork","for","which","inference","is","to","be","performed",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.models","import","MarkovNetwork",">",">",">","from","pgmpy.inference","import","Mplp",">",">",">","from","pgmpy.factors.discrete","import","DiscreteFactor",">",">",">","student","=","MarkovNetwork","(",")",">",">",">","student.add_edges_from","(","[","(","'","A","'",",","'","B","'",")",",","(","'","B","'",",","'","C","'",")",",","(","'","C","'",",","'D","'",")",",","(","'","E","'",",","'","F","'",")","]",")",">",">",">","factor_a","=","DiscreteFactor","(","[","'","A","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.54577",",","1.8323","]",")",")",">",">",">","factor_b","=","DiscreteFactor","(","[","'","B","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.93894",",","1.065","]",")",")",">",">",">","factor_c","=","DiscreteFactor","(","[","'","C","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.89205",",","1.121","]",")",")",">",">",">","factor_d","=","DiscreteFactor","(","[","'D","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.56292",",","1.7765","]",")",")",">",">",">","factor_e","=","DiscreteFactor","(","[","'","E","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.47117",",","2.1224","]",")",")",">",">",">","factor_f","=","DiscreteFactor","(","[","'","F","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","1.5093",",","0.66257","]",")",")",">",">",">","factor_a_b","=","DiscreteFactor","(","[","'","A","'",",","'","B","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","1.3207",",","0.75717",",","0.75717",",","1.3207","]",")",")",">",">",">","factor_b_c","=","DiscreteFactor","(","[","'","B","'",",","'","C","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","0.00024189",",","4134.2",",","4134.2",",","0.00024189","]",")",")",">",">",">","factor_c_d","=","DiscreteFactor","(","[","'","C","'",",","'D","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","0.0043227",",","231.34",",","231.34",",","0.0043227","]",")",")",">",">",">","factor_d_e","=","DiscreteFactor","(","[","'","E","'",",","'","F","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","31.228",",","0.032023",",","0.032023",",","31.228","]",")",")",">",">",">","student.add_factors","(","factor_a",",","factor_b",",","factor_c",",","factor_d",",","factor_e",",","factor_f",",","factor_a_b",",","...","factor_b_c",",","factor_c_d",",","factor_d_e",")",">",">",">","mplp","=","Mplp","(","student",")"]
docstr: Returns the integrality gap of the current state of the Mplp algorithm. The lesser it is, the closer we are
          towards the exact solution.
  
  Examples
  --------
  >>> from pgmpy.models import MarkovNetwork
  >>> from pgmpy.factors.discrete import DiscreteFactor
  >>> from pgmpy.inference import Mplp
  >>> mm = MarkovNetwork()
  >>> mm.add_nodes_from(['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'])
  >>> mm.add_edges_from([('x1', 'x3'), ('x1', 'x4'), ('x2', 'x4'),
  ...                    ('x2', 'x5'), ('x3', 'x6'), ('x4', 'x6'),
  ...                    ('x4', 'x7'), ('x5', 'x7')])
  >>> phi = [DiscreteFactor(edge, [2, 2], np.random.rand(4)) for edge in mm.edges()]
  >>> mm.add_factors(*phi)
  >>> mplp = Mplp(mm)
  >>> mplp.map_query()
  >>> int_gap = mplp.get_integrality_gap()
docstr_tok: ["Returns","the","integrality","gap","of","the","current","state","of","the","Mplp","algorithm",".","The","lesser","it","is",",","the","closer","we","are","towards","the","exact","solution",".","Examples","--","--","--","--",">",">",">","from","pgmpy.models","import","MarkovNetwork",">",">",">","from","pgmpy.factors.discrete","import","DiscreteFactor",">",">",">","from","pgmpy.inference","import","Mplp",">",">",">","mm","=","MarkovNetwork","(",")",">",">",">","mm.add_nodes_from","(","[","'x1","'",",","'x2","'",",","'x3","'",",","'x4","'",",","'x5","'",",","'x6","'",",","'x7","'","]",")",">",">",">","mm.add_edges_from","(","[","(","'x1","'",",","'x3","'",")",",","(","'x1","'",",","'x4","'",")",",","(","'x2","'",",","'x4","'",")",",","...","(","'x2","'",",","'x5","'",")",",","(","'x3","'",",","'x6","'",")",",","(","'x4","'",",","'x6","'",")",",","...","(","'x4","'",",","'x7","'",")",",","(","'x5","'",",","'x7","'",")","]",")",">",">",">","phi","=","[","DiscreteFactor","(","edge",",","[","2",",","2","]",",","np.random.rand","(","4",")",")","for","edge","in","mm.edges","(",")","]",">",">",">","mm.add_factors","(","*","phi",")",">",">",">","mplp","=","Mplp","(","mm",")",">",">",">","mplp.map_query","(",")",">",">",">","int_gap","=","mplp.get_integrality_gap","(",")"]
code: def get_integrality_gap(self):
      """
      Returns the integrality gap of the current state of the Mplp algorithm. The lesser it is, the closer we are
              towards the exact solution.
  
      Examples
      --------
      >>> from pgmpy.models import MarkovNetwork
      >>> from pgmpy.factors.discrete import DiscreteFactor
      >>> from pgmpy.inference import Mplp
      >>> mm = MarkovNetwork()
      >>> mm.add_nodes_from(['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'])
      >>> mm.add_edges_from([('x1', 'x3'), ('x1', 'x4'), ('x2', 'x4'),
      ...                    ('x2', 'x5'), ('x3', 'x6'), ('x4', 'x6'),
      ...                    ('x4', 'x7'), ('x5', 'x7')])
      >>> phi = [DiscreteFactor(edge, [2, 2], np.random.rand(4)) for edge in mm.edges()]
      >>> mm.add_factors(*phi)
      >>> mplp = Mplp(mm)
      >>> mplp.map_query()
      >>> int_gap = mplp.get_integrality_gap()
      """
  
      return self.integrality_gap
  
imports: import copy
  import itertools
  import networkx
  import numpy
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.inference import Inference
  from pgmpy.models import MarkovNetwork
label_desc: Use image node_id 10 for calling the Mplp obj's underlying member method code with example usage: obj.get_integrality_gap() and returns: self