ANYstructure 5.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anystruct/ANYstructure_documentation.pdf +0 -0
- anystruct/SN_curve_parameters.py +35 -0
- anystruct/__init__.py +0 -0
- anystruct/__main__.py +24 -0
- anystruct/api.py +772 -0
- anystruct/buckling_calc_external.py +120 -0
- anystruct/bulb_anglebar_tbar_flatbar.csv +677 -0
- anystruct/calc_loads.py +526 -0
- anystruct/calc_structure.py +4838 -0
- anystruct/compartment_window.py +176 -0
- anystruct/example_data.py +532 -0
- anystruct/example_data_puls.py +46 -0
- anystruct/excel_inteface.py +244 -0
- anystruct/fatigue_window.py +352 -0
- anystruct/grid_window.py +307 -0
- anystruct/gui.py +24 -0
- anystruct/helper.py +623 -0
- anystruct/images/ANYstructure_logo.jpg +0 -0
- anystruct/images/Buckling_Strength_of_Shells.png +0 -0
- anystruct/images/Panel_geometry_definitions.png +0 -0
- anystruct/images/current_comps_NONE.png +0 -0
- anystruct/images/fls_button.gif +0 -0
- anystruct/images/img_T_L_FB.gif +0 -0
- anystruct/images/img_axial_stresses.gif +0 -0
- anystruct/images/img_ext_pressure_button.gif +0 -0
- anystruct/images/img_ext_pressure_button_def.gif +0 -0
- anystruct/images/img_fixation_parameters.gif +0 -0
- anystruct/images/img_generate_report.gif +0 -0
- anystruct/images/img_int_pressure_button.gif +0 -0
- anystruct/images/img_int_pressure_button_search.gif +0 -0
- anystruct/images/img_multi_opt.gif +0 -0
- anystruct/images/img_optimize.gif +0 -0
- anystruct/images/img_plate_and_stiffener.gif +0 -0
- anystruct/images/img_stf_button.gif +0 -0
- anystruct/images/img_stiffener.gif +0 -0
- anystruct/images/img_stress_button.gif +0 -0
- anystruct/images/img_title.gif +0 -0
- anystruct/images/img_transverse_stress.gif +0 -0
- anystruct/load_factor_window.py +166 -0
- anystruct/load_window.py +721 -0
- anystruct/main_application.py +7918 -0
- anystruct/make_grid_numpy.py +506 -0
- anystruct/make_queue.py +52 -0
- anystruct/make_stack.py +52 -0
- anystruct/ml_files/CL_CSR-Tank_req_cl_predictor.pickle +0 -0
- anystruct/ml_files/CL_CSR-Tank_req_cl_scaler.pickle +0 -0
- anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor.pickle +0 -0
- anystruct/ml_files/CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_scaler.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_buc_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_110_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_predictor_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_1_UP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_SP.pickle +0 -0
- anystruct/ml_files/CL_output_cl_str_ult_115_scaler_In-plane_support_cl_2,_3_UP.pickle +0 -0
- anystruct/opt_problem.py +31 -0
- anystruct/optimize.py +1680 -0
- anystruct/optimize_cylinder.py +898 -0
- anystruct/optimize_geometry.py +1708 -0
- anystruct/optimize_multiple_window.py +1507 -0
- anystruct/optimize_window.py +1117 -0
- anystruct/pl_stf_window.py +572 -0
- anystruct/report_generator.py +912 -0
- anystruct/sections.csv +202 -0
- anystruct/sesam_interface.py +115 -0
- anystruct/ship_section_example.txt +1 -0
- anystruct/stresses_window.py +269 -0
- anystruct/testCalc.py +118 -0
- anystructure-5.2.0.dist-info/METADATA +86 -0
- anystructure-5.2.0.dist-info/RECORD +99 -0
- anystructure-5.2.0.dist-info/WHEEL +5 -0
- anystructure-5.2.0.dist-info/entry_points.txt +2 -0
- anystructure-5.2.0.dist-info/licenses/LICENSE +21 -0
- anystructure-5.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1507 @@
|
|
|
1
|
+
# This is where the optimization is done.
|
|
2
|
+
import tkinter as tk
|
|
3
|
+
from _tkinter import TclError
|
|
4
|
+
from tkinter.ttk import Progressbar
|
|
5
|
+
from tkinter import messagebox
|
|
6
|
+
from tkinter.filedialog import askopenfilenames
|
|
7
|
+
from multiprocessing import Pool, cpu_count
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import anystruct.main_application
|
|
11
|
+
import anystruct.optimize as op
|
|
12
|
+
import anystruct.example_data as test
|
|
13
|
+
from anystruct.calc_structure import *
|
|
14
|
+
import anystruct.calc_structure as calc
|
|
15
|
+
from anystruct.helper import *
|
|
16
|
+
import anystruct.optimize as opt
|
|
17
|
+
except ModuleNotFoundError:
|
|
18
|
+
import ANYstructure.anystruct.main_application
|
|
19
|
+
import ANYstructure.anystruct.optimize as op
|
|
20
|
+
import ANYstructure.anystruct.example_data as test
|
|
21
|
+
from ANYstructure.anystruct.calc_structure import *
|
|
22
|
+
import ANYstructure.anystruct.calc_structure as calc
|
|
23
|
+
from ANYstructure.anystruct.helper import *
|
|
24
|
+
import ANYstructure.anystruct.optimize as opt
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def helper_harmonizer_multi(iterator):
|
|
28
|
+
'''
|
|
29
|
+
:param :
|
|
30
|
+
:return:
|
|
31
|
+
'''
|
|
32
|
+
|
|
33
|
+
this_check, master_x = list(), None
|
|
34
|
+
for slave_line in iterator['info']['lines']:
|
|
35
|
+
lateral_press = iterator['info'][slave_line]['lateral pressure']
|
|
36
|
+
fat_press = iterator['info'][slave_line]['fatigue pressure']
|
|
37
|
+
fat_obj = iterator['info'][slave_line]['fatigue object']
|
|
38
|
+
slamming_pressure = iterator['info'][slave_line]['slamming pressure']
|
|
39
|
+
chk_calc_obj = iterator['info'][slave_line]['chk_calc_obj']
|
|
40
|
+
master_x = list(iterator['x'])
|
|
41
|
+
ml_cl = iterator['info'][slave_line]['ML-CL']
|
|
42
|
+
fup = iterator['info'][slave_line]['fup']
|
|
43
|
+
fdwn = iterator['info'][slave_line]['fdwn']
|
|
44
|
+
if iterator['info']['keep spacing']:
|
|
45
|
+
x = [chk_calc_obj.get_s()] + master_x[1:] + [chk_calc_obj.span, chk_calc_obj.girder_lg]
|
|
46
|
+
else:
|
|
47
|
+
x = master_x + [chk_calc_obj.span, chk_calc_obj.girder_lg]
|
|
48
|
+
|
|
49
|
+
chk_any = op.any_constraints_all(x=x, obj=chk_calc_obj, lat_press=lateral_press,
|
|
50
|
+
init_weight=float('inf'), side='p', chk=iterator['info']['checks'],
|
|
51
|
+
fat_dict=None if fat_obj == None else fat_obj.get_fatigue_properties(),
|
|
52
|
+
fat_press=fat_press, slamming_press=slamming_pressure,PULSrun=None,
|
|
53
|
+
print_result=False,fdwn=fdwn, fup=fup, ml_results=ml_cl)
|
|
54
|
+
this_check.append(chk_any[0])
|
|
55
|
+
|
|
56
|
+
if all(this_check) and master_x is not None:
|
|
57
|
+
return tuple(master_x)
|
|
58
|
+
else:
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
class CreateOptimizeMultipleWindow():
|
|
62
|
+
'''
|
|
63
|
+
This class initiates the MultiOpt window.
|
|
64
|
+
'''
|
|
65
|
+
def __init__(self, master, app=None):
|
|
66
|
+
super(CreateOptimizeMultipleWindow, self).__init__()
|
|
67
|
+
if __name__ == '__main__':
|
|
68
|
+
import pickle
|
|
69
|
+
self._load_objects = {}
|
|
70
|
+
self._load_comb_dict = {}
|
|
71
|
+
self._line_dict = test.get_line_dict()
|
|
72
|
+
self._load_count = 0
|
|
73
|
+
self._point_dict = test.get_point_dict()
|
|
74
|
+
self._canvas_scale = 25
|
|
75
|
+
self._line_to_struc = test.get_line_to_struc()
|
|
76
|
+
self._slamming_pressure = test.get_slamming_pressure()
|
|
77
|
+
self._fatigue_pressure = test.get_fatigue_pressures()
|
|
78
|
+
self._fatigue_object = test.get_fatigue_object()
|
|
79
|
+
self._normal_pressure = test.get_random_pressure()
|
|
80
|
+
image_dir = os.path.dirname(__file__)+'\\images\\'
|
|
81
|
+
self._active_lines = []
|
|
82
|
+
self._ML_buckling = dict() # Buckling machine learning algorithm
|
|
83
|
+
for name, file_base in zip(['cl SP buc int predictor', 'cl SP buc int scaler',
|
|
84
|
+
'cl SP ult int predictor', 'cl SP ult int scaler',
|
|
85
|
+
'cl SP buc GLGT predictor', 'cl SP buc GLGT scaler',
|
|
86
|
+
'cl SP ult GLGT predictor', 'cl SP ult GLGT scaler',
|
|
87
|
+
'cl UP buc int predictor', 'cl UP buc int scaler',
|
|
88
|
+
'cl UP ult int predictor', 'cl UP ult int scaler',
|
|
89
|
+
'cl UP buc GLGT predictor', 'cl UP buc GLGT scaler',
|
|
90
|
+
'cl UP ult GLGT predictor', 'cl UP ult GLGT scaler'
|
|
91
|
+
],
|
|
92
|
+
["ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_SP",
|
|
93
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_SP",
|
|
94
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_SP",
|
|
95
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_SP",
|
|
96
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_SP",
|
|
97
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_SP",
|
|
98
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_SP",
|
|
99
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_SP",
|
|
100
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_1_UP",
|
|
101
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_1_UP",
|
|
102
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_1_UP",
|
|
103
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_1_UP",
|
|
104
|
+
"ml_files\\CL_output_cl_buc_predictor_In-plane_support_cl_2,_3_UP",
|
|
105
|
+
"ml_files\\CL_output_cl_buc_scaler_In-plane_support_cl_2,_3_UP",
|
|
106
|
+
"ml_files\\CL_output_cl_ult_predictor_In-plane_support_cl_2,_3_UP",
|
|
107
|
+
"ml_files\\CL_output_cl_ult_scaler_In-plane_support_cl_2,_3_UP",
|
|
108
|
+
"CL_CSR-Tank_req_cl_predictor",
|
|
109
|
+
"CL_CSR-Tank_req_cl_UP_scaler",
|
|
110
|
+
"CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_predictor",
|
|
111
|
+
"CL_CSR_plate_cl,_CSR_web_cl,_CSR_web_flange_cl,_CSR_flange_cl_SP_scaler"]):
|
|
112
|
+
self._ML_buckling[name] = None
|
|
113
|
+
if os.path.isfile(file_base + '.pickle'):
|
|
114
|
+
file = open(file_base + '.pickle', 'rb')
|
|
115
|
+
from sklearn.neural_network import MLPClassifier
|
|
116
|
+
from sklearn.preprocessing import StandardScaler
|
|
117
|
+
self._ML_buckling[name] = pickle.load(file)
|
|
118
|
+
file.close()
|
|
119
|
+
else:
|
|
120
|
+
self.app = app
|
|
121
|
+
self._load_objects = app._load_dict
|
|
122
|
+
self._load_comb_dict = app._new_load_comb_dict
|
|
123
|
+
self._line_dict = app._line_dict
|
|
124
|
+
self._load_count = 0
|
|
125
|
+
self._point_dict = app._point_dict
|
|
126
|
+
self._canvas_scale = app._canvas_scale
|
|
127
|
+
self._line_to_struc = app._line_to_struc
|
|
128
|
+
image_dir = app._root_dir + '\\images\\'
|
|
129
|
+
self._root_dir = app._root_dir
|
|
130
|
+
self._active_lines = app._multiselect_lines
|
|
131
|
+
self._ML_buckling = app._ML_buckling
|
|
132
|
+
|
|
133
|
+
self._frame = master
|
|
134
|
+
self._frame.wm_title("Optimize structure")
|
|
135
|
+
self._frame.geometry('1800x950')
|
|
136
|
+
self._frame.grab_set()
|
|
137
|
+
self._canvas_origo = (50, 720 - 50)
|
|
138
|
+
|
|
139
|
+
self._canvas_base_origo = self._canvas_origo
|
|
140
|
+
self._canvas_draw_origo = list(self._canvas_base_origo)
|
|
141
|
+
self._previous_drag_mouse = list(self._canvas_draw_origo)
|
|
142
|
+
|
|
143
|
+
self._active_lines = []
|
|
144
|
+
self._add_to_lines = True
|
|
145
|
+
self._lines_add_to_load = []
|
|
146
|
+
self._mid_click_line = None
|
|
147
|
+
|
|
148
|
+
self._predefined_structure = None
|
|
149
|
+
|
|
150
|
+
# ----------------------------------COPIED FROM OPTIMIZE_WINDOW-----------------------------------------------
|
|
151
|
+
|
|
152
|
+
self._opt_results = {}
|
|
153
|
+
self._opt_actual_running_time = tk.Label(self._frame, text='')
|
|
154
|
+
|
|
155
|
+
tk.Frame(self._frame, width=770, height=5, bg="grey", colormap="new").place(x=20, y=95)
|
|
156
|
+
tk.Frame(self._frame, width=770, height=5, bg="grey", colormap="new").place(x=20, y=135)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
algorithms = ('anysmart', 'random', 'random_no_delta')
|
|
160
|
+
|
|
161
|
+
tk.Label(self._frame, text='-- Structural optimizer for multiple selections --',
|
|
162
|
+
font='Verdana 15 bold').place(x=10, y=10)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
# upper and lower bounds for optimization
|
|
166
|
+
# [0.6, 0.012, 0.3, 0.01, 0.1, 0.01]
|
|
167
|
+
self._new_spacing_upper = tk.DoubleVar()
|
|
168
|
+
self._new_spacing_lower = tk.DoubleVar()
|
|
169
|
+
self._new_pl_thk_upper = tk.DoubleVar()
|
|
170
|
+
self._new_pl_thk_lower = tk.DoubleVar()
|
|
171
|
+
self._new_web_h_upper = tk.DoubleVar()
|
|
172
|
+
self._new_web_h_lower = tk.DoubleVar()
|
|
173
|
+
self._new_web_thk_upper = tk.DoubleVar()
|
|
174
|
+
self._new_web_thk_lower = tk.DoubleVar()
|
|
175
|
+
self._new_fl_w_upper = tk.DoubleVar()
|
|
176
|
+
self._new_fl_w_lower = tk.DoubleVar()
|
|
177
|
+
self._new_fl_thk_upper = tk.DoubleVar()
|
|
178
|
+
self._new_fl_thk_lower = tk.DoubleVar()
|
|
179
|
+
self._new_span = tk.DoubleVar()
|
|
180
|
+
self._new_width_lg = tk.DoubleVar()
|
|
181
|
+
self._new_algorithm = tk.StringVar()
|
|
182
|
+
self._new_algorithm_random_trials = tk.IntVar()
|
|
183
|
+
self._new_delta_spacing = tk.DoubleVar()
|
|
184
|
+
self._new_delta_pl_thk = tk.DoubleVar()
|
|
185
|
+
self._new_delta_web_h = tk.DoubleVar()
|
|
186
|
+
self._new_delta_web_thk = tk.DoubleVar()
|
|
187
|
+
self._new_delta_fl_w = tk.DoubleVar()
|
|
188
|
+
self._new_delta_fl_thk = tk.DoubleVar()
|
|
189
|
+
self._new_swarm_size = tk.IntVar()
|
|
190
|
+
self._new_omega = tk.DoubleVar()
|
|
191
|
+
self._new_phip = tk.DoubleVar()
|
|
192
|
+
self._new_phig = tk.DoubleVar()
|
|
193
|
+
self._new_maxiter = tk.IntVar()
|
|
194
|
+
self._new_minstep = tk.DoubleVar()
|
|
195
|
+
self._new_minfunc = tk.DoubleVar()
|
|
196
|
+
|
|
197
|
+
ent_w = 10
|
|
198
|
+
self._ent_spacing_upper = tk.Entry(self._frame, textvariable=self._new_spacing_upper, width=ent_w)
|
|
199
|
+
self._ent_spacing_lower = tk.Entry(self._frame, textvariable=self._new_spacing_lower, width=ent_w)
|
|
200
|
+
self._ent_pl_thk_upper = tk.Entry(self._frame, textvariable=self._new_pl_thk_upper, width=ent_w)
|
|
201
|
+
self._ent_pl_thk_lower = tk.Entry(self._frame, textvariable=self._new_pl_thk_lower, width=ent_w)
|
|
202
|
+
self._ent_web_h_upper = tk.Entry(self._frame, textvariable=self._new_web_h_upper, width=ent_w)
|
|
203
|
+
self._ent_web_h_lower = tk.Entry(self._frame, textvariable=self._new_web_h_lower, width=ent_w)
|
|
204
|
+
self._ent_web_thk_upper = tk.Entry(self._frame, textvariable=self._new_web_thk_upper, width=ent_w)
|
|
205
|
+
self._ent_web_thk_lower = tk.Entry(self._frame, textvariable=self._new_web_thk_lower, width=ent_w)
|
|
206
|
+
self._ent_fl_w_upper = tk.Entry(self._frame, textvariable=self._new_fl_w_upper, width=ent_w)
|
|
207
|
+
self._ent_fl_w_lower = tk.Entry(self._frame, textvariable=self._new_fl_w_lower, width=ent_w)
|
|
208
|
+
self._ent_fl_thk_upper = tk.Entry(self._frame, textvariable=self._new_fl_thk_upper, width=ent_w)
|
|
209
|
+
self._ent_fl_thk_lower = tk.Entry(self._frame, textvariable=self._new_fl_thk_lower, width=ent_w)
|
|
210
|
+
self._ent_span = tk.Entry(self._frame, textvariable=self._new_span, width=ent_w)
|
|
211
|
+
self._ent_width_lg = tk.Entry(self._frame, textvariable=self._new_width_lg, width=ent_w)
|
|
212
|
+
self._ent_algorithm = tk.OptionMenu(self._frame, self._new_algorithm, command=self.selected_algorithm, *algorithms)
|
|
213
|
+
self._ent_random_trials = tk.Entry(self._frame, textvariable=self._new_algorithm_random_trials)
|
|
214
|
+
self._ent_delta_spacing = tk.Entry(self._frame, textvariable=self._new_delta_spacing, width=ent_w)
|
|
215
|
+
self._ent_delta_pl_thk = tk.Entry(self._frame, textvariable=self._new_delta_pl_thk, width=ent_w)
|
|
216
|
+
self._ent_delta_web_h = tk.Entry(self._frame, textvariable=self._new_delta_web_h, width=ent_w)
|
|
217
|
+
self._ent_delta_web_thk = tk.Entry(self._frame, textvariable=self._new_delta_web_thk, width=ent_w)
|
|
218
|
+
self._ent_delta_fl_w = tk.Entry(self._frame, textvariable=self._new_delta_fl_w, width=ent_w)
|
|
219
|
+
self._ent_delta_fl_thk = tk.Entry(self._frame, textvariable=self._new_delta_fl_thk, width=ent_w)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
pso_width = 10
|
|
223
|
+
self._ent_swarm_size = tk.Entry(self._frame,textvariable=self._new_swarm_size, width = pso_width)
|
|
224
|
+
self._ent_omega = tk.Entry(self._frame,textvariable=self._new_omega, width = pso_width)
|
|
225
|
+
self._ent_phip = tk.Entry(self._frame,textvariable=self._new_phip, width = pso_width)
|
|
226
|
+
self._ent_phig = tk.Entry(self._frame,textvariable=self._new_phig, width = pso_width)
|
|
227
|
+
self._ent_maxiter = tk.Entry(self._frame,textvariable=self._new_maxiter, width = pso_width)
|
|
228
|
+
self._ent_minstep = tk.Entry(self._frame,textvariable=self._new_minstep, width = pso_width)
|
|
229
|
+
self._ent_minfunc = tk.Entry(self._frame,textvariable=self._new_minfunc, width = pso_width)
|
|
230
|
+
|
|
231
|
+
start_x, start_y, dx, dy = 20, 70, 100, 40
|
|
232
|
+
|
|
233
|
+
self._new_processes = tk.IntVar()
|
|
234
|
+
self._new_processes.set(max(cpu_count() - 1, 1))
|
|
235
|
+
tk.Label(self._frame, text='Processes\n (CPUs)', font='Verdana 9 bold', bg = 'silver')\
|
|
236
|
+
.place(x=start_x + 12.3 * dx, y=start_y - 0.2 * dy)
|
|
237
|
+
tk.Entry(self._frame, textvariable=self._new_processes, width = 12, bg = 'silver')\
|
|
238
|
+
.place(x=start_x + 12.3 * dx, y=start_y + 0.7* dy)
|
|
239
|
+
|
|
240
|
+
self._prop_canvas_dim = (500, 450)
|
|
241
|
+
self._draw_scale = 500
|
|
242
|
+
self._canvas_opt = tk.Canvas(self._frame, width=self._prop_canvas_dim[0], height=self._prop_canvas_dim[1],
|
|
243
|
+
background='azure',relief='groove', borderwidth=2)
|
|
244
|
+
self._canvas_opt.place(x=start_x+10.5*dx, y=start_y+3.5*dy)
|
|
245
|
+
self._select_canvas_dim = (1000, 720)
|
|
246
|
+
self._canvas_select = tk.Canvas(self._frame, width=self._select_canvas_dim[0], height=self._select_canvas_dim[1],
|
|
247
|
+
background='azure',relief='groove', borderwidth=2)
|
|
248
|
+
self._canvas_select.place(x=start_x+0*dx, y=start_y+3.5*dy)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
# Labels for the pso
|
|
253
|
+
self._lb_swarm_size = tk.Label(self._frame, text='swarm size')
|
|
254
|
+
self._lb_omega = tk.Label(self._frame, text='omega')
|
|
255
|
+
self._lb_phip = tk.Label(self._frame, text='phip')
|
|
256
|
+
self._lb_phig = tk.Label(self._frame, text='phig')
|
|
257
|
+
self._lb_maxiter = tk.Label(self._frame, text='maxiter')
|
|
258
|
+
self._lb_minstep = tk.Label(self._frame, text='minstep')
|
|
259
|
+
self._lb_minfunc = tk.Label(self._frame, text='minfunc')
|
|
260
|
+
|
|
261
|
+
tk.Label(self._frame, text='Upper bounds [mm]', font='Verdana 9').place(x=start_x, y=start_y)
|
|
262
|
+
tk.Label(self._frame, text='Iteration delta [mm]', font='Verdana 9').place(x=start_x, y=start_y + dy)
|
|
263
|
+
tk.Label(self._frame, text='Lower bounds [mm]', font='Verdana 9').place(x=start_x, y=start_y + 2 * dy)
|
|
264
|
+
tk.Label(self._frame, text='Spacing [mm]', font='Verdana 7 bold').place(x=start_x + 1.97 * dx,
|
|
265
|
+
y=start_y - 0.6 * dy)
|
|
266
|
+
tk.Label(self._frame, text='Plate thk. [mm]', font='Verdana 7 bold').place(x=start_x + 2.97 * dx,
|
|
267
|
+
y=start_y - 0.6 * dy)
|
|
268
|
+
tk.Label(self._frame, text='Web height [mm]', font='Verdana 7 bold').place(x=start_x + 3.97 * dx,
|
|
269
|
+
y=start_y - 0.6 * dy)
|
|
270
|
+
tk.Label(self._frame, text='Web thk. [mm]', font='Verdana 7 bold').place(x=start_x + 4.97 * dx,
|
|
271
|
+
y=start_y - 0.6 * dy)
|
|
272
|
+
tk.Label(self._frame, text='Flange width [mm]', font='Verdana 7 bold').place(x=start_x + 5.97 * dx,
|
|
273
|
+
y=start_y - 0.6 * dy)
|
|
274
|
+
tk.Label(self._frame, text='Flange thk. [mm]', font='Verdana 7 bold').place(x=start_x + 6.97 * dx,
|
|
275
|
+
y=start_y - 0.6 * dy)
|
|
276
|
+
tk.Label(self._frame, text='Estimated running time for algorithm: ',
|
|
277
|
+
font='Verdana 9 bold').place(x=start_x, y=start_y + 2.8 * dy)
|
|
278
|
+
self._runnig_time_label = tk.Label(self._frame, text='', font='Verdana 9 bold')
|
|
279
|
+
self._runnig_time_label.place(x=start_x + 2.7 * dx, y=start_y + 2.8 * dy)
|
|
280
|
+
tk.Label(self._frame, text='seconds ', font='Verdana 9 bold').place(x=start_x + 3.3 * dx, y=start_y + 2.8 * dy)
|
|
281
|
+
self._result_label = tk.Label(self._frame, text='', font='Verdana 9 bold')
|
|
282
|
+
self._result_label.place(x=start_x, y=start_y + 4 * dy)
|
|
283
|
+
|
|
284
|
+
self._ent_spacing_upper.place(x=start_x + dx * 2, y=start_y)
|
|
285
|
+
self._ent_delta_spacing.place(x=start_x + dx * 2, y=start_y + dy)
|
|
286
|
+
self._ent_spacing_lower.place(x=start_x + dx * 2, y=start_y + 2 * dy)
|
|
287
|
+
self._ent_pl_thk_upper.place(x=start_x + dx * 3, y=start_y)
|
|
288
|
+
self._ent_delta_pl_thk.place(x=start_x + dx * 3, y=start_y + dy)
|
|
289
|
+
self._ent_pl_thk_lower.place(x=start_x + dx * 3, y=start_y + 2 * dy)
|
|
290
|
+
self._ent_web_h_upper.place(x=start_x + dx * 4, y=start_y)
|
|
291
|
+
self._ent_delta_web_h.place(x=start_x + dx * 4, y=start_y + dy)
|
|
292
|
+
self._ent_web_h_lower.place(x=start_x + dx * 4, y=start_y + 2 * dy)
|
|
293
|
+
self._ent_web_thk_upper.place(x=start_x + dx * 5, y=start_y)
|
|
294
|
+
self._ent_delta_web_thk.place(x=start_x + dx * 5, y=start_y + dy)
|
|
295
|
+
self._ent_web_thk_lower.place(x=start_x + dx * 5, y=start_y + 2 * dy)
|
|
296
|
+
self._ent_fl_w_upper.place(x=start_x + dx * 6, y=start_y)
|
|
297
|
+
self._ent_delta_fl_w.place(x=start_x + dx * 6, y=start_y + dy)
|
|
298
|
+
self._ent_fl_w_lower.place(x=start_x + dx * 6, y=start_y + 2 * dy)
|
|
299
|
+
self._ent_fl_thk_upper.place(x=start_x + dx * 7, y=start_y)
|
|
300
|
+
self._ent_delta_fl_thk.place(x=start_x + dx * 7, y=start_y + dy)
|
|
301
|
+
self._ent_fl_thk_lower.place(x=start_x + dx * 7, y=start_y + 2 * dy)
|
|
302
|
+
|
|
303
|
+
# setting default values
|
|
304
|
+
init_dim = float(10) # mm
|
|
305
|
+
init_thk = float(1) # mm
|
|
306
|
+
self._new_delta_spacing.set(init_dim)
|
|
307
|
+
self._new_delta_pl_thk.set(init_thk)
|
|
308
|
+
self._new_delta_web_h.set(init_dim)
|
|
309
|
+
self._new_delta_web_thk.set(init_thk)
|
|
310
|
+
self._new_delta_fl_w.set(init_dim)
|
|
311
|
+
self._new_delta_fl_thk.set(init_thk)
|
|
312
|
+
self._new_spacing_upper.set(round(800, 5))
|
|
313
|
+
self._new_spacing_lower.set(round(600, 5))
|
|
314
|
+
self._new_pl_thk_upper.set(round(25, 5))
|
|
315
|
+
self._new_pl_thk_lower.set(round(15, 5))
|
|
316
|
+
self._new_web_h_upper.set(round(500, 5))
|
|
317
|
+
self._new_web_h_lower.set(round(400, 5))
|
|
318
|
+
self._new_web_thk_upper.set(round(20, 5))
|
|
319
|
+
self._new_web_thk_lower.set(round(10, 5))
|
|
320
|
+
self._new_fl_w_upper.set(round(200, 5))
|
|
321
|
+
self._new_fl_w_lower.set(round(100, 5))
|
|
322
|
+
self._new_fl_thk_upper.set(round(30, 5))
|
|
323
|
+
self._new_fl_thk_lower.set(round(15, 5))
|
|
324
|
+
self._new_algorithm.set('anysmart')
|
|
325
|
+
self._new_algorithm_random_trials.set(10000)
|
|
326
|
+
# Selection of constraints
|
|
327
|
+
self._new_check_sec_mod = tk.BooleanVar()
|
|
328
|
+
self._new_check_min_pl_thk = tk.BooleanVar()
|
|
329
|
+
self._new_check_shear_area = tk.BooleanVar()
|
|
330
|
+
self._new_check_buckling = tk.BooleanVar()
|
|
331
|
+
self._new_check_fatigue = tk.BooleanVar()
|
|
332
|
+
self._new_check_slamming = tk.BooleanVar()
|
|
333
|
+
self._new_check_local_buckling = tk.BooleanVar()
|
|
334
|
+
self._new_check_ml_buckling = tk.BooleanVar()
|
|
335
|
+
self._new_harmonizer = tk.BooleanVar()
|
|
336
|
+
self._keep_spacing = tk.BooleanVar()
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
self._new_check_sec_mod.set(True)
|
|
340
|
+
self._new_check_min_pl_thk.set(True)
|
|
341
|
+
self._new_check_shear_area.set(True)
|
|
342
|
+
self._new_check_buckling.set(True)
|
|
343
|
+
self._new_check_fatigue.set(True)
|
|
344
|
+
self._new_check_slamming.set(False)
|
|
345
|
+
self._new_check_local_buckling.set(True)
|
|
346
|
+
self._new_harmonizer.set(False)
|
|
347
|
+
self._keep_spacing.set(False)
|
|
348
|
+
self._new_check_ml_buckling.set(False)
|
|
349
|
+
|
|
350
|
+
self._new_swarm_size.set(100)
|
|
351
|
+
self._new_omega.set(0.5)
|
|
352
|
+
self._new_phip.set(0.5)
|
|
353
|
+
self._new_phig.set(0.5)
|
|
354
|
+
self._new_maxiter.set(100)
|
|
355
|
+
self._new_minstep.set(1e-8)
|
|
356
|
+
self._new_minfunc.set(1e-8)
|
|
357
|
+
|
|
358
|
+
self._new_delta_spacing.trace('w', self.update_running_time)
|
|
359
|
+
self._new_delta_pl_thk.trace('w', self.update_running_time)
|
|
360
|
+
self._new_delta_web_h.trace('w', self.update_running_time)
|
|
361
|
+
self._new_delta_web_thk.trace('w', self.update_running_time)
|
|
362
|
+
self._new_delta_fl_w.trace('w', self.update_running_time)
|
|
363
|
+
self._new_delta_fl_thk.trace('w', self.update_running_time)
|
|
364
|
+
self._new_spacing_upper.trace('w', self.update_running_time)
|
|
365
|
+
self._new_spacing_lower.trace('w', self.update_running_time)
|
|
366
|
+
self._new_pl_thk_upper.trace('w', self.update_running_time)
|
|
367
|
+
self._new_pl_thk_lower.trace('w', self.update_running_time)
|
|
368
|
+
self._new_web_h_upper.trace('w', self.update_running_time)
|
|
369
|
+
self._new_web_h_lower.trace('w', self.update_running_time)
|
|
370
|
+
self._new_web_thk_upper.trace('w', self.update_running_time)
|
|
371
|
+
self._new_web_thk_lower.trace('w', self.update_running_time)
|
|
372
|
+
self._new_fl_w_upper.trace('w', self.update_running_time)
|
|
373
|
+
self._new_fl_w_lower.trace('w', self.update_running_time)
|
|
374
|
+
self._new_fl_thk_upper.trace('w', self.update_running_time)
|
|
375
|
+
self._new_fl_thk_lower.trace('w', self.update_running_time)
|
|
376
|
+
self._new_algorithm_random_trials.trace('w', self.update_running_time)
|
|
377
|
+
self._new_algorithm.trace('w', self.update_running_time)
|
|
378
|
+
self._keep_spacing.trace('w',self.trace_keep_spacing_check)
|
|
379
|
+
self._new_check_ml_buckling.trace('w', self.update_running_time)
|
|
380
|
+
|
|
381
|
+
self.running_time_per_item = 1.009943181818182e-5
|
|
382
|
+
self._runnig_time_label.config(text=str(self.get_running_time()))
|
|
383
|
+
tk.Label(self._frame, text='Select algorithm type --->', font='Verdana 8 bold').place(x=start_x + dx * 8,
|
|
384
|
+
y=start_y + 1 * dy)
|
|
385
|
+
self._ent_algorithm.place(x=start_x + dx * 10, y=start_y + dy)
|
|
386
|
+
self.algorithm_random_label = tk.Label(self._frame, text='Number of trials')
|
|
387
|
+
tk.Button(self._frame, text='algorithm information', command=self.algorithm_info, bg='white') \
|
|
388
|
+
.place(x=start_x + dx * 15, y=start_y + dy *-0.5)
|
|
389
|
+
self.run_button = tk.Button(self._frame, text='RUN OPTIMIZATION!', command=self.run_optimizaion, bg='red',
|
|
390
|
+
font='Verdana 10', fg='Yellow')
|
|
391
|
+
self.run_button.place(x=start_x + dx * 8, y=start_y)
|
|
392
|
+
self.run_results = tk.Button(self._frame,text='show calculated', command=self.plot_results, bg='white',
|
|
393
|
+
font='Verdana 10',fg='black')
|
|
394
|
+
self.run_results.place(x=start_x+dx*8, y=start_y+dy*1.5)
|
|
395
|
+
self._opt_actual_running_time.place(x=start_x + dx * 8, y=start_y - dy * 1.5)
|
|
396
|
+
self.close_and_save = tk.Button(self._frame, text='Return and replace with selected optimized structure',
|
|
397
|
+
command=self.save_and_close, bg='green', font='Verdana 10 bold', fg='yellow')
|
|
398
|
+
self.close_and_save.place(x=start_x + dx * 10, y=10)
|
|
399
|
+
|
|
400
|
+
tk.Button(self._frame, text='Open predefined stiffeners example',
|
|
401
|
+
command=self.open_example_file, bg='white', font='Verdana 10')\
|
|
402
|
+
.place(x=start_x+dx*15,y=10)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
start_y, start_x, dy = 530, 100, 35
|
|
409
|
+
tk.Label(self._frame,text='Check for minimum section modulus').place(x=start_x+dx*9.7,y=start_y+4*dy)
|
|
410
|
+
tk.Label(self._frame, text='Check for minimum plate thk.').place(x=start_x+dx*9.7,y=start_y+5*dy)
|
|
411
|
+
tk.Label(self._frame, text='Check for minimum shear area').place(x=start_x+dx*9.7,y=start_y+6*dy)
|
|
412
|
+
tk.Label(self._frame, text='Check for buckling (RP-C201)').place(x=start_x+dx*9.7,y=start_y+7*dy)
|
|
413
|
+
tk.Label(self._frame, text='Check for fatigue (RP-C203)').place(x=start_x + dx * 9.7, y=start_y + 8 * dy)
|
|
414
|
+
tk.Label(self._frame, text='Check for bow slamming').place(x=start_x + dx * 9.7, y=start_y + 9 * dy)
|
|
415
|
+
tk.Label(self._frame, text='Check for local stf. buckling').place(x=start_x + dx * 9.7, y=start_y + 10 * dy)
|
|
416
|
+
tk.Label(self._frame, text='Check for buckling (ML-CL)').place(x=start_x + dx * 9.7, y=start_y + 11 * dy)
|
|
417
|
+
tk.Label(self._frame, text='Check to harmonize results. Same stiffener and plate dimensions '
|
|
418
|
+
'(defined by largest in opt).', font='Verdana 10 bold')\
|
|
419
|
+
.place(x=start_x + dx * +8.5, y=start_y - 10.5 * dy)
|
|
420
|
+
tk.Label(self._frame, text='Check to skip iterating over spacing (respective line spacing used).',
|
|
421
|
+
font='Verdana 10 bold')\
|
|
422
|
+
.place(x=start_x + dx * +8.5, y=start_y - 9.8 * dy)
|
|
423
|
+
|
|
424
|
+
tk.Checkbutton(self._frame,variable=self._new_check_sec_mod).place(x=start_x+dx*12,y=start_y+4*dy)
|
|
425
|
+
tk.Checkbutton(self._frame, variable=self._new_check_min_pl_thk).place(x=start_x+dx*12,y=start_y+5*dy)
|
|
426
|
+
tk.Checkbutton(self._frame, variable=self._new_check_shear_area).place(x=start_x+dx*12,y=start_y+6*dy)
|
|
427
|
+
tk.Checkbutton(self._frame, variable=self._new_check_buckling).place(x=start_x+dx*12,y=start_y+7*dy)
|
|
428
|
+
tk.Checkbutton(self._frame, variable=self._new_check_fatigue).place(x=start_x + dx * 12, y=start_y + 8 * dy)
|
|
429
|
+
tk.Checkbutton(self._frame, variable=self._new_check_slamming).place(x=start_x + dx * 12, y=start_y + 9 * dy)
|
|
430
|
+
tk.Checkbutton(self._frame, variable=self._new_check_local_buckling).place(x=start_x + dx * 12,
|
|
431
|
+
y=start_y + 10 * dy)
|
|
432
|
+
tk.Checkbutton(self._frame, variable=self._new_check_ml_buckling).place(x=start_x + dx * 12,
|
|
433
|
+
y=start_y + 11 * dy)
|
|
434
|
+
tk.Checkbutton(self._frame, variable=self._new_harmonizer).place(x=start_x + dx * 8, y=start_y - 10.5 * dy)
|
|
435
|
+
tk.Checkbutton(self._frame, variable=self._keep_spacing).place(x=start_x + dx * +8, y=start_y - 9.8 * dy)
|
|
436
|
+
|
|
437
|
+
self._toggle_btn = tk.Button(self._frame, text="Iterate predefiened stiffeners", relief="raised",
|
|
438
|
+
command=self.toggle, bg = 'salmon')
|
|
439
|
+
|
|
440
|
+
self._toggle_btn.place(x=start_x+dx*9, y=start_y - dy * 13)
|
|
441
|
+
self._toggle_object, self._filez = None, None
|
|
442
|
+
|
|
443
|
+
# Stress scaling
|
|
444
|
+
self._new_fup = tk.DoubleVar()
|
|
445
|
+
self._new_fup.set(0.5)
|
|
446
|
+
self._new_fdwn = tk.DoubleVar()
|
|
447
|
+
self._new_fdwn.set(1)
|
|
448
|
+
|
|
449
|
+
tk.Label(self._frame, text='Factor when scaling stresses up, fup')\
|
|
450
|
+
.place(x=start_x + dx * 13, y=start_y + 5 * dy)
|
|
451
|
+
ent_fup = tk.Entry(self._frame, textvariable=self._new_fup, width = 10)
|
|
452
|
+
ent_fup.place(x=start_x + dx * 15.5, y=start_y + 5 * dy)
|
|
453
|
+
tk.Label(self._frame, text='Factor when scaling stresses up, fdown')\
|
|
454
|
+
.place(x=start_x + dx * 13, y=start_y + 6 * dy)
|
|
455
|
+
ent_fdwn = tk.Entry(self._frame, textvariable=self._new_fdwn, width = 10)
|
|
456
|
+
ent_fdwn.place(x=start_x + dx * 15.5, y=start_y + 6 * dy)
|
|
457
|
+
|
|
458
|
+
self.draw_properties()
|
|
459
|
+
|
|
460
|
+
# ----------------------------------END OF OPTIMIZE SINGLE COPY-----------------------------------------------
|
|
461
|
+
self.progress_count = tk.IntVar()
|
|
462
|
+
self.progress_count.set(0)
|
|
463
|
+
self.progress_bar = Progressbar(self._frame, orient="horizontal",length=200, mode="determinate",
|
|
464
|
+
variable=self.progress_count)
|
|
465
|
+
self.progress_bar.place(x=start_x+dx*10.5,y=start_y-dy*11.5)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
self.controls()
|
|
469
|
+
self.draw_select_canvas()
|
|
470
|
+
self._harmonizer_data = {}
|
|
471
|
+
|
|
472
|
+
def trace_keep_spacing_check(self, *args):
|
|
473
|
+
if self._keep_spacing.get():
|
|
474
|
+
self._ent_spacing_lower.configure({"background": "red"})
|
|
475
|
+
self._ent_delta_spacing.configure({"background": "red"})
|
|
476
|
+
self._ent_spacing_upper.configure({"background": "red"})
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def selected_algorithm(self, event):
|
|
480
|
+
'''
|
|
481
|
+
Action when selecting an algorithm in the optionm menu.
|
|
482
|
+
:return:
|
|
483
|
+
'''
|
|
484
|
+
start_x, start_y, dx, dy = 20, 100, 100, 40
|
|
485
|
+
if self._new_algorithm.get() == 'random' or self._new_algorithm.get() == 'random_no_delta':
|
|
486
|
+
self._ent_random_trials.place_forget()
|
|
487
|
+
self.algorithm_random_label.place_forget()
|
|
488
|
+
self._lb_swarm_size.place_forget()
|
|
489
|
+
self._lb_omega.place_forget()
|
|
490
|
+
self._lb_phip.place_forget()
|
|
491
|
+
self._lb_phig.place_forget()
|
|
492
|
+
self._lb_maxiter.place_forget()
|
|
493
|
+
self._lb_minstep.place_forget()
|
|
494
|
+
self._lb_minfunc.place_forget()
|
|
495
|
+
self._ent_swarm_size.place_forget()
|
|
496
|
+
self._ent_omega.place_forget()
|
|
497
|
+
self._ent_phip.place_forget()
|
|
498
|
+
self._ent_phig.place_forget()
|
|
499
|
+
self._ent_maxiter.place_forget()
|
|
500
|
+
self._ent_minstep.place_forget()
|
|
501
|
+
self._ent_minfunc.place_forget()
|
|
502
|
+
self._ent_random_trials.place(x=start_x + dx * 11.3, y=start_y + 1.2 * dy)
|
|
503
|
+
self.algorithm_random_label.place(x=start_x + dx * 11.3, y=start_y + 0.5 * dy)
|
|
504
|
+
|
|
505
|
+
elif self._new_algorithm.get() == 'anysmart' or self._new_algorithm.get() == 'anydetail':
|
|
506
|
+
self._ent_random_trials.place_forget()
|
|
507
|
+
self.algorithm_random_label.place_forget()
|
|
508
|
+
self._lb_swarm_size.place_forget()
|
|
509
|
+
self._lb_omega.place_forget()
|
|
510
|
+
self._lb_phip.place_forget()
|
|
511
|
+
self._lb_phig.place_forget()
|
|
512
|
+
self._lb_maxiter.place_forget()
|
|
513
|
+
self._lb_minstep.place_forget()
|
|
514
|
+
self._lb_minfunc.place_forget()
|
|
515
|
+
self._ent_swarm_size.place_forget()
|
|
516
|
+
self._ent_omega.place_forget()
|
|
517
|
+
self._ent_phip.place_forget()
|
|
518
|
+
self._ent_phig.place_forget()
|
|
519
|
+
self._ent_maxiter.place_forget()
|
|
520
|
+
self._ent_minstep.place_forget()
|
|
521
|
+
self._ent_minfunc.place_forget()
|
|
522
|
+
|
|
523
|
+
elif self._new_algorithm.get() == 'pso':
|
|
524
|
+
y_place_label = 11.2
|
|
525
|
+
y_place = 12.2
|
|
526
|
+
self._ent_random_trials.place_forget()
|
|
527
|
+
start_x = 150
|
|
528
|
+
|
|
529
|
+
self._lb_swarm_size.place(x=start_x + dx*11 , y=start_y - 1 * dy)
|
|
530
|
+
self._lb_omega.place(x=start_x + dx*11 , y=start_y - 0 * dy)
|
|
531
|
+
self._lb_phip.place(x=start_x + dx*11 , y=start_y + 1 * dy)
|
|
532
|
+
self._lb_phig.place(x=start_x + dx*11 , y=start_y + 2 * dy)
|
|
533
|
+
|
|
534
|
+
self._lb_maxiter.place(x=start_x + dx*14 , y=start_y - 1 * dy)
|
|
535
|
+
self._lb_minstep.place(x=start_x + dx*14, y=start_y + 0 * dy)
|
|
536
|
+
self._lb_minfunc.place(x=start_x + dx*14, y=start_y + 1 * dy)
|
|
537
|
+
|
|
538
|
+
self._ent_swarm_size.place(x=start_x + dx*12 , y=start_y - 1 * dy)
|
|
539
|
+
self._ent_omega.place(x=start_x + dx*12 , y=start_y - 0 * dy)
|
|
540
|
+
self._ent_phip.place(x=start_x + dx*12 , y=start_y + 1 * dy)
|
|
541
|
+
self._ent_phig.place(x=start_x + dx*12 , y=start_y + 2 * dy)
|
|
542
|
+
|
|
543
|
+
self._ent_maxiter.place(x=start_x + dx*15 , y=start_y - 1 * dy)
|
|
544
|
+
self._ent_minstep.place(x=start_x + dx*15, y=start_y + 0 * dy)
|
|
545
|
+
self._ent_minfunc.place(x=start_x + dx*15, y=start_y + 1 * dy)
|
|
546
|
+
|
|
547
|
+
def get_pressure_input(self, line):
|
|
548
|
+
if __name__ == '__main__':
|
|
549
|
+
lateral_press = self._normal_pressure
|
|
550
|
+
fat_press = self._fatigue_pressure
|
|
551
|
+
slamming_pressure = self._slamming_pressure
|
|
552
|
+
fat_obj = self._fatigue_object
|
|
553
|
+
else:
|
|
554
|
+
lateral_press = self.app.get_highest_pressure(line)['normal'] / 1e6
|
|
555
|
+
|
|
556
|
+
fat_obj = self.app._line_to_struc[line][2]
|
|
557
|
+
if fat_obj is not None:
|
|
558
|
+
try:
|
|
559
|
+
fat_press = self.app.get_fatigue_pressures(line, fat_obj.get_accelerations())
|
|
560
|
+
except AttributeError:
|
|
561
|
+
fat_press = None
|
|
562
|
+
else:
|
|
563
|
+
fat_press = {'p_ext': {'loaded': 0, 'ballast': 0, 'part': 0},
|
|
564
|
+
'p_int': {'loaded': 0, 'ballast': 0, 'part': 0}}
|
|
565
|
+
|
|
566
|
+
try:
|
|
567
|
+
if self.app.get_highest_pressure(line)['slamming'] is None:
|
|
568
|
+
slamming_pressure = 0
|
|
569
|
+
else:
|
|
570
|
+
slamming_pressure = self.app.get_highest_pressure(line)['slamming']
|
|
571
|
+
except [KeyError, AttributeError]:
|
|
572
|
+
slamming_pressure = 0
|
|
573
|
+
|
|
574
|
+
fat_press = ((fat_press['p_ext']['loaded'], fat_press['p_ext']['ballast'],
|
|
575
|
+
fat_press['p_ext']['part']),
|
|
576
|
+
(fat_press['p_int']['loaded'], fat_press['p_int']['ballast'],
|
|
577
|
+
fat_press['p_int']['part']))
|
|
578
|
+
return {'lateral pressure': lateral_press, 'fatigue pressure': fat_press,
|
|
579
|
+
'slamming pressure': slamming_pressure, 'fatigue object': fat_obj}
|
|
580
|
+
|
|
581
|
+
def run_optimizaion(self):
|
|
582
|
+
'''
|
|
583
|
+
Function when pressing the optimization botton inside this window.
|
|
584
|
+
:return:
|
|
585
|
+
'''
|
|
586
|
+
self.run_button.config(bg = 'white')
|
|
587
|
+
self._opt_results = {}
|
|
588
|
+
t_start = time.time()
|
|
589
|
+
|
|
590
|
+
self.progress_bar.config(maximum=len(self._active_lines))
|
|
591
|
+
self._opt_actual_running_time.config(text='')
|
|
592
|
+
|
|
593
|
+
contraints = (self._new_check_sec_mod.get(), self._new_check_min_pl_thk.get(),
|
|
594
|
+
self._new_check_shear_area.get(), self._new_check_buckling.get(),
|
|
595
|
+
self._new_check_fatigue.get(), self._new_check_slamming.get(),
|
|
596
|
+
self._new_check_local_buckling.get(), False, self._new_check_ml_buckling.get(), False)
|
|
597
|
+
|
|
598
|
+
self.pso_parameters = (self._new_swarm_size.get(),self._new_omega.get(),self._new_phip.get(),
|
|
599
|
+
self._new_phig.get(),self._new_maxiter.get(),self._new_minstep.get(),
|
|
600
|
+
self._new_minfunc.get())
|
|
601
|
+
|
|
602
|
+
max_min_span = None
|
|
603
|
+
|
|
604
|
+
self.progress_count.set(0)
|
|
605
|
+
counter = 0
|
|
606
|
+
found_files = self._filez
|
|
607
|
+
for line in self._active_lines:
|
|
608
|
+
init_obj = self._line_to_struc[line][0]
|
|
609
|
+
|
|
610
|
+
if __name__ == '__main__':
|
|
611
|
+
lateral_press = 200 #for testing
|
|
612
|
+
fat_obj = test.get_fatigue_object()
|
|
613
|
+
fat_press = test.get_fatigue_pressures()
|
|
614
|
+
slamming_pressure = test.get_slamming_pressure()
|
|
615
|
+
fat_press = ((fat_press['p_ext']['loaded'], fat_press['p_ext']['ballast'],
|
|
616
|
+
fat_press['p_ext']['part']),
|
|
617
|
+
(fat_press['p_int']['loaded'], fat_press['p_int']['ballast'],
|
|
618
|
+
fat_press['p_int']['part']))
|
|
619
|
+
|
|
620
|
+
else:
|
|
621
|
+
input_pressures = self.get_pressure_input(line)
|
|
622
|
+
lateral_press = input_pressures['lateral pressure']
|
|
623
|
+
fat_press = input_pressures['fatigue pressure']
|
|
624
|
+
slamming_pressure = input_pressures['slamming pressure']
|
|
625
|
+
fat_obj = input_pressures['fatigue object']
|
|
626
|
+
|
|
627
|
+
if self._toggle_btn.config('relief')[-1] == 'sunken':
|
|
628
|
+
found_files, predefined_stiffener_iter = self.toggle(found_files=found_files, obj = init_obj,
|
|
629
|
+
iterating=True)
|
|
630
|
+
else:
|
|
631
|
+
predefined_stiffener_iter = None
|
|
632
|
+
|
|
633
|
+
self._opt_results[line] = list(op.run_optmizataion(init_obj, self.get_lower_bounds(init_obj),
|
|
634
|
+
self.get_upper_bounds(init_obj),
|
|
635
|
+
lateral_press,self.get_deltas(),
|
|
636
|
+
algorithm=self._new_algorithm.get(),
|
|
637
|
+
trials=self._new_algorithm_random_trials.get(),
|
|
638
|
+
side=init_obj.Plate.get_side(),
|
|
639
|
+
const_chk=contraints,
|
|
640
|
+
pso_options=self.pso_parameters,
|
|
641
|
+
fatigue_obj=fat_obj,
|
|
642
|
+
fat_press_ext_int=fat_press,
|
|
643
|
+
slamming_press=slamming_pressure,
|
|
644
|
+
predefined_stiffener_iter = predefined_stiffener_iter,
|
|
645
|
+
processes=self._new_processes.get(),
|
|
646
|
+
min_max_span=max_min_span, use_weight_filter=False,
|
|
647
|
+
fdwn = self._new_fdwn.get(), fup = self._new_fdwn.get(),
|
|
648
|
+
ml_algo=self._ML_buckling))
|
|
649
|
+
self._harmonizer_data[line] = {}
|
|
650
|
+
counter += 1
|
|
651
|
+
self.progress_count.set(counter)
|
|
652
|
+
self.progress_bar.update_idletasks()
|
|
653
|
+
|
|
654
|
+
if self._opt_results[line] != None:
|
|
655
|
+
self._opt_actual_running_time.config(text='Accumulated running time: \n'
|
|
656
|
+
+ str(time.time() - t_start) + ' sec')
|
|
657
|
+
# print('Runned', line, 'OK')
|
|
658
|
+
# else:
|
|
659
|
+
# print('Runned', line, 'NOT OK - no results')
|
|
660
|
+
|
|
661
|
+
self.draw_select_canvas()
|
|
662
|
+
|
|
663
|
+
if self._new_harmonizer.get() == True:
|
|
664
|
+
self._canvas_opt.config(bg='yellow')
|
|
665
|
+
self._canvas_opt.create_text(200, 200, text='Harmonizing results',
|
|
666
|
+
font='Verdana 14 bold')
|
|
667
|
+
self.opt_harmonizer_historic()
|
|
668
|
+
|
|
669
|
+
counter += 1
|
|
670
|
+
|
|
671
|
+
self.progress_bar.stop()
|
|
672
|
+
self.run_button.config(bg='green')
|
|
673
|
+
self.draw_properties()
|
|
674
|
+
|
|
675
|
+
def opt_harmonizer_historic(self):
|
|
676
|
+
# getting all acceptable solutions.
|
|
677
|
+
all_ok_checks = []
|
|
678
|
+
for line, data in self._opt_results.items():
|
|
679
|
+
for fail_ok in data[4]:
|
|
680
|
+
if fail_ok[0] == True:
|
|
681
|
+
# try:
|
|
682
|
+
# [round(val, 10) for val in fail_ok[2]]
|
|
683
|
+
# except TypeError:
|
|
684
|
+
# [print(val) for val in fail_ok[2]]
|
|
685
|
+
|
|
686
|
+
all_ok_checks.append(tuple([round(val,10) for val in fail_ok[2][0:6]]))
|
|
687
|
+
all_ok_checks = set(all_ok_checks)
|
|
688
|
+
|
|
689
|
+
# make iterator for multiprocessing
|
|
690
|
+
iterator = list()
|
|
691
|
+
to_check = (self._new_check_sec_mod.get(), self._new_check_min_pl_thk.get(),
|
|
692
|
+
self._new_check_shear_area.get(), self._new_check_buckling.get(),
|
|
693
|
+
self._new_check_fatigue.get(), self._new_check_slamming.get(),
|
|
694
|
+
self._new_check_local_buckling.get(), False, self._new_check_ml_buckling.get(), False)
|
|
695
|
+
iter_run_info = dict()
|
|
696
|
+
for slave_line in self._opt_results.keys():
|
|
697
|
+
input_pressures = self.get_pressure_input(slave_line)
|
|
698
|
+
iter_run_info[slave_line] = {'lateral pressure': input_pressures['lateral pressure'],
|
|
699
|
+
'fatigue pressure': input_pressures['fatigue pressure'],
|
|
700
|
+
'fatigue object':input_pressures['fatigue object'],
|
|
701
|
+
'slamming pressure':input_pressures['slamming pressure'],
|
|
702
|
+
'chk_calc_obj': self._opt_results[slave_line][0], 'ML-CL': [0,0],
|
|
703
|
+
'fup': self._new_fup.get(), 'fdwn': self._new_fdwn.get()}
|
|
704
|
+
iter_run_info['lines'] = list(self._opt_results.keys())
|
|
705
|
+
iter_run_info['checks'] = to_check
|
|
706
|
+
iter_run_info['keep spacing'] = self._keep_spacing.get()
|
|
707
|
+
|
|
708
|
+
for x_check in all_ok_checks:
|
|
709
|
+
iterator.append({'x': x_check, 'info': iter_run_info})
|
|
710
|
+
|
|
711
|
+
if to_check[8]:
|
|
712
|
+
# Do ML-CL checks
|
|
713
|
+
to_run = list()
|
|
714
|
+
for x_and_info in iterator:
|
|
715
|
+
for slave_line in x_and_info['info']['lines']:
|
|
716
|
+
iter_run_info = x_and_info['info']
|
|
717
|
+
lateral_press = iter_run_info[slave_line]['lateral pressure']
|
|
718
|
+
fat_press = iter_run_info[slave_line]['fatigue pressure']
|
|
719
|
+
fat_obj = iter_run_info[slave_line]['fatigue object']
|
|
720
|
+
slamming_pressure = iter_run_info[slave_line]['slamming pressure']
|
|
721
|
+
chk_calc_obj = iter_run_info[slave_line]['chk_calc_obj']
|
|
722
|
+
master_x = list(x_and_info['x'])
|
|
723
|
+
if iter_run_info['keep spacing']:
|
|
724
|
+
x = [chk_calc_obj.Plate.get_s()] + master_x[1:] + [chk_calc_obj.Plate.span, chk_calc_obj.Plate.girder_lg]
|
|
725
|
+
else:
|
|
726
|
+
x = master_x + [chk_calc_obj.Plate.span, chk_calc_obj.Plate.girder_lg]
|
|
727
|
+
fdwn = self._new_fdwn.get()
|
|
728
|
+
fup = self._new_fdwn.get()
|
|
729
|
+
calc_object = op.create_new_calc_obj(chk_calc_obj, x, fat_obj.get_fatigue_properties(), fdwn=fdwn,
|
|
730
|
+
fup=fup)
|
|
731
|
+
|
|
732
|
+
calc_object_stf = op.create_new_calc_obj(chk_calc_obj.Stiffener, x,
|
|
733
|
+
fat_obj.get_fatigue_properties(), fdwn=fdwn, fup=fup)
|
|
734
|
+
calc_object_pl = op.create_new_calc_obj(chk_calc_obj.Plate, x, fat_obj.get_fatigue_properties(),
|
|
735
|
+
fdwn=fdwn, fup=fup)
|
|
736
|
+
calc_object = [calc.AllStructure(Plate=calc_object_pl[0], Stiffener=calc_object_stf[0], Girder=None,
|
|
737
|
+
main_dict=chk_calc_obj.get_main_properties()['main dict']),
|
|
738
|
+
calc_object_pl[1]]
|
|
739
|
+
calc_object[0].lat_press = lateral_press
|
|
740
|
+
|
|
741
|
+
to_run.append((calc_object, x, lateral_press))
|
|
742
|
+
|
|
743
|
+
# ML-CL to be used.
|
|
744
|
+
sp_int, sp_gl_gt, up_int, up_gl_gt, \
|
|
745
|
+
sp_int_idx, sp_gl_gt_idx, up_int_idx, up_gl_gt_idx = \
|
|
746
|
+
list(), list(), list(), list(), list(), list(), list(), list()
|
|
747
|
+
|
|
748
|
+
# Create iterator
|
|
749
|
+
idx_count = 0
|
|
750
|
+
for calc_object, x, lat_press in to_run:
|
|
751
|
+
idx_count += 1
|
|
752
|
+
|
|
753
|
+
if calc_object[0].Plate.get_puls_sp_or_up() == 'UP':
|
|
754
|
+
if calc_object[0].Plate.get_puls_boundary() == 'Int':
|
|
755
|
+
up_int.append(calc_object[0].Stiffener.get_buckling_ml_input(lat_press, alone=False))
|
|
756
|
+
up_int_idx.append(idx_count-1)
|
|
757
|
+
else:
|
|
758
|
+
up_gl_gt_idx.append(idx_count-1)
|
|
759
|
+
else:
|
|
760
|
+
if calc_object[0].Stiffener.get_puls_boundary() == 'Int':
|
|
761
|
+
sp_int.append(calc_object[0].Stiffener.get_buckling_ml_input(lat_press, alone=False))
|
|
762
|
+
sp_int_idx.append(idx_count-1)
|
|
763
|
+
else:
|
|
764
|
+
sp_gl_gt.append(calc_object[0].Stiffener.get_buckling_ml_input(lat_press, alone=False))
|
|
765
|
+
sp_gl_gt_idx.append(idx_count-1)
|
|
766
|
+
|
|
767
|
+
# Predict
|
|
768
|
+
sort_again = np.zeros([len(to_run), 2])
|
|
769
|
+
|
|
770
|
+
if len(sp_int) != 0:
|
|
771
|
+
sp_int_res = [self._ML_buckling['cl SP buc int predictor'].predict(self._ML_buckling['cl SP buc int scaler']
|
|
772
|
+
.transform(sp_int)),
|
|
773
|
+
self._ML_buckling['cl SP ult int predictor'].predict(self._ML_buckling['cl SP buc int scaler']
|
|
774
|
+
.transform(sp_int))]
|
|
775
|
+
for idx, res_buc, res_ult in zip(sp_int_idx, sp_int_res[0], sp_int_res[1]):
|
|
776
|
+
sort_again[idx] = [res_buc, res_ult]
|
|
777
|
+
|
|
778
|
+
if len(sp_gl_gt) != 0:
|
|
779
|
+
sp_gl_gt_res = [self._ML_buckling['cl SP buc GLGT predictor'].predict(self._ML_buckling['cl SP buc GLGT scaler']
|
|
780
|
+
.transform(sp_gl_gt)),
|
|
781
|
+
self._ML_buckling['cl SP buc GLGT predictor'].predict(self._ML_buckling['cl SP buc GLGT scaler']
|
|
782
|
+
.transform(sp_gl_gt))]
|
|
783
|
+
for idx, res_buc, res_ult in zip(sp_gl_gt_idx, sp_gl_gt_res[0], sp_gl_gt_res[1]):
|
|
784
|
+
sort_again[idx] = [res_buc, res_ult]
|
|
785
|
+
if len(up_int) != 0:
|
|
786
|
+
up_int_res = [self._ML_buckling['cl UP buc int predictor'].predict(self._ML_buckling['cl UP buc int scaler']
|
|
787
|
+
.transform(up_int)),
|
|
788
|
+
self._ML_buckling['cl UP ult int predictor'].predict(self._ML_buckling['cl UP buc int scaler']
|
|
789
|
+
.transform(up_int))]
|
|
790
|
+
for idx, res_buc, res_ult in zip(up_int_idx, up_int_res[0], up_int_res[1]):
|
|
791
|
+
sort_again[idx] = [res_buc, res_ult]
|
|
792
|
+
if len(up_gl_gt) != 0:
|
|
793
|
+
up_gl_gt_res = [self._ML_buckling['cl UP buc GLGT predictor'].predict(self._ML_buckling['cl UP buc GLGT scaler']
|
|
794
|
+
.transform(up_gl_gt)),
|
|
795
|
+
self._ML_buckling['cl UP buc GLGT predictor'].predict(self._ML_buckling['cl UP buc GLGT scaler']
|
|
796
|
+
.transform(up_gl_gt))]
|
|
797
|
+
for idx, res_buc, res_ult in zip(up_gl_gt_idx, up_gl_gt_res[0], up_gl_gt_res[1]):
|
|
798
|
+
sort_again[idx] = [res_buc, res_ult]
|
|
799
|
+
|
|
800
|
+
for idx, x_and_info in enumerate(iterator):
|
|
801
|
+
for slave_line in x_and_info['info']['lines']:
|
|
802
|
+
iterator[idx]['info'][slave_line]['ML-CL'] = sort_again[idx]
|
|
803
|
+
|
|
804
|
+
# END ML-CL calc
|
|
805
|
+
|
|
806
|
+
processes = max(cpu_count() - 1, 1)
|
|
807
|
+
with Pool(processes) as my_process:
|
|
808
|
+
res_pre = my_process.map(helper_harmonizer_multi, iterator)
|
|
809
|
+
|
|
810
|
+
after_multirun_check_ok = list()
|
|
811
|
+
for res in res_pre:
|
|
812
|
+
if res is not None:
|
|
813
|
+
after_multirun_check_ok.append(res)
|
|
814
|
+
|
|
815
|
+
lowest_area, lowest_x = float('inf'), None
|
|
816
|
+
for ok_chkd in set(after_multirun_check_ok):
|
|
817
|
+
if sum(op.get_field_tot_area(ok_chkd )) < lowest_area:
|
|
818
|
+
lowest_area = sum(op.get_field_tot_area(ok_chkd))
|
|
819
|
+
lowest_x = ok_chkd
|
|
820
|
+
|
|
821
|
+
if lowest_area != float('inf'):
|
|
822
|
+
for line in self._opt_results.keys():
|
|
823
|
+
if self._keep_spacing:
|
|
824
|
+
this_x = [self._line_to_struc[line][0].Plate.get_s()] + list(lowest_x)[1:] + \
|
|
825
|
+
[self._line_to_struc[line][0].Plate.span, self._line_to_struc[line][0].Plate.girder_lg]
|
|
826
|
+
else:
|
|
827
|
+
this_x = list(lowest_x) + [self._line_to_struc[line][0].Plate.span,
|
|
828
|
+
self._line_to_struc[line][0].Plate.girder_lg]
|
|
829
|
+
|
|
830
|
+
calc_object_stf = op.create_new_calc_obj(self._line_to_struc[line][0].Plate, this_x,
|
|
831
|
+
fat_obj.get_fatigue_properties(), fdwn=fdwn, fup=fup)
|
|
832
|
+
calc_object_pl = op.create_new_calc_obj(self._line_to_struc[line][0].Stiffener, this_x,
|
|
833
|
+
fat_obj.get_fatigue_properties(), fdwn=fdwn, fup=fup)
|
|
834
|
+
self._opt_results[line][0] = [calc.AllStructure(Plate=calc_object_pl[0], Stiffener=calc_object_stf[0], Girder=None,
|
|
835
|
+
main_dict=chk_calc_obj.get_main_properties()['main dict']),
|
|
836
|
+
calc_object_pl[1]]
|
|
837
|
+
|
|
838
|
+
if self._line_to_struc[line][2] != None:
|
|
839
|
+
self._opt_results[line][2] = opt.create_new_calc_obj(init_obj= self._line_to_struc[line][1],
|
|
840
|
+
x = this_x,
|
|
841
|
+
fat_dict=self._line_to_struc[line]
|
|
842
|
+
[2].get_fatigue_properties())[1]
|
|
843
|
+
else:
|
|
844
|
+
self._line_to_struc[line][2] = None
|
|
845
|
+
return True
|
|
846
|
+
else:
|
|
847
|
+
for line in self._opt_results.keys():
|
|
848
|
+
self._opt_results[line][0] = None
|
|
849
|
+
|
|
850
|
+
return False
|
|
851
|
+
|
|
852
|
+
def opt_harmonizer(self):
|
|
853
|
+
'''
|
|
854
|
+
Harmonizes the results of you run.
|
|
855
|
+
:return:
|
|
856
|
+
'''
|
|
857
|
+
|
|
858
|
+
# Find highest section modulus.
|
|
859
|
+
harm_res= {}
|
|
860
|
+
chk = (self._new_check_sec_mod.get(), self._new_check_min_pl_thk.get(),
|
|
861
|
+
self._new_check_shear_area.get(), self._new_check_buckling.get(),
|
|
862
|
+
self._new_check_fatigue.get(), self._new_check_slamming.get(),
|
|
863
|
+
self._new_check_local_buckling.get())
|
|
864
|
+
for master_line in self._opt_results.keys():
|
|
865
|
+
master_obj = self._opt_results[master_line][0]
|
|
866
|
+
master_x = [master_obj.Plate.get_s(), master_obj.Plate.get_pl_thk(), master_obj.Stiffener.get_web_h(),
|
|
867
|
+
master_obj.Stiffener.get_web_thk(), master_obj.Stiffener.get_fl_w(),
|
|
868
|
+
master_obj.Stiffener.get_fl_thk(),
|
|
869
|
+
master_obj.Plate.span,master_obj.Plate.girder_lg]
|
|
870
|
+
harm_res[master_line] = []
|
|
871
|
+
for slave_line in self._opt_results.keys():
|
|
872
|
+
input_pressures = self.get_pressure_input(slave_line)
|
|
873
|
+
lateral_press = input_pressures['lateral pressure']
|
|
874
|
+
fat_press = input_pressures['fatigue pressure']
|
|
875
|
+
fat_obj = input_pressures['fatigue object']
|
|
876
|
+
slamming_pressure = input_pressures['slamming pressure']
|
|
877
|
+
chk_calc_obj = self._opt_results[slave_line][1]
|
|
878
|
+
|
|
879
|
+
chk_result = list(op.run_optmizataion(chk_calc_obj,
|
|
880
|
+
master_x[0:6]+[chk_calc_obj.Plate.span,
|
|
881
|
+
chk_calc_obj.Plate.girder_lg],
|
|
882
|
+
master_x[0:6]+[chk_calc_obj.Plate.span,
|
|
883
|
+
chk_calc_obj.Plate.girder_lg],
|
|
884
|
+
lateral_press,self.get_deltas(),
|
|
885
|
+
algorithm=self._new_algorithm.get(),
|
|
886
|
+
trials=self._new_algorithm_random_trials.get(),
|
|
887
|
+
side=chk_calc_obj.Plate.get_side(), const_chk=chk,
|
|
888
|
+
pso_options=self.pso_parameters,fatigue_obj=fat_obj,
|
|
889
|
+
fat_press_ext_int=fat_press, slamming_press=slamming_pressure,
|
|
890
|
+
predefined_stiffener_iter = None,
|
|
891
|
+
processes=self._new_processes.get(), min_max_span=None,
|
|
892
|
+
use_weight_filter=True,
|
|
893
|
+
fdwn = self._new_fdwn.get(), fup = self._new_fdwn.get()))[0:4]
|
|
894
|
+
print('Master:', master_line, 'Slave', slave_line, 'Check', chk_result[-1])
|
|
895
|
+
harm_res[master_line].append(chk_result)
|
|
896
|
+
|
|
897
|
+
harmonized_area, harmonized_line =float('inf'), None
|
|
898
|
+
for master_line, all_slave_res in harm_res.items():
|
|
899
|
+
if all([slave_line_res[-1] for slave_line_res in all_slave_res]):
|
|
900
|
+
master_obj = self._opt_results[master_line][0]
|
|
901
|
+
master_area = sum(op.get_field_tot_area([master_obj.Plate.get_s(), master_obj.Plate.get_pl_thk(),
|
|
902
|
+
master_obj.Stiffener.get_web_h(), master_obj.Stiffener.get_web_thk(),
|
|
903
|
+
master_obj.Stiffener.get_fl_w(), master_obj.Stiffener.get_fl_thk(),
|
|
904
|
+
master_obj.Plate.span,master_obj.Plate.girder_lg]))
|
|
905
|
+
if master_area < harmonized_area:
|
|
906
|
+
harmonized_area = master_area
|
|
907
|
+
harmonized_line = master_line
|
|
908
|
+
|
|
909
|
+
if harmonized_area != 0 and harmonized_line is not None:
|
|
910
|
+
harmonized_x_pl = self._opt_results[harmonized_line][0].Plate.get_tuple()
|
|
911
|
+
harmonized_x_stf = self._opt_results[harmonized_line][0].Stiffener.get_tuple()
|
|
912
|
+
harmonized_x = harmonized_x_pl[0:2] + harmonized_x_stf[2:]
|
|
913
|
+
for line in self._opt_results.keys():
|
|
914
|
+
self._opt_results[line][0] = opt.create_new_structure_obj(self._line_to_struc[line][0], harmonized_x)
|
|
915
|
+
|
|
916
|
+
calc_object_stf = op.create_new_calc_obj(self._line_to_struc[line][0].Plate, harmonized_x)
|
|
917
|
+
calc_object_pl = op.create_new_calc_obj(self._line_to_struc[line][0].Stiffener,harmonized_x)
|
|
918
|
+
self._opt_results[line][0] = [calc.AllStructure(Plate=calc_object_pl[0], Stiffener=calc_object_stf[0],
|
|
919
|
+
Girder=None, main_dict=chk_calc_obj.get_main_properties()['main dict']),
|
|
920
|
+
calc_object_pl[1]]
|
|
921
|
+
|
|
922
|
+
if self._line_to_struc[line][2] != None:
|
|
923
|
+
self._opt_results[line][2] = opt.create_new_calc_obj(init_obj= self._line_to_struc[line][1],
|
|
924
|
+
x = harmonized_x,
|
|
925
|
+
fat_dict=self._line_to_struc[line]
|
|
926
|
+
[2].get_fatigue_properties())[1]
|
|
927
|
+
else:
|
|
928
|
+
self._line_to_struc[line][2] = None
|
|
929
|
+
return True
|
|
930
|
+
else:
|
|
931
|
+
for line in self._opt_results.keys():
|
|
932
|
+
self._opt_results[line][0] = None
|
|
933
|
+
self._opt_results[line][1] = None
|
|
934
|
+
return False
|
|
935
|
+
|
|
936
|
+
def get_running_time(self):
|
|
937
|
+
'''
|
|
938
|
+
Estimate the running time of the algorithm.
|
|
939
|
+
:return:
|
|
940
|
+
'''
|
|
941
|
+
if self._new_algorithm.get() in ['anysmart', 'anydetail']:
|
|
942
|
+
try:
|
|
943
|
+
number_of_combinations = \
|
|
944
|
+
max((self._new_spacing_upper.get() - self._new_spacing_lower.get()) / self._new_delta_spacing.get(),
|
|
945
|
+
1) * \
|
|
946
|
+
max((self._new_pl_thk_upper.get() - self._new_pl_thk_lower.get()) / self._new_delta_pl_thk.get(), 1) * \
|
|
947
|
+
max((self._new_web_h_upper.get() - self._new_web_h_lower.get()) / self._new_delta_web_h.get(), 1) * \
|
|
948
|
+
max((self._new_web_thk_upper.get() - self._new_web_thk_lower.get()) / self._new_delta_web_thk.get(),
|
|
949
|
+
1) * \
|
|
950
|
+
max((self._new_fl_w_upper.get() - self._new_fl_w_lower.get()) / self._new_delta_fl_w.get(), 1) * \
|
|
951
|
+
max((self._new_fl_thk_upper.get() - self._new_fl_thk_lower.get()) / self._new_delta_fl_thk.get(), 1)
|
|
952
|
+
return int(number_of_combinations * self.running_time_per_item)*len(self._active_lines)
|
|
953
|
+
except TclError:
|
|
954
|
+
return 0
|
|
955
|
+
else:
|
|
956
|
+
try:
|
|
957
|
+
return int(self._new_algorithm_random_trials.get() * self.running_time_per_item)*len(self._active_lines)
|
|
958
|
+
except TclError:
|
|
959
|
+
return 0
|
|
960
|
+
|
|
961
|
+
def get_deltas(self):
|
|
962
|
+
'''
|
|
963
|
+
Return a numpy array of the deltas.
|
|
964
|
+
:return:
|
|
965
|
+
'''
|
|
966
|
+
return np.array([float(self._ent_delta_spacing.get()) / 1000, float(self._new_delta_pl_thk.get()) / 1000,
|
|
967
|
+
float(self._new_delta_web_h.get()) / 1000, float(self._new_delta_web_thk.get()) / 1000,
|
|
968
|
+
float(self._new_delta_fl_w.get()) / 1000, float(self._new_delta_fl_thk.get()) / 1000])
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
def update_running_time(self, *args):
|
|
973
|
+
'''
|
|
974
|
+
Estimate the running time of the algorithm.
|
|
975
|
+
:return:
|
|
976
|
+
'''
|
|
977
|
+
try:
|
|
978
|
+
self._runnig_time_label.config(text=str(self.get_running_time()))
|
|
979
|
+
except ZeroDivisionError:
|
|
980
|
+
pass # _tkinter.TclError: pass
|
|
981
|
+
|
|
982
|
+
if self._new_check_ml_buckling.get() == True:
|
|
983
|
+
self._new_check_buckling.set(False)
|
|
984
|
+
self._new_check_local_buckling.set(False)
|
|
985
|
+
|
|
986
|
+
def get_upper_bounds(self,obj):
|
|
987
|
+
'''
|
|
988
|
+
Return an numpy array of upper bounds.
|
|
989
|
+
:return:
|
|
990
|
+
'''
|
|
991
|
+
if self._keep_spacing:
|
|
992
|
+
spacing = obj.Plate.get_s()
|
|
993
|
+
else:
|
|
994
|
+
spacing = self._new_spacing_lower.get() / 1000
|
|
995
|
+
return np.array([spacing, self._new_pl_thk_upper.get() / 1000,
|
|
996
|
+
self._new_web_h_upper.get() / 1000, self._new_web_thk_upper.get() / 1000,
|
|
997
|
+
self._new_fl_w_upper.get() / 1000, self._new_fl_thk_upper.get() / 1000,
|
|
998
|
+
obj.Plate.span, obj.Plate.girder_lg])
|
|
999
|
+
|
|
1000
|
+
def get_lower_bounds(self,obj):
|
|
1001
|
+
'''
|
|
1002
|
+
Return an numpy array of lower bounds.
|
|
1003
|
+
:return:
|
|
1004
|
+
'''
|
|
1005
|
+
if self._keep_spacing:
|
|
1006
|
+
spacing = obj.Plate.get_s()
|
|
1007
|
+
else:
|
|
1008
|
+
spacing = self._new_spacing_lower.get() / 1000
|
|
1009
|
+
return np.array([spacing, self._new_pl_thk_lower.get() / 1000,
|
|
1010
|
+
self._new_web_h_lower.get() / 1000, self._new_web_thk_lower.get() / 1000,
|
|
1011
|
+
self._new_fl_w_lower.get() / 1000, self._new_fl_thk_lower.get() / 1000,
|
|
1012
|
+
obj.Plate.span, obj.Plate.girder_lg])
|
|
1013
|
+
|
|
1014
|
+
def checkered(self, line_distance):
|
|
1015
|
+
'''
|
|
1016
|
+
Creates a grid in the properties canvas.
|
|
1017
|
+
:param line_distance:
|
|
1018
|
+
:return:
|
|
1019
|
+
'''
|
|
1020
|
+
# vertical lines at an interval of "line_distance" pixel
|
|
1021
|
+
for x in range(line_distance, self._prop_canvas_dim[0], line_distance):
|
|
1022
|
+
self._canvas_opt.create_line(x, 0, x, self._prop_canvas_dim[0], fill="grey", stipple='gray50')
|
|
1023
|
+
# horizontal lines at an interval of "line_distance" pixel
|
|
1024
|
+
for y in range(line_distance, self._prop_canvas_dim[1], line_distance):
|
|
1025
|
+
self._canvas_opt.create_line(0, y, self._prop_canvas_dim[0], y, fill="grey", stipple='gray50')
|
|
1026
|
+
|
|
1027
|
+
def draw_properties(self,init_obj = None, opt_obj=None,line=None):
|
|
1028
|
+
'''
|
|
1029
|
+
Drawing properties in the canvas.
|
|
1030
|
+
:return:
|
|
1031
|
+
'''
|
|
1032
|
+
ctr_x = self._prop_canvas_dim[0] / 2
|
|
1033
|
+
ctr_y = self._prop_canvas_dim[1] / 2 + 200
|
|
1034
|
+
opt_color, opt_stippe = 'red', 'gray12'
|
|
1035
|
+
m = self._draw_scale
|
|
1036
|
+
self._canvas_opt.delete('all')
|
|
1037
|
+
if init_obj != None:
|
|
1038
|
+
|
|
1039
|
+
self.checkered(10)
|
|
1040
|
+
init_color, init_stipple = 'blue', 'gray12'
|
|
1041
|
+
|
|
1042
|
+
self._canvas_opt.create_rectangle(0, 0, self._prop_canvas_dim[0] + 10, 80, fill='white')
|
|
1043
|
+
self._canvas_opt.create_line(10, 10, 30, 10, fill=init_color, width=5)
|
|
1044
|
+
self._canvas_opt.create_text(270, 10, text='Initial - Pl.: ' + str(init_obj.Plate.get_s() * 1000) + 'x' + str(
|
|
1045
|
+
init_obj.Plate.get_pl_thk() * 1000) +
|
|
1046
|
+
' Stf.: ' + str(init_obj.Stiffener.get_web_h() * 1000) + 'x' + str(
|
|
1047
|
+
init_obj.Stiffener.get_web_thk() * 1000) + '+' +
|
|
1048
|
+
str(init_obj.Stiffener.get_fl_w() * 1000) + 'x' +
|
|
1049
|
+
str(init_obj.Stiffener.get_fl_thk() * 1000),
|
|
1050
|
+
font='Verdana 8',
|
|
1051
|
+
fill=init_color)
|
|
1052
|
+
self._canvas_opt.create_text(120, 30, text='Weight (per Lg width): ' +
|
|
1053
|
+
str(int(op.calc_weight([init_obj.Plate.get_s(),
|
|
1054
|
+
init_obj.Plate.get_pl_thk(),
|
|
1055
|
+
init_obj.Stiffener.get_web_h(),
|
|
1056
|
+
init_obj.Stiffener.get_web_thk(),
|
|
1057
|
+
init_obj.Stiffener.get_fl_w(),
|
|
1058
|
+
init_obj.Stiffener.get_fl_thk(),
|
|
1059
|
+
init_obj.Stiffener.span,
|
|
1060
|
+
init_obj.Stiffener.girder_lg]))),
|
|
1061
|
+
font='Verdana 8', fill=init_color)
|
|
1062
|
+
|
|
1063
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.Plate.get_s() / 2, ctr_y, ctr_x + m * init_obj.Plate.get_s() / 2,
|
|
1064
|
+
ctr_y - m * init_obj.Plate.get_pl_thk(), fill=init_color, stipple=init_stipple)
|
|
1065
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.Stiffener.get_web_thk() / 2, ctr_y - m * init_obj.Stiffener.get_pl_thk(),
|
|
1066
|
+
ctr_x + m * init_obj.Stiffener.get_web_thk() / 2, ctr_y - m * (init_obj.Stiffener.get_web_h() + init_obj.Stiffener.get_pl_thk())
|
|
1067
|
+
, fill=init_color, stipple=init_stipple)
|
|
1068
|
+
if init_obj.Stiffener.get_stiffener_type() not in ['L', 'L-bulb']:
|
|
1069
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.Stiffener.get_fl_w() / 2, ctr_y - m * (init_obj.Plate.get_pl_thk() + init_obj.Stiffener.get_web_h()),
|
|
1070
|
+
ctr_x + m * init_obj.Stiffener.get_fl_w() / 2,
|
|
1071
|
+
ctr_y - m * (init_obj.Plate.get_pl_thk() + init_obj.Stiffener.get_web_h() + init_obj.Stiffener.get_fl_thk()),
|
|
1072
|
+
fill=init_color, stipple=init_stipple)
|
|
1073
|
+
else:
|
|
1074
|
+
self._canvas_opt.create_rectangle(ctr_x - m * init_obj.Stiffener.get_web_thk() / 2,
|
|
1075
|
+
ctr_y - m * (init_obj.Plate.get_pl_thk() + init_obj.Stiffener.get_web_h()),
|
|
1076
|
+
ctr_x + m * init_obj.Stiffener.get_fl_w(),
|
|
1077
|
+
ctr_y - m * (init_obj.Plate.get_pl_thk() + init_obj.Stiffener.get_web_h() + init_obj.Stiffener.get_fl_thk()),
|
|
1078
|
+
fill=init_color, stipple=init_stipple)
|
|
1079
|
+
|
|
1080
|
+
if opt_obj != None:
|
|
1081
|
+
# [0.6, 0.012, 0.25, 0.01, 0.1, 0.01]
|
|
1082
|
+
self._canvas_opt.config(bg = 'palegreen')
|
|
1083
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.Plate.get_s() / 2, ctr_y,
|
|
1084
|
+
ctr_x + m * opt_obj.Plate.get_s() / 2,
|
|
1085
|
+
ctr_y - m * opt_obj.Plate.get_pl_thk(), fill=opt_color,
|
|
1086
|
+
stipple=opt_stippe)
|
|
1087
|
+
|
|
1088
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.Stiffener.get_web_thk() / 2, ctr_y -
|
|
1089
|
+
m * opt_obj.Plate.get_pl_thk(),
|
|
1090
|
+
ctr_x + m * opt_obj.Stiffener.get_web_thk() / 2,
|
|
1091
|
+
ctr_y - m * (
|
|
1092
|
+
opt_obj.Stiffener.get_web_h() + opt_obj.Plate.get_pl_thk())
|
|
1093
|
+
, fill=opt_color, stipple=opt_stippe)
|
|
1094
|
+
if init_obj.Stiffener.get_stiffener_type() not in ['L', 'L-bulb']:
|
|
1095
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.Stiffener.get_fl_w() / 2, ctr_y
|
|
1096
|
+
- m * (
|
|
1097
|
+
opt_obj.Plate.get_pl_thk() + opt_obj.Stiffener.get_web_h()),
|
|
1098
|
+
ctr_x + m * opt_obj.Stiffener.get_fl_w() / 2, ctr_y -
|
|
1099
|
+
m * (
|
|
1100
|
+
opt_obj.Plate.get_pl_thk() + opt_obj.Stiffener.get_web_h() +
|
|
1101
|
+
opt_obj.Stiffener.get_fl_thk()),
|
|
1102
|
+
fill=opt_color, stipple=opt_stippe)
|
|
1103
|
+
else:
|
|
1104
|
+
self._canvas_opt.create_rectangle(ctr_x - m * opt_obj.Stiffener.get_web_thk() / 2, ctr_y
|
|
1105
|
+
- m * (
|
|
1106
|
+
opt_obj.Plate.get_pl_thk() + opt_obj.Stiffener.get_web_h()),
|
|
1107
|
+
ctr_x + m * opt_obj.Stiffener.get_fl_w(), ctr_y -
|
|
1108
|
+
m * (
|
|
1109
|
+
opt_obj.Plate.get_pl_thk() + opt_obj.Stiffener.get_web_h() +
|
|
1110
|
+
opt_obj.Stiffener.get_fl_thk()),
|
|
1111
|
+
fill=opt_color, stipple=opt_stippe)
|
|
1112
|
+
|
|
1113
|
+
self._canvas_opt.create_line(10, 50, 30, 50, fill=opt_color, width=5)
|
|
1114
|
+
self._canvas_opt.create_text(270, 50,
|
|
1115
|
+
text='Optimized - Pl.: ' + str(round(opt_obj.Plate.get_s() * 1000,1)) + 'x' +
|
|
1116
|
+
str(round(opt_obj.Plate.get_pl_thk() * 1000,1)) + ' Stf.: '
|
|
1117
|
+
+ str(round(opt_obj.Stiffener.get_web_h() * 1000,1)) +
|
|
1118
|
+
'x' + str(round(opt_obj.Stiffener.get_web_thk() * 1000,1)) + '+' +
|
|
1119
|
+
str(round(opt_obj.Stiffener.get_fl_w() * 1000,1)) +
|
|
1120
|
+
'x' + str(round(opt_obj.Stiffener.get_fl_thk() * 1000,1)),
|
|
1121
|
+
font='Verdana 8', fill=opt_color)
|
|
1122
|
+
self._canvas_opt.create_text(120, 70, text='Weight (per Lg width): '
|
|
1123
|
+
+ str(int(op.calc_weight([opt_obj.Plate.get_s(),
|
|
1124
|
+
opt_obj.Plate.get_pl_thk(),
|
|
1125
|
+
opt_obj.Stiffener.get_web_h(),
|
|
1126
|
+
opt_obj.Stiffener.get_web_thk(),
|
|
1127
|
+
opt_obj.Stiffener.get_fl_w(),
|
|
1128
|
+
opt_obj.Stiffener.get_fl_thk(),
|
|
1129
|
+
opt_obj.Plate.span,
|
|
1130
|
+
opt_obj.Plate.girder_lg]))),
|
|
1131
|
+
font='Verdana 8', fill=opt_color)
|
|
1132
|
+
|
|
1133
|
+
elif self._opt_results != {}:
|
|
1134
|
+
self._canvas_opt.config(bg='green')
|
|
1135
|
+
self._canvas_opt.create_text(200, 200, text='Optimization results avaliable.\n\n'
|
|
1136
|
+
'Middle click orange lines to\n view results.',
|
|
1137
|
+
font = 'Verdana 14 bold')
|
|
1138
|
+
|
|
1139
|
+
else:
|
|
1140
|
+
self._canvas_opt.config(bg='mistyrose')
|
|
1141
|
+
self._canvas_opt.create_text(200, 60, text='No optimization results found.', font = 'Verdana 14 bold')
|
|
1142
|
+
|
|
1143
|
+
if line != None:
|
|
1144
|
+
if __name__ == '__main__':
|
|
1145
|
+
lateral_press = 200 # for testing
|
|
1146
|
+
else:
|
|
1147
|
+
lateral_press = self.app.get_highest_pressure(line)['normal'] / 1000
|
|
1148
|
+
self._canvas_opt.create_text(250, self._prop_canvas_dim[1]-10,
|
|
1149
|
+
text= line + ' lateral pressure: '+str(lateral_press)+' kPa',
|
|
1150
|
+
font='Verdana 10 bold',fill='red')
|
|
1151
|
+
|
|
1152
|
+
def draw_select_canvas(self, load_selected=False):
|
|
1153
|
+
'''
|
|
1154
|
+
Making the lines canvas.
|
|
1155
|
+
:return:
|
|
1156
|
+
'''
|
|
1157
|
+
self._canvas_select.delete('all')
|
|
1158
|
+
|
|
1159
|
+
# grid for the canavs
|
|
1160
|
+
|
|
1161
|
+
self._canvas_select.create_line(self._canvas_draw_origo[0], 0, self._canvas_draw_origo[0], self._select_canvas_dim[1],
|
|
1162
|
+
stipple='gray50')
|
|
1163
|
+
self._canvas_select.create_line(0, self._canvas_draw_origo[1], self._select_canvas_dim[0], self._canvas_draw_origo[1],
|
|
1164
|
+
stipple='gray50')
|
|
1165
|
+
self._canvas_select.create_text(self._canvas_draw_origo[0] - 30 ,
|
|
1166
|
+
self._canvas_draw_origo[1] + 20 , text='(0,0)',
|
|
1167
|
+
font='Text 10')
|
|
1168
|
+
self._canvas_select.create_text([800 ,60],
|
|
1169
|
+
text='Mouse left click: select lines to loads\n'
|
|
1170
|
+
'Mouse mid click: show properties for one line\n'
|
|
1171
|
+
'Mouse right click: clear all selection\n'
|
|
1172
|
+
'Shift key press: add selected line\n'
|
|
1173
|
+
'Control key press: remove selected line\n\n'
|
|
1174
|
+
'NOTE! Select lines you want to return before\n'
|
|
1175
|
+
'pressing return button.', font='Verdana 8 bold',
|
|
1176
|
+
fill='red')
|
|
1177
|
+
# drawing the line dictionary.
|
|
1178
|
+
if len(self._line_dict) != 0:
|
|
1179
|
+
for line, value in self._line_dict.items():
|
|
1180
|
+
color = 'black'
|
|
1181
|
+
coord1 = self.get_point_canvas_coord('point' + str(value[0]))
|
|
1182
|
+
coord2 = self.get_point_canvas_coord('point' + str(value[1]))
|
|
1183
|
+
|
|
1184
|
+
vector = [coord2[0] - coord1[0], coord2[1] - coord1[1]]
|
|
1185
|
+
# drawing a bold line if it is selected
|
|
1186
|
+
if line in self._active_lines:
|
|
1187
|
+
width = 6
|
|
1188
|
+
if line in self._opt_results.keys():
|
|
1189
|
+
color, width = 'orange', 8
|
|
1190
|
+
self._canvas_select.create_line(coord1, coord2, width=width, fill=color)
|
|
1191
|
+
self._canvas_select.create_text(coord1[0] + vector[0] / 2 + 5, coord1[1] + vector[1] / 2 + 10,
|
|
1192
|
+
text='Line ' + str(get_num(line)), font='Verdand 10 bold',
|
|
1193
|
+
fill='red')
|
|
1194
|
+
else:
|
|
1195
|
+
if line in self._opt_results.keys():
|
|
1196
|
+
color = 'orange'
|
|
1197
|
+
self._canvas_select.create_line(coord1, coord2, width=3, fill=color)
|
|
1198
|
+
self._canvas_select.create_text(coord1[0] - 20 + vector[0] / 2 + 5, coord1[1] + vector[1] / 2 + 10,
|
|
1199
|
+
text='line' + str(get_num(line)), font="Text 8", fill='black')
|
|
1200
|
+
|
|
1201
|
+
def algorithm_info(self):
|
|
1202
|
+
''' When button is clicked, info is displayed.'''
|
|
1203
|
+
|
|
1204
|
+
messagebox.showinfo(title='Algorithm information',
|
|
1205
|
+
message='The algorithms currently included is:\n'
|
|
1206
|
+
'ANYSMART: \n'
|
|
1207
|
+
' Calculates all alternatives using upper and lower bounds.\n'
|
|
1208
|
+
' The step used inside the bounds is defined in deltas.\n\n'
|
|
1209
|
+
'RANDOM: \n'
|
|
1210
|
+
' Uses the same bounds and deltas as in ANYSMART.\n'
|
|
1211
|
+
' Number of combinations calculated is defined in "trials",\n'
|
|
1212
|
+
' which selects withing the bounds and deltas defined.\n\n'
|
|
1213
|
+
'RANDOM_NO_BOUNDS:\n'
|
|
1214
|
+
' Same as RANDOM, but does not use the defined deltas.\n'
|
|
1215
|
+
' The deltas is set to 1 mm for all dimensions/thicknesses.\n\n'
|
|
1216
|
+
'ANYDETAIL:\n'
|
|
1217
|
+
' Same as for ANYSMART, but will take some more time and\n'
|
|
1218
|
+
' provide a chart of weight development during execution.\n\n'
|
|
1219
|
+
'PSO - Particle Swarm Search:\n'
|
|
1220
|
+
' The information can be found on \n'
|
|
1221
|
+
' http://pythonhosted.org/pyswarm/ \n'
|
|
1222
|
+
' For further information google it!\n'
|
|
1223
|
+
' Parameters:\n'
|
|
1224
|
+
' swarmsize : The number of particles in the swarm (Default: 100)\n'
|
|
1225
|
+
' omega : Particle velocity scaling factor (Default: 0.5)\n'
|
|
1226
|
+
' phip : Scaling factor to search away from the particle’s \n'
|
|
1227
|
+
' best known position (Default: 0.5)\n'
|
|
1228
|
+
' phig : Scaling factor to search away from the swarm’s best \n'
|
|
1229
|
+
' known position (Default: 0.5)\n'
|
|
1230
|
+
' maxiter : The maximum number of iterations for the swarm \n'
|
|
1231
|
+
' to search (Default: 100)\n'
|
|
1232
|
+
' minstep : The minimum stepsize of swarm’s best position \n'
|
|
1233
|
+
' before the search terminates (Default: 1e-8)\n'
|
|
1234
|
+
' minfunc : The minimum change of swarm’s best objective value\n'
|
|
1235
|
+
' before the search terminates (Default: 1e-8)\n\n'
|
|
1236
|
+
|
|
1237
|
+
'\n'
|
|
1238
|
+
'All algorithms calculates local scantling and buckling requirements')
|
|
1239
|
+
|
|
1240
|
+
def slider_used(self, event):
|
|
1241
|
+
'''
|
|
1242
|
+
Action when slider is activated.
|
|
1243
|
+
:return:
|
|
1244
|
+
'''
|
|
1245
|
+
self._canvas_scale = self.slider.get()
|
|
1246
|
+
self.draw_canvas()
|
|
1247
|
+
|
|
1248
|
+
def on_closing(self):
|
|
1249
|
+
'''
|
|
1250
|
+
Action when closing the window without saving.
|
|
1251
|
+
:return:
|
|
1252
|
+
'''
|
|
1253
|
+
if __name__ == '__main__':
|
|
1254
|
+
self._frame.destroy()
|
|
1255
|
+
return
|
|
1256
|
+
|
|
1257
|
+
mess = tk.messagebox.showwarning('Closed without saving', 'Closing will not save loads you have created',
|
|
1258
|
+
type = 'okcancel')
|
|
1259
|
+
if mess == 'ok':
|
|
1260
|
+
self._frame.grab_release()
|
|
1261
|
+
self._frame.destroy()
|
|
1262
|
+
self.app.on_aborted_load_window()
|
|
1263
|
+
|
|
1264
|
+
def get_point_canvas_coord(self, point_no):
|
|
1265
|
+
'''
|
|
1266
|
+
Returning the canvas coordinates of the point. This value will change with slider.
|
|
1267
|
+
:param point_no:
|
|
1268
|
+
:return:
|
|
1269
|
+
'''
|
|
1270
|
+
point_coord_x = self._canvas_draw_origo[0] + self._point_dict[point_no][0]* self._canvas_scale
|
|
1271
|
+
point_coord_y = self._canvas_draw_origo[1] - self._point_dict[point_no][1]* self._canvas_scale
|
|
1272
|
+
|
|
1273
|
+
return [point_coord_x, point_coord_y]
|
|
1274
|
+
|
|
1275
|
+
def controls(self):
|
|
1276
|
+
'''
|
|
1277
|
+
Specifying the controls to be used.
|
|
1278
|
+
:return:
|
|
1279
|
+
'''
|
|
1280
|
+
self._canvas_select.bind('<Button-1>', self.left_click)
|
|
1281
|
+
self._canvas_select.bind('<Button-2>', self.mid_click)
|
|
1282
|
+
self._canvas_select.bind('<Button-3>', self.right_click)
|
|
1283
|
+
|
|
1284
|
+
self._frame.bind('<Shift_L>', self.shift_pressed)
|
|
1285
|
+
self._frame.bind('<Shift_R>', self.shift_pressed)
|
|
1286
|
+
self._frame.bind('<Control_L>', self.ctrl_pressed)
|
|
1287
|
+
self._frame.bind('<Control_R>', self.ctrl_pressed)
|
|
1288
|
+
self._frame.bind("<MouseWheel>", self.mouse_scroll)
|
|
1289
|
+
self._frame.bind("<B2-Motion>", self.button_2_click_and_drag)
|
|
1290
|
+
|
|
1291
|
+
def shift_pressed(self,event=None):
|
|
1292
|
+
'''
|
|
1293
|
+
Event is executed when shift key pressed.
|
|
1294
|
+
:return:
|
|
1295
|
+
'''
|
|
1296
|
+
self._add_to_lines = True
|
|
1297
|
+
|
|
1298
|
+
def ctrl_pressed(self,event=None):
|
|
1299
|
+
'''
|
|
1300
|
+
Event when control is pressed.
|
|
1301
|
+
:param event:
|
|
1302
|
+
:return:
|
|
1303
|
+
'''
|
|
1304
|
+
self._add_to_lines = False
|
|
1305
|
+
|
|
1306
|
+
def left_click(self, event):
|
|
1307
|
+
'''
|
|
1308
|
+
When clicking the right button, this method is called.
|
|
1309
|
+
method is referenced in
|
|
1310
|
+
'''
|
|
1311
|
+
self._previous_drag_mouse = [event.x, event.y]
|
|
1312
|
+
click_x = self._canvas_select.winfo_pointerx() - self._canvas_select.winfo_rootx()
|
|
1313
|
+
click_y = self._canvas_select.winfo_pointery() - self._canvas_select.winfo_rooty()
|
|
1314
|
+
stop = False
|
|
1315
|
+
|
|
1316
|
+
if len(self._line_dict) > 0:
|
|
1317
|
+
for key, value in self._line_dict.items():
|
|
1318
|
+
|
|
1319
|
+
coord1x = self.get_point_canvas_coord('point' + str(value[0]))[0]
|
|
1320
|
+
coord2x = self.get_point_canvas_coord('point' + str(value[1]))[0]
|
|
1321
|
+
coord1y = self.get_point_canvas_coord('point' + str(value[0]))[1]
|
|
1322
|
+
coord2y = self.get_point_canvas_coord('point' + str(value[1]))[1]
|
|
1323
|
+
|
|
1324
|
+
vector = [coord2x - coord1x, coord2y - coord1y]
|
|
1325
|
+
click_x_range = [ix for ix in range(click_x - 10, click_x + 10)]
|
|
1326
|
+
click_y_range = [iy for iy in range(click_y - 10, click_y + 10)]
|
|
1327
|
+
distance = int(dist([coord1x, coord1y], [coord2x, coord2y]))
|
|
1328
|
+
|
|
1329
|
+
# checking along the line if the click is witnin +- 10 around the click
|
|
1330
|
+
for dist_mult in range(1, distance - 1):
|
|
1331
|
+
dist_mult = dist_mult / distance
|
|
1332
|
+
x_check = int(coord1x) + int(round(vector[0] * dist_mult, 0))
|
|
1333
|
+
y_check = int(coord1y) + int(round(vector[1] * dist_mult, 0))
|
|
1334
|
+
if x_check in click_x_range and y_check in click_y_range:
|
|
1335
|
+
self.line_is_active = True
|
|
1336
|
+
if self._add_to_lines:
|
|
1337
|
+
if key not in self._active_lines:
|
|
1338
|
+
self._active_lines.append(key)
|
|
1339
|
+
elif self._add_to_lines== False:
|
|
1340
|
+
if key in self._active_lines:
|
|
1341
|
+
self._active_lines.remove(key)
|
|
1342
|
+
self._canvas_select.delete('all')
|
|
1343
|
+
break
|
|
1344
|
+
self.draw_select_canvas()
|
|
1345
|
+
self.update_running_time()
|
|
1346
|
+
|
|
1347
|
+
def right_click(self,event):
|
|
1348
|
+
'''
|
|
1349
|
+
Event when right click.
|
|
1350
|
+
:param evnet:
|
|
1351
|
+
:return:
|
|
1352
|
+
'''
|
|
1353
|
+
|
|
1354
|
+
self._previous_drag_mouse = [event.x, event.y]
|
|
1355
|
+
self._active_lines = []
|
|
1356
|
+
self._canvas_select.delete('all')
|
|
1357
|
+
self.draw_select_canvas()
|
|
1358
|
+
self.update_running_time()
|
|
1359
|
+
|
|
1360
|
+
def mid_click(self,event):
|
|
1361
|
+
'''
|
|
1362
|
+
Event when right click.
|
|
1363
|
+
:param evnet:
|
|
1364
|
+
:return:
|
|
1365
|
+
'''
|
|
1366
|
+
|
|
1367
|
+
self._previous_drag_mouse = [event.x, event.y]
|
|
1368
|
+
if self._opt_results == {}:
|
|
1369
|
+
return
|
|
1370
|
+
click_x = self._canvas_select.winfo_pointerx() - self._canvas_select.winfo_rootx()
|
|
1371
|
+
click_y = self._canvas_select.winfo_pointery() - self._canvas_select.winfo_rooty()
|
|
1372
|
+
|
|
1373
|
+
if len(self._line_dict) > 0:
|
|
1374
|
+
for key, value in self._line_dict.items():
|
|
1375
|
+
|
|
1376
|
+
coord1x = self.get_point_canvas_coord('point' + str(value[0]))[0]
|
|
1377
|
+
coord2x = self.get_point_canvas_coord('point' + str(value[1]))[0]
|
|
1378
|
+
coord1y = self.get_point_canvas_coord('point' + str(value[0]))[1]
|
|
1379
|
+
coord2y = self.get_point_canvas_coord('point' + str(value[1]))[1]
|
|
1380
|
+
|
|
1381
|
+
vector = [coord2x - coord1x, coord2y - coord1y]
|
|
1382
|
+
click_x_range = [ix for ix in range(click_x - 10, click_x + 10)]
|
|
1383
|
+
click_y_range = [iy for iy in range(click_y - 10, click_y + 10)]
|
|
1384
|
+
distance = int(dist([coord1x, coord1y], [coord2x, coord2y]))
|
|
1385
|
+
|
|
1386
|
+
# checking along the line if the click is witnin +- 10 around the click
|
|
1387
|
+
for dist_mult in range(1, distance - 1):
|
|
1388
|
+
dist_mult = dist_mult / distance
|
|
1389
|
+
x_check = int(coord1x) + int(round(vector[0] * dist_mult, 0))
|
|
1390
|
+
y_check = int(coord1y) + int(round(vector[1] * dist_mult, 0))
|
|
1391
|
+
if x_check in click_x_range and y_check in click_y_range:
|
|
1392
|
+
self._canvas_select.delete('all')
|
|
1393
|
+
self._active_lines = []
|
|
1394
|
+
self._active_lines.append(key)
|
|
1395
|
+
if key in self._opt_results.keys() and self._opt_results[key]!=None:
|
|
1396
|
+
self.draw_properties(init_obj=self._line_to_struc[key][0],opt_obj=self._opt_results[key][0],
|
|
1397
|
+
line=key)
|
|
1398
|
+
self._mid_click_line = key
|
|
1399
|
+
else:
|
|
1400
|
+
self.draw_properties(init_obj=self._line_to_struc[key][0],line=key)
|
|
1401
|
+
self._mid_click_line = None
|
|
1402
|
+
break
|
|
1403
|
+
self.draw_select_canvas()
|
|
1404
|
+
self.draw_select_canvas()
|
|
1405
|
+
self.update_running_time()
|
|
1406
|
+
|
|
1407
|
+
def save_and_close(self):
|
|
1408
|
+
'''
|
|
1409
|
+
Save and close
|
|
1410
|
+
:return:
|
|
1411
|
+
'''
|
|
1412
|
+
if __name__ == '__main__':
|
|
1413
|
+
self._frame.destroy()
|
|
1414
|
+
return
|
|
1415
|
+
if self._opt_results == {}:
|
|
1416
|
+
messagebox.showinfo(title='Nothing to return', message='No results to return.')
|
|
1417
|
+
return
|
|
1418
|
+
else:
|
|
1419
|
+
to_return = {}
|
|
1420
|
+
for line in self._active_lines:
|
|
1421
|
+
if self._opt_results[line][0] is not None:
|
|
1422
|
+
to_return[line] = self._opt_results[line]
|
|
1423
|
+
else:
|
|
1424
|
+
messagebox.showinfo(title='None in results, cannot return', message='None in results, c'
|
|
1425
|
+
'annot return values.')
|
|
1426
|
+
return
|
|
1427
|
+
|
|
1428
|
+
self.app.on_close_opt_multiple_window(to_return)
|
|
1429
|
+
messagebox.showinfo(title='Return info', message='Returning: '+str(list(to_return.keys())) +
|
|
1430
|
+
'\nLines without results are not returned.')
|
|
1431
|
+
|
|
1432
|
+
self._frame.destroy()
|
|
1433
|
+
|
|
1434
|
+
def toggle(self, found_files = None, obj = None, iterating = False):
|
|
1435
|
+
'''
|
|
1436
|
+
On off button.
|
|
1437
|
+
:param found_files:
|
|
1438
|
+
:param obj:
|
|
1439
|
+
:return:
|
|
1440
|
+
'''
|
|
1441
|
+
if iterating:
|
|
1442
|
+
if found_files is not None:
|
|
1443
|
+
predefined_structure = hlp.helper_read_section_file(files=found_files, obj=obj.Plate)
|
|
1444
|
+
else:
|
|
1445
|
+
predefined_structure = None
|
|
1446
|
+
if self._toggle_btn.config('relief')[-1] == 'sunken':
|
|
1447
|
+
self._toggle_btn.config(relief="raised")
|
|
1448
|
+
self._toggle_btn.config(bg = 'salmon')
|
|
1449
|
+
self._ent_spacing_upper.config(bg = 'white')
|
|
1450
|
+
self._ent_spacing_lower.config(bg = 'white')
|
|
1451
|
+
self._ent_delta_spacing.config(bg = 'white')
|
|
1452
|
+
else:
|
|
1453
|
+
self._toggle_btn.config(relief="sunken")
|
|
1454
|
+
self._toggle_btn.config(bg='lightgreen')
|
|
1455
|
+
self._ent_spacing_upper.config(bg = 'lightgreen')
|
|
1456
|
+
self._ent_spacing_lower.config(bg = 'lightgreen')
|
|
1457
|
+
self._ent_delta_spacing.config(bg = 'lightgreen')
|
|
1458
|
+
openfile = list(askopenfilenames(parent=self._frame, title='Choose files to open',
|
|
1459
|
+
initialdir=self._root_dir))
|
|
1460
|
+
if openfile == []:
|
|
1461
|
+
self._toggle_btn.config(relief="raised")
|
|
1462
|
+
self._toggle_btn.config(bg='salmon')
|
|
1463
|
+
self._ent_spacing_upper.config(bg='white')
|
|
1464
|
+
self._ent_spacing_lower.config(bg='white')
|
|
1465
|
+
self._ent_delta_spacing.config(bg='white')
|
|
1466
|
+
else:
|
|
1467
|
+
self._filez = openfile
|
|
1468
|
+
|
|
1469
|
+
return found_files, predefined_structure
|
|
1470
|
+
|
|
1471
|
+
def toggle_harmonizer(self):
|
|
1472
|
+
pass
|
|
1473
|
+
|
|
1474
|
+
def plot_results(self):
|
|
1475
|
+
if self._mid_click_line is not None:
|
|
1476
|
+
if len(self._opt_results[self._mid_click_line]) != 0:
|
|
1477
|
+
op.plot_optimization_results(self._opt_results[self._mid_click_line])
|
|
1478
|
+
|
|
1479
|
+
def mouse_scroll(self,event):
|
|
1480
|
+
self._canvas_scale += event.delta/50
|
|
1481
|
+
self._canvas_scale = 0 if self._canvas_scale < 0 else self._canvas_scale
|
|
1482
|
+
|
|
1483
|
+
self.draw_select_canvas()
|
|
1484
|
+
|
|
1485
|
+
def button_2_click_and_drag(self,event):
|
|
1486
|
+
|
|
1487
|
+
self._canvas_draw_origo = (self._canvas_draw_origo[0]-(self._previous_drag_mouse[0]-event.x),
|
|
1488
|
+
self._canvas_draw_origo[1]-(self._previous_drag_mouse[1]-event.y))
|
|
1489
|
+
|
|
1490
|
+
self._previous_drag_mouse = (event.x,event.y)
|
|
1491
|
+
self.draw_select_canvas()
|
|
1492
|
+
|
|
1493
|
+
def open_example_file(self):
|
|
1494
|
+
import os
|
|
1495
|
+
if os.path.isfile('sections.csv'):
|
|
1496
|
+
os.startfile('sections.csv')
|
|
1497
|
+
else:
|
|
1498
|
+
os.startfile(self._root_dir + '/' + 'sections.csv')
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
if __name__ == '__main__':
|
|
1502
|
+
root = tk.Tk()
|
|
1503
|
+
my_app = CreateOptimizeMultipleWindow(master=root)
|
|
1504
|
+
root.mainloop()
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|