Пример #1
0
    def set_functional(self):

        if self.parms == 6:
            self._gist_functional_ext = gist_functional_6p_ext
        elif self.parms == 5:
            self._gist_functional_ext = gist_functional_5p_ext
        elif self.parms == 4:
            self._gist_functional_ext = gist_functional_4p_ext

        else:
            parms_error(self.parms, self._parms)

        ### Note, all arrays which are passed to the functionals (such as
        ### gist_functional_6p_ext), must be DOUBLE (i.e. 32bit floating
        ### point type in C). This will not checked within the C routine
        ### (but should be implemented at some point ...).

        if self.pairs:
            self._exp_data = pair_difference_ext(self.dg.astype(DOUBLE),
                                                 self.pairidx)
            self._f = np.zeros(self.N_pairs, dtype=DOUBLE)
            self._g = np.zeros((self.N_pairs, self._parms), dtype=DOUBLE)
        else:
            self._exp_data = np.copy(self.dg.astype(DOUBLE))
            self._f = np.zeros(self.N_case, dtype=DOUBLE)
            self._g = np.zeros((self.N_case, self._parms), dtype=DOUBLE)

        self._gradients = np.zeros((self.N_pos, self.parms), dtype=DOUBLE)
        self._calc_data = np.zeros(self.N_pos, dtype=DOUBLE)
        self._dx = 0.00000001
Пример #2
0
    def set_step(self):

        self.steps = np.zeros(self._parms, dtype=DOUBLE)

        self.steps[-1] = 1.0

        if self.parms == 6:
            self.steps[0] = 1.
            self.steps[1] = 2.0
            self.steps[2] = 1.
            self.steps[3] = 2.0
            self.steps[4] = 2.0

        elif self.parms == 5:
            self.steps[0] = 1.
            self.steps[1] = 2.0
            self.steps[2] = 2.0
            self.steps[3] = 2.0

        elif self.parms == 4:
            self.steps[0] = 2.0
            self.steps[1] = 2.0
            self.steps[2] = 2.0

        else:
            parms_error(self.parms, self._parms)
Пример #3
0
    def set_step(self):

        ### x[0] = E_aff
        ### x[1] = e_co
        ### x[2] = S_aff
        ### x[3] = s_co
        ### x[4] = g_co (Rec)
        ### x[5] = g_co (Cplx)
        ### x[6] = g_co (Lig)
        ### x[7] = C_E
        ### x[8] = C_S

        self.steps = np.zeros(self._parms, dtype=DOUBLE)
        if not self.pairs:
            self.steps[-5] = 2.0
        self.steps[-4] = 2.0
        self.steps[-3] = 2.0
        self.steps[-2] = 1.0
        self.steps[-1] = 1.0

        if self.parms == 6:
            self.steps[0] = 1.
            self.steps[1] = 2.0
            self.steps[2] = 1.
            self.steps[3] = 2.0

        elif self.parms == 5:
            self.steps[0] = 1.
            self.steps[1] = 2.0
            self.steps[2] = 2.0

        elif self.parms == 4:
            self.steps[0] = 2.0
            self.steps[1] = 2.0

        else:
            parms_error(self.parms, self._parms)
