Exemplo n.º 1
0
 def _make_xgen(self):
     xl = randint(-10, 0, self.param['n'])
     xu = randint(1, 10, self.param['n'])
     self.info['xl'] = npvec(xl)
     self.info['xu'] = npvec(xu)
     self.info['xgen'] = npvec(
         [(xl[i] + (xu[i] - xl[i]) * randcst())[0] for i in range(self.param['n'])])
Exemplo n.º 2
0
    def _make_ygen(self):
        self._make_u()

        num_double_at_upper = self.info[
            'md_upp_deg'] + self.info['md_upp_nonactive']
        num_not_floating = self.info['md'] - self.info['md_float']

        double_at_upper = npvec(self.u[:num_double_at_upper])
        double_at_lower = zeros(
            self.info['md_low_deg'] + self.info['md_low_nonactive'])
        double_floating = npvec(
            [randcst() * x for x in self.u[num_not_floating:]])

        single_at_lower = zeros(
            self.info['ms_deg'] + self.info['ms_nonactive'])
        single_floating = rand(self.info['ms_active'])

# ygen = conmat([npvec(u[:m_upp_deg+upp_nonactive]),            # double_at_upper
#                     zeros(m_low_deg+low_nonactive),          # double_at_lower
#                     v2,                                      # double_floating
#                     zeros(m_inf_deg+inf_nonactive),          # single_at_lower
# rand(m_inf-m_inf_deg-inf_nonactive)])    # single_floating
        self.info['ygen'] = conmat([
            double_at_upper,  # y=u cases
            double_at_lower,  # y=0 cases
            double_floating,  # 0<y<u cases
            single_at_lower,  # y=0 cases
            single_floating])  # y>0 cases

        for yi in self.info['ygen']:
            assert yi >= 0
        for i in range(self.info['md']):
            assert self.info['ygen'][i] <= self.u[i]
Exemplo n.º 3
0
 def test(self):
     """ Test with a simple input.
     """
     size = 10
     vec = [x for x in range(size)]
     res = helpers.npvec(vec)
     self.assertEqual(res.shape, (size, 1))