Exemplo n.º 1
0
def create_plotting_options():
    # create sets of reference points (from tuple, dict and from list)
    ref1 = ([1., 1.5], 0.2)
    ref2 = ([1.8, 1.9], 0.6)
    ref3 = {'x': np.array([1.4, 1.7]), 'fval': 0.4}
    ref4 = [ref1, ref2]
    ref_point = visualize.create_references(ref4)

    return ref1, ref2, ref3, ref4, ref_point
Exemplo n.º 2
0
def test_reference_points():
    # create the necessary results
    (ref1, ref2, ref3, ref4, _) = create_plotting_options()

    # Try conversion from different inputs
    visualize.create_references(ref1)
    visualize.create_references(references=ref2)
    ref_list_1 = visualize.create_references(ref3)
    ref_list_2 = visualize.create_references(ref4)

    # Try to append to a list
    ref_list_2.append(ref_list_1[0])
    ref_list_2 = visualize.create_references(ref_list_2)

    # Try to append one point to a list via the interface
    visualize.create_references(references=ref_list_2, x=ref2[0], fval=ref2[1])
Exemplo n.º 3
0
# retrieve second optimum
all_x = result1_bfgs.optimize_result.get_for_key('x')
all_fval = result1_bfgs.optimize_result.get_for_key('fval')
x = all_x[19]
fval = all_fval[19]
print('Second optimum at: ' + str(fval))

# create a reference point from it
ref = {
    'x': x,
    'fval': fval,
    'color': [0.2, 0.4, 1., 1.],
    'legend': 'second optimum'
}
ref = visualize.create_references(ref)

# new waterfall plot with reference point for second optimum
visualize.waterfall(result1_dogleg,
                    size=(15, 6),
                    scale_y='lin',
                    y_limits=[-1, 101],
                    reference=ref,
                    colors=[0., 0., 0., 1.])

###### Visulaize Parameters
visualize.parameters([result1_bfgs, result1_tnc],
                     legends=['L-BFGS-B', 'TNC'],
                     balance_alpha=False)
visualize.parameters(result1_dogleg,
                     legends='dogleg',
Exemplo n.º 4
0
        # Lucarelli  nc =  16 (4* 4)
        # Isensee    nc = 123 (4*30 + 3)
        # Beer       nc =  19 (4* 4 + 3)
        engine_threads = 3
        objective.n_threads = 4

    engine = pypesto.engine.MultiThreadEngine(n_threads=engine_threads)

    options = optimize.OptimizeOptions(allow_failed_starts=True,
                                       report_sres=False,
                                       report_hess=False)

    # do the optimization
    ref = visualize.create_references(
        x=np.asarray(petab_problem.x_nominal_scaled)[np.asarray(
            petab_problem.x_free_indices)],
        fval=problem.objective(
            np.asarray(petab_problem.x_nominal_scaled)[np.asarray(
                petab_problem.x_free_indices)]))

    print(f'Reference fval: {ref[0]["fval"]}')

    hdf_results_file = os.path.join('results', prefix + '.hdf5')

    result = optimize.minimize(
        problem=problem,
        optimizer=optimizer,
        n_starts=N_STARTS,
        engine=engine,
        options=options,
        progress_bar=False,
        filename=None,