Пример #4
0
    def set_bounds(self):

        __doc__ = """
        Ensures that we don't run out of bounds during MC steps.
        """

        ### x[0] = E_aff
        ### x[1] = e_co
        ### x[2] = S_aff
        ### x[3] = s_co
        ### x[4] = g_co (Rec)
        ### x[5] = g_co (Cplx)
        ### x[6] = g_co (Lig)
        ### x[7] = C

        self.xmin = np.zeros(self._parms, dtype=DOUBLE)
        self.xmax = np.zeros(self._parms, dtype=DOUBLE)

        self._restraint_grad = np.zeros(self._parms, dtype=DOUBLE)
        self._restraint = 0.

        self.kforce_f = np.zeros(self._parms, dtype=DOUBLE)

        if self.pairs:
            _E = np.min([np.min(self.E_cplx),np.min(self.E_lig)]),\
                np.max([np.max(self.E_cplx),np.max(self.E_lig)])

            _S = np.min([np.min(self.S_cplx),np.min(self.S_lig)]),\
                np.max([np.max(self.S_cplx),np.max(self.S_lig)])

        else:
            _E = np.min([np.min(self.E_cplx),np.min(self.E),np.min(self.E_lig)]),\
                np.max([np.max(self.E_cplx),np.max(self.E),np.max(self.E_lig)])

            _S = np.min([np.min(self.S_cplx),np.min(self.S),np.min(self.S_lig)]),\
                np.max([np.max(self.S_cplx),np.max(self.S),np.max(self.S_lig)])

        if isinstance(self.boundsdict, dict):
            if not self.pairs:
                self.xmin[-5], self.xmax[-5] = self.boundsdict['g_co'][
                    0], self.boundsdict['g_co'][1]  ### g_co (Rec)
                self.kforce_f[-5] = 10.
            self.xmin[-4], self.xmax[-4] = self.boundsdict['g_co'][
                0], self.boundsdict['g_co'][1]  ### g_co (Cplx)
            self.xmin[-3], self.xmax[-3] = self.boundsdict['g_co'][
                0], self.boundsdict['g_co'][1]  ### g_co (Lig)
            self.xmin[-2], self.xmax[-2] = self.boundsdict['C'][
                0], self.boundsdict['C'][1]  ### C_E
            self.xmin[-1], self.xmax[-1] = self.boundsdict['C'][
                0], self.boundsdict['C'][1]  ### C_S
            self.kforce_f[-4] = 10.
            self.kforce_f[-3] = 10.
            self.kforce_f[-2] = 1.
            self.kforce_f[-1] = 1.
        else:
            _g_r = np.min(self.g), np.max(self.g)
            _g_c = np.min(self.g_cplx), np.max(self.g_cplx)
            _g_l = np.min(self.g_lig), np.max(self.g_lig)
            if not self.pairs:
                self.xmin[-5], self.xmax[-5] = np.min(_g_r), np.max(
                    _g_r)  ### g_co (Rec)
                self.kforce_f[-5] = 10.
            self.xmin[-4], self.xmax[-4] = np.min(_g_c), np.max(
                _g_c)  ### g_co (Cplx)
            self.xmin[-3], self.xmax[-3] = np.min(_g_l), np.max(
                _g_l)  ### g_co (Lig)
            self.xmin[-2], self.xmax[-2] = -10., 10.  ### C_E
            self.xmin[-1], self.xmax[-1] = -10., 10.  ### C_S
            self.kforce_f[-4] = 10.
            self.kforce_f[-3] = 10.
            self.kforce_f[-2] = 1.
            self.kforce_f[-1] = 1.

        if self.parms == 6:

            if isinstance(self.boundsdict, dict):
                self.xmin[0], self.xmax[0] = self.boundsdict['E'][
                    0], self.boundsdict['E'][1]  ### E_aff
                self.xmin[1], self.xmax[1] = self.boundsdict['e_co'][
                    0], self.boundsdict['e_co'][1]  ### e_co
                self.xmin[2], self.xmax[2] = self.boundsdict['S'][
                    0], self.boundsdict['S'][1]  ### S_aff
                self.xmin[3], self.xmax[3] = self.boundsdict['s_co'][
                    0], self.boundsdict['s_co'][1]  ### s_co
            else:
                self.xmin[0], self.xmax[0] = -10, 10.  ### E_aff
                self.xmin[1], self.xmax[1] = _E[0], _E[1]  ### e_co
                self.xmin[2], self.xmax[2] = -10., 10.  ### S_aff
                self.xmin[3], self.xmax[3] = _S[0], _S[1]  ### s_co
            self.kforce_f[0] = 1.
            self.kforce_f[1] = 10.
            self.kforce_f[2] = 1.
            self.kforce_f[3] = 10.

        elif self.parms == 5:

            if isinstance(self.boundsdict, dict):
                self.xmin[0], self.xmax[0] = self.boundsdict['E'][
                    0], self.boundsdict['E'][1]  ### Aff
                self.xmin[1], self.xmax[1] = self.boundsdict['e_co'][
                    0], self.boundsdict['e_co'][1]  ### e_co
                self.xmin[2], self.xmax[2] = self.boundsdict['s_co'][
                    0], self.boundsdict['s_co'][1]  ### s_co
            else:
                self.xmin[0], self.xmax[0] = -10, 10.  ### Aff
                self.xmin[1], self.xmax[1] = _E[0], _E[1]  ### e_co
                self.xmin[2], self.xmax[2] = _S[0], _S[1]  ### s_co
            self.kforce_f[0] = 1.
            self.kforce_f[1] = 10.
            self.kforce_f[2] = 10.

        elif self.parms == 4:

            if isinstance(self.boundsdict, dict):
                self.xmin[0], self.xmax[0] = self.boundsdict['e_co'][
                    0], self.boundsdict['e_co'][1]  ### e_co
                self.xmin[1], self.xmax[1] = self.boundsdict['s_co'][
                    0], self.boundsdict['s_co'][1]  ### s_co
            else:
                self.xmin[0], self.xmax[0] = _E[0], _E[1]  ### e_co
                self.xmin[1], self.xmax[1] = _S[0], _S[1]  ### s_co
            self.kforce_f[0] = 10.
            self.kforce_f[1] = 10.

        else:
            parms_error(self.parms, self._parms)
