예제 #1
0
    def to_json(self, p_dump=True):

        dictionary = {
            self.DIMENSION: self.dimension,
            self.A_CODE: self._A.tolist(),
            self.B_CODE: self._b.tolist(),
            self.A_INV_CODE: self._A_inv.tolist(),
            self.THETA_CODE: self._theta.tolist()
        }

        return serialize_json(dictionary, p_dump)
예제 #2
0
    def to_json(self, p_dump=True):

        # Nombre bras
        # Bras i : [succes, echecs]

        json_dictionnary = {}
        json_dictionnary[self.NOMBRE_BRAS] = self.nombre_bras
        json_dictionnary[self.CLASS] = type(self).__name__
        json_dictionnary["prior"] = {}

        for i_k in range(self.nombre_bras):
            json_dictionnary["prior"][i_k] = {
                self.SUCCESS: self.prior[i_k][self.INDEX_SUCCESS],
                self.FAILURE: self.prior[i_k][self.INDEX_FAILURE]
            }

        return serialize_json(json_dictionnary, p_dump)
예제 #3
0
    def to_json(self, p_dump=True):

        dictionary = {self.NOMBRE_BRAS: self.nombre_bras}

        is_wrapper_unique = self.wrappers is not None and type(self.wrappers) != list

        if is_wrapper_unique:
            dictionary[self.WRAPPER] = self.wrappers.to_json(False)

        for i_k in range(self.nombre_bras):

            dictionary[i_k] = {}

            dictionary[i_k][self.BRAIN] = self.brains[i_k].to_json(False)

            if self.wrappers is not None:

                if not is_wrapper_unique:
                    dictionary[i_k][self.WRAPPER] = self.wrappers[i_k].to_json(False)

        return serialize_json(dictionary, p_dump)
예제 #4
0
    def to_json(self, p_dump=True):

        # Nombre bras
        # Compteurs t
        # Bras i : [INDEX_NOMBRE_TIRAGES, INDEX_RECOMPENSE_CUMULEE]

        json_dictionnary = {}
        json_dictionnary[self.NOMBRE_BRAS] = self.nombre_bras

        json_dictionnary[self.CLASS] = type(self).__name__

        json_dictionnary[self.NB_ITERATIONS_GLOBAL] = self.t

        json_dictionnary[self.COUNTERS] = {}

        for k in range(self.nombre_bras):
            json_dictionnary[self.COUNTERS][k] = {
                self.NB_TIRAGES:
                self.counters[k][self.INDEX_NOMBRE_TIRAGES],
                self.CUMULATED_REWARD:
                self.counters[k][self.INDEX_RECOMPENSE_CUMULEE]
            }

        return serialize_json(json_dictionnary, p_dump)
예제 #5
0
    def to_json(self, p_dump=True):

        return serialize_json({self.NOMBRE_BRAS: self.nombre_bras}, p_dump)