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, )
def history(request) -> pypesto.History: if request.param == "memory": history = pypesto.MemoryHistory(options={'trace_record': True}) elif request.param == "csv": file = tempfile.mkstemp(suffix='.csv')[1] history = pypesto.CsvHistory(file, options={'trace_record': True}) else: history = pypesto.History() for _ in range(10): result = {FVAL: np.random.randn(), GRAD: np.random.randn(7)} history.update(np.random.randn(7), (0, 1), 'mode_fun', result) history.finalize() return history
def test_trace_all(self): history = pypesto.MemoryHistory(options=pypesto.HistoryOptions( trace_record=True, trace_record_grad=True, trace_record_hess=True, trace_record_res=True, trace_record_sres=True, trace_record_chi2=True, trace_record_schi2=True, )) self.obj.history = history self.check_history()
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)