Пример #5
0
    def set_bounds(self):

        __doc__ = """
        Ensures that we don't run out of bounds during MC steps.
        """

        self.xmin = np.zeros(self._parms, dtype=DOUBLE)
        self.xmax = np.zeros(self._parms, dtype=DOUBLE)

        self._restraint_grad = np.zeros(self._parms, dtype=DOUBLE)
        self._restraint = 0.

        self.kforce_f = np.zeros(self._parms, dtype=DOUBLE)

        if isinstance(self.boundsdict, dict):
            self.xmin[-2], self.xmax[-2] = self.boundsdict['C'][
                0], self.boundsdict['C'][1]  ### C_E
            self.xmin[-1], self.xmax[-1] = self.boundsdict['C'][
                0], self.boundsdict['C'][1]  ### C_S
        else:
            self.xmin[-2], self.xmax[-2] = -10., 10.  ### C
            self.xmin[-1], self.xmax[-1] = -10., 10.  ### C

        self.kforce_f[-2] = 1.
        self.kforce_f[-1] = 1.

        if self.parms == 6:

            if isinstance(self.boundsdict, dict):
                self.xmin[0], self.xmax[0] = self.boundsdict['E'][
                    0], self.boundsdict['E'][1]  ### E_aff
                self.xmin[1], self.xmax[1] = self.boundsdict['e_co'][
                    0], self.boundsdict['e_co'][1]  ### e_co
                self.xmin[2], self.xmax[2] = self.boundsdict['S'][
                    0], self.boundsdict['S'][1]  ### S_aff
                self.xmin[3], self.xmax[3] = self.boundsdict['s_co'][
                    0], self.boundsdict['s_co'][1]  ### s_co
                self.xmin[4], self.xmax[4] = self.boundsdict['g_co'][
                    0], self.boundsdict['g_co'][1]  ### g_co
            else:
                self.xmin[0], self.xmax[0] = -10, 10.  ### E_aff
                self.xmin[1], self.xmax[1] = np.min(self.E), np.max(
                    self.E)  ### e_co
                self.xmin[2], self.xmax[2] = -10., 10.  ### S_aff
                self.xmin[3], self.xmax[3] = np.min(self.S), np.max(
                    self.S)  ### s_co
                self.xmin[4], self.xmax[4] = 1., np.max(self.g)  ### g_co
            self.kforce_f[0] = 1.
            self.kforce_f[1] = 10.
            self.kforce_f[2] = 1.
            self.kforce_f[3] = 10.
            self.kforce_f[4] = 10.

        elif self.parms == 5:

            if isinstance(self.boundsdict, dict):
                self.xmin[0], self.xmax[0] = self.boundsdict['E'][
                    0], self.boundsdict['E'][1]  ### Aff
                self.xmin[1], self.xmax[1] = self.boundsdict['e_co'][
                    0], self.boundsdict['e_co'][1]  ### e_co
                self.xmin[2], self.xmax[2] = self.boundsdict['s_co'][
                    0], self.boundsdict['s_co'][1]  ### s_co
                self.xmin[3], self.xmax[3] = self.boundsdict['g_co'][
                    0], self.boundsdict['g_co'][1]  ### g_co
            else:
                self.xmin[0], self.xmax[0] = -10, 10.  ### Aff
                self.xmin[1], self.xmax[1] = np.min(self.E), np.max(
                    self.E)  ### e_co
                self.xmin[2], self.xmax[2] = np.min(self.S), np.max(
                    self.S)  ### s_co
                self.xmin[3], self.xmax[3] = 1., np.max(self.g)  ### g_co
            self.kforce_f[0] = 1.
            self.kforce_f[1] = 10.
            self.kforce_f[2] = 10.
            self.kforce_f[3] = 10.

        elif self.parms == 4:

            if isinstance(self.boundsdict, dict):
                self.xmin[0], self.xmax[0] = self.boundsdict['e_co'][
                    0], self.boundsdict['e_co'][1]  ### e_co
                self.xmin[1], self.xmax[1] = self.boundsdict['s_co'][
                    0], self.boundsdict['s_co'][1]  ### s_co
                self.xmin[2], self.xmax[2] = self.boundsdict['g_co'][
                    0], self.boundsdict['g_co'][1]  ### g_co
            else:
                self.xmin[0], self.xmax[0] = np.min(self.E), np.max(
                    self.E)  ### e_co
                self.xmin[1], self.xmax[1] = np.min(self.S), np.max(
                    self.S)  ### s_co
                self.xmin[2], self.xmax[2] = 1., np.max(self.g)  ### g_co
            self.kforce_f[0] = 10.
            self.kforce_f[1] = 10.
            self.kforce_f[2] = 10.

        else:
            parms_error(self.parms)