Example #1
0
    def test_gutmann_ex8_1_4_log(self):
        """Check solution of ex8_1_4 with Gutmann, log scaling, infstep.

        Sampling-based global search.

        """
        bb = ti.TestBlackBox('ex8_1_4')
        optimum = bb._function.optimum_value
        for seed in self.rand_seeds:
            print()
            print('Solving branin with random seed ' + '{:d}'.format(seed))
            settings = RbfSettings(algorithm='Gutmann',
                                   rbf='multiquadric',
                                   global_search_method='sampling',
                                   target_objval=optimum,
                                   eps_opt=self.eps_opt,
                                   max_iterations=200,
                                   max_evaluations=300,
                                   function_scaling='log',
                                   do_infstep=True,
                                   rand_seed=seed)
            alg = ra.OptAlgorithm(settings, bb)
            res = alg.optimize()
            msg = 'Could not solve branin with Gutmann\'s algorithm'
            target = optimum + (abs(optimum) * self.eps_opt if abs(optimum) >
                                settings.eps_zero else self.eps_opt)
            self.assertLessEqual(res[0], target, msg=msg)
Example #2
0
    def test_msrsm_parallel_st_miqp3_no_local_search(self):
        """Check solution of st_miqp3 with MSRSM and no local search.

        Solver solution of global search problems."""
        bb = ti.TestBlackBox('st_miqp3')
        optimum = bb._function.optimum_value
        for seed in self.rand_seeds:
            print()
            print('Solving st_miqp3 with random seed ' + '{:d}'.format(seed))
            settings = RbfSettings(rbf='cubic',
                                   global_search_method='genetic',
                                   algorithm='MSRSM',
                                   target_objval=optimum,
                                   eps_opt=self.eps_opt,
                                   max_iterations=200,
                                   max_evaluations=300,
                                   num_cpus=4,
                                   local_search_box_scaling=10000,
                                   rand_seed=seed)
            alg = ra.OptAlgorithm(settings, bb)
            res = alg.optimize()
            msg = 'Could not solve st_miqp3 with MSRSM algorithm'
            target = optimum + (abs(optimum) * self.eps_opt if abs(optimum) >
                                settings.eps_zero else self.eps_opt)
            self.assertLessEqual(res[0], target, msg=msg)
Example #3
0
 def test_state_reload(self):
     """Check solution of ex8_1_4 after state save/reload."""
     bb = ti.TestBlackBox('ex8_1_4')
     optimum = bb._function.optimum_value
     handle, filename = tempfile.mkstemp()
     for seed in self.rand_seeds:
         print()
         print('Solving ex8_1_4 with random seed ' + '{:d}'.format(seed))
         settings = RbfSettings(algorithm='MSRSM',
                                rbf='linear',
                                target_objval=optimum,
                                eps_opt=self.eps_opt,
                                max_iterations=200,
                                max_evaluations=300,
                                rand_seed=seed)
         alg = ra.OptAlgorithm(settings, bb)
         res = alg.optimize(5)
         alg.save_to_file(filename)
         alg_reload = ra.OptAlgorithm.load_from_file(filename)
         res = alg_reload.optimize()
         msg = 'Could not solve ex8_1_4 after reload'
         target = optimum + (abs(optimum) * self.eps_opt if abs(optimum) >
                             settings.eps_zero else self.eps_opt)
         self.assertLessEqual(res[0], target, msg=msg)
     os.close(handle)
     os.remove(filename)
Example #4
0
 def test_time_limit(self):
     """Verify that time limits are satisfied."""
     bb = ti.TestBlackBox('hartman6')
     optimum = bb._function.optimum_value
     for seed in self.rand_seeds:
         print()
         print('Solving hartman6 with random seed ' + '{:d}'.format(seed))
         settings = RbfSettings(algorithm='MSRSM',
                                global_search_method='solver',
                                target_objval=optimum,
                                eps_opt=0.0,
                                max_clock_time=2.0,
                                rand_seed=seed)
         start_time = time.time()
         alg = ra.OptAlgorithm(settings, bb)
         res = alg.optimize()
         tot_time = time.time() - start_time
         msg = 'Time limit exceeded with MSRSM algorithm'
         self.assertLessEqual(tot_time, 5.0, msg=msg)
