Ejemplo n.º 1
0
    def test_neighbor_lingeling(self):
        print("lingeling neighbor")

        cs = ConfigSpace(self.lingeling_pcs_file)
        def_config = cs.get_default_config_dict()
        def_vec = cs.convert_param_dict(def_config)

        t0 = time.time()
        for _ in xrange(0, 10000):
            neighbor_vec = cs.get_random_neighbor(def_vec)
        print("lingeling neighbor time (sec): %f" % (time.time() - t0))
Ejemplo n.º 2
0
    def test_neighbor_clasp(self):
        print("clasp neighbor")

        cs = ConfigSpace(self.clasp_pcs_file)
        def_config = cs.get_default_config_dict()
        def_vec = cs.convert_param_dict(def_config)

        t0 = time.time()
        for _ in xrange(0, 10000):
            neighbor_vec = cs.get_random_neighbor(def_vec)
        print("clasp neighbor time (sec): %f" % (time.time() - t0))

        for _ in xrange(1000):
            random_vec = cs.get_random_config_vector()
            random_dic_ = cs.convert_param_vector(random_vec)
            random_vec_ = cs.convert_param_dict(random_dic_)
            for i, (v1, v2) in enumerate(zip(random_vec, random_vec_)):
                assert (numpy.isnan(v1) and numpy.isnan(v2)) or numpy.allclose(
                    v1, v2), "%d: %f vs %f\n %s\n %s\n" % (
                        i, v1, v2, map(str, random_vec), map(str, random_vec_))