Ejemplo n.º 1
0
    def main():
        num_of_comps = 1

        tau_mag = .5
        tau_degs = 35
        rho_degs = 45

        if num_of_comps == 1:
            size1 = 3
            size2 = 4
            max_n_sum = 5
            pa1 = BayesNode(0, "parent1", size=size1)
            pa2 = BayesNode(1, "parent2", size=size2)

            pa1.state_names = [str(k) for k in range(size1)]
            pa2.state_names = [str(k) for k in range(size2)]

            bs = BeamSplitter(2, "a_bs", pa1, pa2,
                    tau_mag, tau_degs, rho_degs, num_of_comps, max_n_sum)

            print("pa1 state names: ", pa1.state_names)
            print("pa2 state names: ", pa2.state_names)
            print("bs state names: ", bs.state_names)
            print(bs.potential)
            print("full dict of total probs: ",
                  bs.potential.get_total_probs())
            print("brief dict of total probs: ",
                  bs.potential.get_total_probs(brief=True))
        elif num_of_comps == 2:
            size1 = 6
            size2 = 8
            max_n_sum = 7
            pa1 = BayesNode(0, "parent1", size=size1)
            pa2 = BayesNode(1, "parent2", size=size2)

            pa1.set_state_names_to_product(
                [range(2), range(3)], trim=False)
            pa2.set_state_names_to_product(
                [range(2), range(4)], trim=False)

            bs = BeamSplitter(2, "a_bs", pa1, pa2,
                    tau_mag, tau_degs, rho_degs, num_of_comps, max_n_sum)

            print("pa1 state names: ", pa1.state_names)
            print("pa2 state names: ", pa2.state_names)
            print("bs state names: ", bs.state_names)
            print(bs.potential)
            print("full dict of total probs: ",
                  bs.potential.get_total_probs())
            print("brief dict of total probs: ",
                  bs.potential.get_total_probs(brief=True))
Ejemplo n.º 2
0
    def main():
        pa_nd = BayesNode(0, "pa_nd", size=24)
        # has_commas = True
        has_commas = False
        pa_nd.set_state_names_to_product(
            [range(2), range(3), range(4)], trim=not has_commas)
        marg = Marginalizer(1,
                            "marg",
                            False,
                            pa_nd,
                            projected_axis=1,
                            has_commas=has_commas)

        print("pa state names: ", pa_nd.state_names)
        print("marg state names: ", marg.state_names)
        print(marg.potential)
        print(marg.potential.get_total_probs())
Ejemplo n.º 3
0
    def main():

        theta_degs = 35
        max_n_sum = 3

        in_nd = BayesNode(0, "parent1", size=6)

        in_nd.set_state_names_to_product([range(2), range(3)], trim=False)

        pr = PolarizationRot(1, "pol_rot", in_nd, theta_degs, max_n_sum)

        print("in_nd state names: ", in_nd.state_names)
        print("pol rot state names: ", pr.state_names)
        print(pr.potential)
        print("full dict of total probs: ", pr.potential.get_total_probs())
        print("brief dict of total probs: ",
              pr.potential.get_total_probs(brief=True))
Ejemplo n.º 4
0
        BayesNode.__init__(self, id_num, name, size=size)
        self.add_parent(pa_nd)

        self.state_names = non_rep_name_list

        pot = DiscreteCondPot(is_quantum, [pa_nd, self], bias=0)
        self.potential = pot

        for k, name in enumerate(self.state_names):
            for r, pa_name in enumerate(rep_name_list):
                if name == pa_name:
                    # remember, focus node is last topo_index
                    self.potential[r, k] = 1

if __name__ == "__main__":
    pa_nd = BayesNode(0, "pa_nd", size=24)
    # has_commas = True
    has_commas = False
    pa_nd.set_state_names_to_product(
        [range(2), range(3), range(4)], trim=not has_commas)
    marg = Marginalizer(1, "marg",
        False, pa_nd, projected_axis=1, has_commas=has_commas)

    print("pa state names: ", pa_nd.state_names)
    print("marg state names: ", marg.state_names)
    print(marg.potential)
    print(marg.potential.get_total_probs())



Ejemplo n.º 5
0
        mx : list[int]
        my : list[int]

        Returns
        -------
        int

        """
        return self.fill_trans_mat_and_st_names_of_nd(
            mx, my, dry_run=True)

if __name__ == "__main__":

    theta_degs = 35
    max_n_sum = 3

    in_nd = BayesNode(0, "parent1", size=6)

    in_nd.set_state_names_to_product(
        [range(2), range(3)], trim=False)

    pr = PolarizationRot(1, "pol_rot", in_nd, theta_degs, max_n_sum)

    print("in_nd state names: ", in_nd.state_names)
    print("pol rot state names: ", pr.state_names)
    print(pr.potential)
    print("full dict of total probs: ",
          pr.potential.get_total_probs())
    print("brief dict of total probs: ",
          pr.potential.get_total_probs(brief=True))
Ejemplo n.º 6
0
        mx : list[int]
        my : list[int]

        Returns
        -------
        int

        """
        return self.fill_trans_mat_and_st_names_of_nd(
            mx, my, dry_run=True)

if __name__ == "__main__":

    theta_degs = 35
    max_n_sum = 3

    in_nd = BayesNode(0, "parent1", size=6)

    in_nd.set_state_names_to_product(
        [range(2), range(3)], trim=False)

    pr = PolarizationRot(1, "pol_rot", in_nd, theta_degs, max_n_sum)

    print("in_nd state names: ", in_nd.state_names)
    print("pol rot state names: ", pr.state_names)
    print(pr.potential)
    print("full dict of total probs: ",
          pr.potential.get_total_probs())
    print("brief dict of total probs: ",
          pr.potential.get_total_probs(brief=True))
Ejemplo n.º 7
0
        print("pa1 state names: ", pa1.state_names)
        print("pa2 state names: ", pa2.state_names)
        print("bs state names: ", bs.state_names)
        print(bs.potential)
        print("full dict of total probs: ",
              bs.potential.get_total_probs())
        print("brief dict of total probs: ",
              bs.potential.get_total_probs(brief=True))
    elif num_of_comps == 2:
        size1 = 6
        size2 = 8
        max_n_sum = 7
        pa1 = BayesNode(0, "parent1", size=size1)
        pa2 = BayesNode(1, "parent2", size=size2)

        pa1.set_state_names_to_product(
            [range(2), range(3)], trim=False)
        pa2.set_state_names_to_product(
            [range(2), range(4)], trim=False)

        bs = BeamSplitter(2, "a_bs", pa1, pa2,
                tau_mag, tau_degs, rho_degs, num_of_comps, max_n_sum)

        print("pa1 state names: ", pa1.state_names)
        print("pa2 state names: ", pa2.state_names)
        print("bs state names: ", bs.state_names)
        print(bs.potential)
        print("full dict of total probs: ",
              bs.potential.get_total_probs())
        print("brief dict of total probs: ",
              bs.potential.get_total_probs(brief=True))