def fill_result_from_objective_history(result, history):
    """
    Overwrite function values in the result object with the values recorded in
    the history.
    """

    # counters
    result.n_fval = history.n_fval
    result.n_grad = history.n_grad
    result.n_hess = history.n_hess
    result.n_res = history.n_res
    result.n_sres = history.n_sres

    # initial values
    result.x0 = history.x0
    result.fval0 = history.fval0

    # best found values
    result.x = history.x_min
    result.fval = history.fval_min

    # trace
    result.trace = history.trace

    return result