Example #5
0
 def test_msrsm_prob03(self):
     """Check solution of prob03 with the MSRSM algorithm, genetic."""
     bb = ti.TestBlackBox('prob03')
     optimum = bb._function.optimum_value
     for seed in self.rand_seeds:
         print()
         print('Solving prob03 with random seed ' + '{:d}'.format(seed))
         settings = RbfSettings(algorithm='MSRSM',
                                global_search_method='genetic',
                                target_objval=optimum,
                                eps_opt=self.eps_opt,
                                max_iterations=200,
                                max_evaluations=300,
                                rand_seed=seed)
         alg = ra.OptAlgorithm(settings, bb)
         res = alg.optimize()
         msg = 'Could not solve prob03 with MSRSM algorithm'
         target = optimum + (abs(optimum) * self.eps_opt if abs(optimum) >
                             settings.eps_zero else self.eps_opt)
         self.assertLessEqual(res[0], target, msg=msg)
 def test_gutmann_ex8_1_4(self):
     """Check solution of ex8_1_4 with Gutmann's method, genetic."""
     bb = ti.TestBlackBox('ex8_1_4')
     optimum = bb._function.optimum_value
     for seed in self.rand_seeds:
         print()
         print('Solving ex8_1_4 with random seed ' + '{:d}'.format(seed))
         settings = RbfoptSettings(algorithm='Gutmann',
                                   global_search_method='genetic',
                                   target_objval=optimum,
                                   eps_opt=self.eps_opt,
                                   max_iterations=200,
                                   max_evaluations=300,
                                   rand_seed=seed)
         alg = ra.RbfoptAlgorithm(settings, bb)
         res = alg.optimize()
         msg = 'Could not solve ex8_1_4 with Gutmann\'s algorithm'
         target = optimum + (abs(optimum) * self.eps_opt if abs(optimum) >
                             settings.eps_zero else self.eps_opt)
         self.assertLessEqual(res[0], target, msg=msg)
Example #7
0
 def test_msrsm_parallel_ex8_1_4(self):
     """Check solution of ex8_1_4 with the MSRSM algorithm, sampling."""
     bb = ti.TestBlackBox('ex8_1_4')
     optimum = bb._function.optimum_value
     for seed in self.rand_seeds:
         print()
         print('Solving ex8_1_4 with random seed ' + '{:d}'.format(seed))
         settings = RbfSettings(algorithm='MSRSM',
                                global_search_method='sampling',
                                rbf='linear',
                                target_objval=optimum,
                                eps_opt=self.eps_opt,
                                max_iterations=200,
                                max_evaluations=300,
                                num_cpus=2,
                                rand_seed=seed)
         alg = ra.OptAlgorithm(settings, bb)
         res = alg.optimize()
         msg = 'Could not solve ex8_1_4 with MSRSM algorithm'
         target = optimum + (abs(optimum) * self.eps_opt if abs(optimum) >
                             settings.eps_zero else self.eps_opt)
         self.assertLessEqual(res[0], target, msg=msg)
Example #8
0
 def test_gutmann_parallel_prob03(self):
     """Check solution of prob03 with Gutmann's method, sampling."""
     bb = ti.TestBlackBox('prob03')
     optimum = bb._function.optimum_value
     for seed in self.rand_seeds:
         print()
         print('Solving prob03 with random seed ' + '{:d}'.format(seed))
         settings = RbfSettings(algorithm='Gutmann',
                                global_search_method='sampling',
                                rbf='cubic',
                                target_objval=optimum,
                                eps_opt=self.eps_opt,
                                max_iterations=200,
                                max_evaluations=300,
                                num_cpus=2,
                                rand_seed=seed)
         alg = ra.OptAlgorithm(settings, bb)
         res = alg.optimize()
         msg = 'Could not solve prob03 with Gutmann\'s algorithm'
         target = optimum + (abs(optimum) * self.eps_opt if abs(optimum) >
                             settings.eps_zero else self.eps_opt)
         self.assertLessEqual(res[0], target, msg=msg)