Exemplo n.º 1
0
def test_profile_with_history():
    objective = rosen_for_sensi(max_sensi_order=2, integrated=False)['obj']

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        (problem, result, optimizer) = create_optimization_results(objective,
                                                                   dim_full=5)

    profile_options = profile.ProfileOptions(
        min_step_size=0.0005,
        delta_ratio_max=0.05,
        default_step_size=0.005,
        ratio_min=0.03,
    )

    problem.fix_parameters(
        [0, 3],
        [
            result.optimize_result.list[0].x[0],
            result.optimize_result.list[0].x[3],
        ],
    )
    problem.objective.history = pypesto.MemoryHistory({'trace_record': True})
    profile.parameter_profile(
        problem=problem,
        result=result,
        optimizer=optimizer,
        profile_index=np.array([0, 2, 4]),
        result_index=0,
        profile_options=profile_options,
        filename=None,
    )
Exemplo n.º 2
0
    def test_selected_profiling(self):
        # create options in order to ensure a short computation time
        options = profile.ProfileOptions(
            default_step_size=0.02,
            min_step_size=0.005,
            max_step_size=1.0,
            step_size_factor=1.5,
            delta_ratio_max=0.2,
            ratio_min=0.3,
            reg_points=5,
            reg_order=2,
        )

        # 1st run of profiling, computing just one out of two profiles
        result = profile.parameter_profile(
            problem=self.problem,
            result=self.result,
            optimizer=self.optimizer,
            profile_index=np.array([1]),
            next_guess_method='fixed_step',
            result_index=1,
            profile_options=options,
            filename=None,
        )

        self.assertIsInstance(result.profile_result.list[0][1],
                              pypesto.ProfilerResult)
        self.assertIsNone(result.profile_result.list[0][0])

        # 2nd run of profiling, appending to an existing list of profiles
        # using another algorithm and another optimum
        result = profile.parameter_profile(
            problem=self.problem,
            result=result,
            optimizer=self.optimizer,
            profile_index=np.array([0]),
            result_index=2,
            profile_list=0,
            profile_options=options,
            filename=None,
        )

        self.assertIsInstance(result.profile_result.list[0][0],
                              pypesto.ProfilerResult)

        # 3rd run of profiling, opening a new list, using the default algorithm
        result = profile.parameter_profile(
            problem=self.problem,
            result=result,
            optimizer=self.optimizer,
            next_guess_method='fixed_step',
            profile_index=np.array([0]),
            profile_options=options,
            filename=None,
        )
        # check result
        self.assertIsInstance(result.profile_result.list[1][0],
                              pypesto.ProfilerResult)
        self.assertIsNone(result.profile_result.list[1][1])
Exemplo n.º 3
0
def test_profile_with_history():
    objective = test_objective.rosen_for_sensi(max_sensi_order=2,
                                               integrated=False)['obj']

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        (problem, result, optimizer) = \
            create_optimization_results(objective)

    profile_options = profile.ProfileOptions(min_step_size=0.0005,
                                             delta_ratio_max=0.05,
                                             default_step_size=0.005,
                                             ratio_min=0.03)

    problem.objective.history = pypesto.MemoryHistory({'trace_record': True})
    profile.parameter_profile(problem=problem,
                              result=result,
                              optimizer=optimizer,
                              profile_index=np.array(
                                  [1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0]),
                              result_index=0,
                              profile_options=profile_options)