Beispiel #1
0
def test_3():
    """This test ensures that the worst-case is increasing with the size of the
    uncertainty set."""
    _, v, q, beta, _, is_cost = get_request()

    rslt = list()
    for beta in np.linspace(0.0, 10):
        rslt.append(get_worst_case_outcome(v, q, beta, is_cost))

    if is_cost:
        cond = np.all(np.diff(np.around(rslt, 5)) >= 0)
    else:
        cond = np.all(np.diff(np.around(rslt, 5)) <= 0)

    np.testing.assert_equal(cond, True)
Beispiel #2
0
def test_1():
    """This test just confirms that the package is running smoothly."""
    x, v, q, beta, gamma, is_cost = get_request()

    get_worst_case_outcome(v, q, beta, is_cost)
    get_worst_case_probs(v, q, beta, is_cost)
Beispiel #3
0
import pickle as pkl
import numpy as np
import socket
import sys

from robupy.auxiliary import get_multiplier_evaluation
from robupy.tests.auxiliary import get_request

num_tests = 1000

if False:

    tests = []
    for _ in range(num_tests):
        print(_)
        x, v, q, beta, gamma, is_cost = get_request()
        args = v, q, gamma
        rslt = get_multiplier_evaluation(*args)
        tests.append([rslt, args])

    pkl.dump(tests, open('regression_vault.robupy.pkl', 'wb'))

fname = '../../robupy/tests/regression_vault.robupy.pkl'
#fname = 'regression_vault.robupy.pkl'

tests = pkl.load(open(fname, 'rb'))
for test in tests:
    rslt, args = test

    # We need to be less strict when the tests were created on a different machine.
    if 'heracles' in socket.gethostname():
Beispiel #4
0
def test_4():
    x, v, q, beta, gamma, is_cost = get_request()
    assert_array_almost_equal(
        criterion_full(gamma, v, q, beta),
        pre_numba_criterion_full(v, q, beta, gamma),
    )
Beispiel #5
0
def test_2():
    x, v, q, beta, gamma, is_cost = get_request()
    assert_array_almost_equal(
        get_worst_case_probs(v, q, beta, is_cost),
        pre_numba_get_worst_case_probs(v, q, beta, is_cost),
    )
Beispiel #6
0
def test_1():
    x, v, q, beta, gamma, is_cost = get_request()
    assert_array_almost_equal(
        pre_numba_get_worst_case_outcome(v, q, beta, is_cost),
        get_worst_case_outcome(v, q, beta, is_cost),
    )