Exemple #1
0
def create_optimization_result_nan_inf():
    """
    Create a result object containing nan and inf function values
    """
    # get result with only numbers
    result = create_optimization_result()

    # append nan and inf
    optimizer_result = pypesto.OptimizerResult(
        fval=float('nan'), x=np.array([float('nan'), float('nan')]))
    result.optimize_result.append(optimizer_result=optimizer_result)
    optimizer_result = pypesto.OptimizerResult(
        fval=-float('inf'), x=np.array([-float('inf'), -float('inf')]))
    result.optimize_result.append(optimizer_result=optimizer_result)

    return result
Exemple #2
0
def create_optimization_result():
    # create the pypesto problem
    problem = create_problem()

    # write some dummy results for optimization
    result = pypesto.Result(problem=problem)
    for j in range(0, 3):
        optimizer_result = pypesto.OptimizerResult(fval=j * 0.01,
                                                   x=[j + 0.1, j + 1])
        result.optimize_result.append(optimizer_result=optimizer_result)
    for j in range(0, 4):
        optimizer_result = pypesto.OptimizerResult(
            fval=10 + j * 0.01, x=[2.5 + j + 0.1, 2 + j + 1])
        result.optimize_result.append(optimizer_result=optimizer_result)

    return result
Exemple #3
0
import pypesto
import pypesto.visualize
import numpy as np
import scipy as sp
import unittest


objective = pypesto.Objective(fun=sp.optimize.rosen,
                              grad=sp.optimize.rosen_der,
                              hess=sp.optimize.rosen_hess)
lb = -7 * np.ones((1, 2))
ub = 7 * np.ones((1, 2))
problem = pypesto.Problem(objective=objective, lb=lb, ub=ub)
result = pypesto.Result(problem=problem)
for j in range(0, 3):
    optimizer_result = pypesto.OptimizerResult(fval=j * 0.01,
                                               x=[j + 0.1, j + 1])
    result.optimize_result.append(optimizer_result=optimizer_result)
for j in range(0, 4):
    optimizer_result = pypesto.OptimizerResult(fval=10 + j * 0.01,
                                               x=[2.5 + j + 0.1, 2 + j + 1])
    result.optimize_result.append(optimizer_result=optimizer_result)


class TestVisualize(unittest.TestCase):

    @staticmethod
    def test_waterfall():
        pypesto.visualize.waterfall(result)

    @staticmethod
    def test_waterfall_lowlevel():