Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

from gassolar.solar.solar import Mission as solar_mike 

import os 

 

from robust.simulations import simulate, read_simulation_data 

 

def mike_solar_model(lat): 

""" 

This model comes from convexengineering/gassolar. 

Please clone from and see https://github.com/convexengineering/gassolar 

for details. 

:param lat: 

:return: 

""" 

model = solar_mike(latitude=lat) 

model.cost = model["W_{total}"] 

return model 

 

if __name__ == '__main__': 

model = mike_solar_model(20) 

number_of_time_average_solves = 30 

number_of_iterations = 300 

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 = 'Solar Model' 

gammas = [0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.29, 0.33, 0.39, 0.45, 0.6, 0.87, 1] 

gammas = [0.7 * i for i in gammas] 

min_num_of_linear_sections = 10 

max_num_of_linear_sections = 50 

linearization_tolerance = 1e-3 

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'] 

 

model = mike_solar_model(20) 

 

variable_gamma_file_name = os.path.dirname(__file__) + '/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 = 0.7 * 1 

numbers_of_linear_sections = [12, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 36, 44, 52, 60, 70, 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__) + '/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) 

 

file_path_gamma = os.path.dirname(__file__) + '/simulation_data_variable_gamma.txt' 

file_path_pwl = os.path.dirname(__file__) + '/simulation_data_variable_pwl.txt' 

read_simulation_data.generate_all_plots(file_path_gamma, file_path_pwl)