-
Notifications
You must be signed in to change notification settings - Fork 3
/
t_legacy.py
71 lines (59 loc) · 3.71 KB
/
t_legacy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Testing legacy code"""
import numpy as np
import os
import matplotlib.pyplot as plt
import unittest
from gpkit import Model
from gpkit.tests.helpers import run_tests
from gpkit.constraints.bounded import Bounded
from robust.testing.models import simple_wing
from robust.simulations import simulate
from robust.simulations import read_simulation_data
class TestLegacy(unittest.TestCase):
def test_simple_wing(self):
model = Model(simple_wing().cost, simple_wing(), simple_wing().substitutions, allow_missingbounds=True)
number_of_time_average_solves = 3
number_of_iterations = 10
nominal_solution, nominal_solve_time, nominal_number_of_constraints, directly_uncertain_vars_subs = \
simulate.generate_model_properties(model, number_of_time_average_solves, number_of_iterations)
model_name = 'Simple_Wing'
gammas = np.linspace(0.0, 1.0, 3)
min_num_of_linear_sections = 3
max_num_of_linear_sections = 99
linearization_tolerance = 1e-4
verbosity = 0
methods = [{'name': 'Best Pairs', 'twoTerm': True, 'boyd': False, 'simpleModel': False},
{'name': 'Linear. Perts.', 'twoTerm': False, 'boyd': False, 'simpleModel': False},
{'name': 'Simple Cons.', 'twoTerm': False, 'boyd': False, 'simpleModel': True},
{'name': 'Two Term', 'twoTerm': False, 'boyd': True, 'simpleModel': False}]
uncertainty_sets = ['box', 'elliptical']
variable_gamma_file_name = os.path.dirname(__file__) + '/' + \
model_name + '_simulation_data_variable_gamma.txt'
simulate.print_variable_gamma_results(model, model_name, gammas, number_of_iterations,
min_num_of_linear_sections,
max_num_of_linear_sections, verbosity, linearization_tolerance,
variable_gamma_file_name, number_of_time_average_solves, methods,
uncertainty_sets, nominal_solution, nominal_solve_time,
nominal_number_of_constraints, directly_uncertain_vars_subs)
gamma = 1.
numbers_of_linear_sections = [12, 20, 30, 44, 60, 80]
methods = [{'name': 'Best Pairs', 'twoTerm': True, 'boyd': False, 'simpleModel': False},
{'name': 'Linear. Perts.', 'twoTerm': False, 'boyd': False, 'simpleModel': False},
{'name': 'Two Term', 'twoTerm': False, 'boyd': True, 'simpleModel': False}]
uncertainty_sets = ['box', 'elliptical']
variable_pwl_file_name = os.path.dirname(__file__) + '/' + \
model_name + '_simulation_data_variable_pwl.txt'
simulate.print_variable_pwlsections_results(model, model_name, gamma, number_of_iterations,
numbers_of_linear_sections, linearization_tolerance,
verbosity, variable_pwl_file_name,
number_of_time_average_solves, methods, uncertainty_sets,
nominal_solution, nominal_solve_time,
nominal_number_of_constraints, directly_uncertain_vars_subs)
read_simulation_data.generate_all_plots(variable_gamma_file_name,
variable_pwl_file_name)
plt.close()
TESTS = [] #TODO: reactivate TestLegacy
def test():
run_tests(TESTS)
if __name__ == "__main__":
test()