Author: Cheuk Ting Li
from psitip import *
# PsiOpts.setting(solver = "pyomo.glpk") # Set linear programming solver
PsiOpts.setting(solver = "pyomo.gurobi") # Set linear programming solver
PsiOpts.setting(repr_latex = True) # Jupyter Notebook LaTeX display
PsiOpts.setting(venn_latex = True) # LaTeX in diagrams
PsiOpts.setting(proof_note_color = "blue") # Reasons in proofs are blue
X, Y, Z, S, U = rv("X, Y, Z, S, U")
M1, M2 = rv_array("M", 1, 3)
R1, R2 = real_array("R", 1, 3)
# Define state-dependent semideterministic BC [Lapidoth-Wang 2012]
model = CodingModel()
model.set_rate(M1, R1) # Rate of M1 is R1
model.set_rate(M2, R2) # Rate of M2 is R2
model.add_node(M1+M2+S, X,
label = "Enc") # Encoder maps M1,M2,S to X
model.add_edge(X+S, Y, is_fcn=True) # Y is a function of X,S
model.add_edge(X+S, Z) # Channel X,S -> Z
model.add_node(Y, M1,
label = "Dec 1") # Decoder 1 maps Y to M1
model.add_node(Z, M2,
label = "Dec 2") # Decoder 2 maps Z to M2
model.graph() # Draw diagram
# Inner bound via [Lee-Chung 2015], give [Lapidoth-Wang 2012]
r = model.get_inner(is_proof=True)
r.display(note=True)
# Inner bound via [Lee-Chung 2015], give [Lapidoth-Wang 2012]
r = model.get_inner()
r
# Enable case decomposition
with PsiOpts(cases = True):
# Output converse proof (is_proof = True for shorter proof)
(model.get_outer(is_proof = True) >> r).proof().display()
X, Y, Z, S, U, V, W = rv("X, Y, Z, S, U, V, W")
M1, M2 = rv_array("M", 1, 3)
R1, R2 = real_array("R", 1, 3)
# Define state-dependent semideterministic BC, causal [Lapidoth-Wang 2012]
model = CodingModel()
model.set_rate(M1, R1) # Rate of M1 is R1
model.set_rate(M2, R2) # Rate of M2 is R2
model.add_node(M1+M2+S, X,
label = "Enc", rv_in_causal=S) # Encoder maps M1,M2,S to X
model.add_edge(X+S, Y, is_fcn=True) # Y is a function of X,S
model.add_edge(X+S, Z) # Channel X,S -> Z
model.add_node(Y, M1,
label = "Dec 1") # Decoder 1 maps Y to M1
model.add_node(Z, M2,
label = "Dec 2") # Decoder 2 maps Z to M2
# Inner bound via [Lee-Chung 2015]
r = model.get_inner(is_proof=True)
r.display(note=True)
rs = r.subs(list(zip(r.aux, [U, V, W])))
rs
print(rs)
( ( R_1 >= 0 ) &( R_2 >= 0 ) &( R_1 <= I(W+U&Y) ) &( R_2 <= I(W+V&Z) ) &( R_1+R_2 <= I(U&Y|W)+I(W+V&Z)-I(U&V|W) ) &( R_1+R_2 <= I(V&Z|W)+I(W+U&Y)-I(U&V|W) ) &( H(Y|S+X) == 0 ) &( indep(W+U+V, S) ) &( markov(W+U+V+Y, S+X, Z) ) ).exists(U+V+W)
r2 = rs.simplified(level=9)
r2
print(r2.tostring(style="std"))
{ R_1 >= 0, R_2 >= 0, R_1 <= I(U,W;Y), R_2 <= I(V,W;Z), R_1+R_2 <= I(U;Y|W)+I(V,W;Z)-I(U;V|W), R_1+R_2 <= I(V;Z|W)+I(U,W;Y)-I(U;V|W), H(Y|S,X) == 0, indep(S, (U,V,W)), markov((U,V,W,Y), (S,X), Z) } , exists U,V,W
# Enable case decomposition
with PsiOpts(cases = True):
# Output converse proof (is_proof = True for shorter proof)
(model.get_outer(is_proof = True) >> r).proof().display()
r_out = model.get_outer(1, future=False)
r_out
--------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) <ipython-input-8-eb0f91e2acdf> in <module> ----> 1 r_out = model.get_outer(1, future=False) 2 r_out ~\Documents\pyprojs\psitip\psitip.py in get_outer(self, aux, oneshot, future, convexify, add_csiszar_sum, leaf_remove, node_fcn, node_fcn_force, skip_simplify, convexify_test, is_proof, include_nondecode_series, include_last_future, full) 29756 return (r, -1 if hassingleconvexify else 0) 29757 > 29758 r = r.aux_reduced(aux, aux_pairs = aux_pairs, aux_force = aux_force, score_fcn = score_fcn) 29759 29760 if not skip_simplify: ~\Documents\pyprojs\psitip\psitip.py in aux_reduced(self, new_aux, maxsize, skip_simplify, aux_pairs, aux_force, score_fcn) 19140 new_pts_outer = [] 19141 # t = self.discover(discover_list + list(zip(new_aux, cauxs)), init_pts_outer = pts_outer, pts_outer = new_pts_outer) > 19142 t = self.discover(discover_list + list(zip(new_aux, cauxs))) 19143 # r.append(t) 19144 if PsiOpts.is_timer_ended(): ~\Documents\pyprojs\psitip\psitip.py in discover(self, entries, method, minsize, maxsize, skip_simplify, reg_init, skipto_ex, toreal_prefix, balanced, init_pts_outer, pts_outer) 21474 return (ropt, rr) 21475 > 21476 rt = LinearProg.proj_hull(cprog, m, toexpr = toexpr, iscone = (method == "hull_cone"), init_pts_outer = init_pts_outer, pts_outer = pts_outer) 21477 21478 ~\Documents\pyprojs\psitip\psitip.py in proj_hull(prog, n, init_pt, toexpr, iscone, isfrac, max_facet, num_simplex, init_pts_outer, pts_outer) 13032 13033 for y in ineqs_tried: > 13034 if sum(abs(a - b) for a, b in zip(x, y)) <= ceps: 13035 break 13036 else: ~\Documents\pyprojs\psitip\psitip.py in <genexpr>(.0) 13032 13033 for y in ineqs_tried: > 13034 if sum(abs(a - b) for a, b in zip(x, y)) <= ceps: 13035 break 13036 else: KeyboardInterrupt: