37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import numpy as np
|
|
|
|
# Функция для масштабирования значений дизайна
|
|
def scale_design(design, param_ranges):
|
|
scaled_design = []
|
|
for row in design:
|
|
scaled_row = []
|
|
for i, val in enumerate(row):
|
|
min_val, max_val = param_ranges[list(param_ranges.keys())[i]]
|
|
scaled_val = (val + 1) / 2 * (max_val - min_val) + min_val
|
|
scaled_row.append(scaled_val)
|
|
scaled_design.append(scaled_row)
|
|
return np.array(scaled_design)
|
|
|
|
|
|
def scale_design_lhs(design, param_ranges):
|
|
scaled_design = []
|
|
for row in design:
|
|
scaled_row = []
|
|
for i, val in enumerate(row):
|
|
min_val, max_val = param_ranges[list(param_ranges.keys())[i]]
|
|
scaled_val = val * (max_val - min_val) + min_val
|
|
scaled_row.append(scaled_val)
|
|
scaled_design.append(scaled_row)
|
|
return np.array(scaled_design)
|
|
|
|
|
|
# Функция для округления значений
|
|
def round_by_index(array, rules):
|
|
rounded_array = np.zeros(array.shape)
|
|
for i in range(array.shape[0]):
|
|
for j in range(array.shape[1]):
|
|
rounded_array[i, j] = round(array[i, j], rules[j])
|
|
return rounded_array
|
|
|
|
|