@@ -65,7 +65,7 @@ class InputDataEntry(object):
6565 derivatives (`np.ndarray`): values of derivatives
6666 deriv_properties (`dict`): settings of derivatives
6767 """
68- def __init__ (self , var_name : str , var_idx : int , data_tensor : Union [List [np .ndarray ], np .ndarray ]):
68+ def __init__ (self , var_name : str , var_idx : int , data_tensor : Union [List [np .ndarray ], np .ndarray ], boundary ):
6969 self .var_name = var_name
7070 self .var_idx = var_idx
7171 if isinstance (data_tensor , np .ndarray ):
@@ -76,6 +76,7 @@ def __init__(self, var_name: str, var_idx: int, data_tensor: Union[List[np.ndarr
7676 assert all ([data_tensor [0 ].ndim == tensor .ndim for tensor in data_tensor ]), 'Mismatching dimensionalities of data tensors.'
7777 self .ndim = data_tensor [0 ].ndim
7878 self .data_tensor = data_tensor
79+ self .boundary = boundary
7980
8081
8182 def set_derivatives (self , preprocesser : PreprocessingPipe , deriv_tensors : Union [list , np .ndarray ] = None ,
@@ -135,6 +136,8 @@ def use_global_cache(self): # , var_idx: int, deriv_codes: list
135136 """
136137 var_idx = self .var_idx
137138 deriv_codes = self .d_orders
139+ self .data_tensor = self .data_tensor [self .boundary != 0 ]
140+ self .derivatives = np .array ([derivative [self .boundary .flatten () != 0 ] for derivative in self .derivatives .T ]).T
138141 derivs_stacked = prepare_var_tensor (self .data_tensor , self .derivatives ,
139142 time_axis = global_var .time_axis )
140143 deriv_codes = [(var_idx , code ) for code in deriv_codes ]
@@ -351,7 +354,7 @@ def set_memory_properties(self, example_tensor, mem_for_cache_frac=None, mem_for
351354 global_var .tensor_cache .memory_usage_properties (example_tensor , mem_for_cache_frac , mem_for_cache_abs )
352355
353356 def set_moeadd_params (self , population_size : int = 6 , solution_params : dict = {},
354- delta : float = 1 / 50. , neighbors_number : int = 3 ,
357+ H : int = 15 , neighbors_number : int = 3 ,
355358 nds_method : Callable = fast_non_dominated_sorting ,
356359 ndl_update_method : Callable = ndl_update ,
357360 subregion_mating_limitation : float = .95 ,
@@ -367,7 +370,7 @@ def set_moeadd_params(self, population_size: int = 6, solution_params: dict = {}
367370 The size of the population of solutions, created during MO - optimization, default 6.
368371 solution_params (`dict`): optional
369372 Dictionary, containing additional parameters to be sent into the newly created solutions.
370- delta (`float`): optional
373+ H (`float`): optional
371374 parameter of uniform spacing between the weight vectors; *H = 1 / delta*
372375 should be integer - a number of divisions along an objective coordinate axis.
373376 neighbors_number (`int`): *> 0*, optional
@@ -407,8 +410,8 @@ def set_moeadd_params(self, population_size: int = 6, solution_params: dict = {}
407410 Returns:
408411 None
409412 """
410- self .optimizer_init_params = {'weights_num' : population_size , ' pop_size' : population_size ,
411- 'delta ' : delta , 'neighbors_number' : neighbors_number ,
413+ self .optimizer_init_params = {'pop_size' : population_size ,
414+ 'H ' : population_size - 1 , 'neighbors_number' : neighbors_number ,
412415 'solution_params' : solution_params ,
413416 'nds_method' : nds_method ,
414417 'ndl_update' : ndl_update_method }
@@ -534,7 +537,12 @@ def uniformize(data):
534537 exponent = np .multiply .reduce (exponent_partial , axis = 0 )
535538 return exponent
536539
537- global_var .grid_cache .g_func = decorator (baseline_exp_function )
540+ def return_ones (grids ):
541+ ones_partial = np .array ([np .ones_like (grid ) for grid in grids ])
542+ ones = np .multiply .reduce (ones_partial , axis = 0 )
543+ return ones
544+ # global_var.grid_cache.g_func = decorator(baseline_exp_function)
545+ global_var .grid_cache .g_func = decorator (return_ones )
538546 else :
539547 global_var .grid_cache .g_func = decorator (function_form )
540548
@@ -671,7 +679,7 @@ def create_pool(self, data: Union[np.ndarray, list, tuple], variable_names=['u',
671679
672680 for data_elem_idx , data_tensor in enumerate (data ):
673681 entry = InputDataEntry (var_name = variable_names [data_elem_idx ], var_idx = data_elem_idx ,
674- data_tensor = data_tensor )
682+ data_tensor = data_tensor , boundary = self . cache [ 0 ]. g_func )
675683 derivs_tensor = derivs [data_elem_idx ] if derivs is not None else None
676684 entry .set_derivatives (preprocesser = self .preprocessor_pipeline , deriv_tensors = derivs_tensor ,
677685 grid = grid , max_order = max_deriv_order )
@@ -847,18 +855,16 @@ def _create_optimizer(multiobjective_mode: bool, optimizer_init_params: dict,
847855 opt_strategy_director : OptimizationPatternDirector ,
848856 population : List [SoEq ] = None , use_pic : bool = False ):
849857 if multiobjective_mode :
858+ best_sol_vals = [0. , 0. ] if use_pic else [0. , 1. ]
859+ optimizer_init_params ['best_sol_vals' ] = best_sol_vals
850860 optimizer_init_params ['passed_population' ] = population
851861 optimizer = MOEADDOptimizer (** optimizer_init_params )
852-
853- # if best_sol_vals is None:
854- best_sol_vals = [0. , 0. ] if use_pic else [0. , 1. ]
855- # best_sol_vals = [0., 0.] if use_pic else [0., 1.]
856-
857862 same_obj_count = sum ([1 for token_family in optimizer_init_params ['population_instruct' ]['pool' ].families
858863 if token_family .status ['demands_equation' ]])
859864 best_obj = np .concatenate ([np .full (same_obj_count , fill_value = fval ) for fval in best_sol_vals ])
860865 print ('best_obj' , len (best_obj ))
861- optimizer .pass_best_objectives (* best_obj )
866+ # optimizer.pass_best_objectives(*best_obj)
867+ optimizer .pass_best_objectives (* best_sol_vals )
862868 else :
863869 optimizer_init_params ['passed_population' ] = population
864870 optimizer = SimpleOptimizer (** optimizer_init_params )
0 commit comments