22"""
33Network model optimization script for optimization with dmosopt
44"""
5-
5+ import gc
66import os
77import sys
88import datetime
@@ -410,9 +410,9 @@ def compute_objectives(local_features, operational_config, opt_targets):
410410 sum_mean_rate_local += mean_rate
411411 ip_rate = np .interp (
412412 fr_time_centers ,
413- dens_dict [ "time" ]. astype ( np . float32 ) ,
413+ time_bins_ref ,
414414 dens_dict ["rate" ].astype (np .float32 ),
415- )
415+ ). astype ( np . float32 )
416416 active_per_bin = ip_rate > active_threshold
417417 sum_active_per_bin += active_per_bin
418418
@@ -439,17 +439,19 @@ def compute_objectives(local_features, operational_config, opt_targets):
439439 )
440440
441441 all_features_dict [f"{ pop_name } mean fraction active per time bin" ] = (
442- mean_fraction_active_per_bin
442+ float ( mean_fraction_active_per_bin )
443443 )
444444 all_features_dict [f"{ pop_name } std fraction active per time bin" ] = (
445- std_fraction_active_per_bin
445+ float ( std_fraction_active_per_bin )
446446 )
447- all_features_dict [f"{ pop_name } fraction active" ] = fraction_active
448- all_features_dict [f"{ pop_name } firing rate" ] = mean_rate
447+ all_features_dict [f"{ pop_name } fraction active" ] = float ( fraction_active )
448+ all_features_dict [f"{ pop_name } firing rate" ] = float ( mean_rate )
449449
450450 rate_constr = mean_rate if mean_rate > 0.0 else - 1.0
451451 constraints .append (rate_constr )
452452
453+ gc .collect ()
454+
453455 objective_names = operational_config ["objective_names" ]
454456 feature_dtypes = [(feature_name , np .float32 ) for feature_name in objective_names ]
455457
@@ -470,7 +472,7 @@ def compute_objectives(local_features, operational_config, opt_targets):
470472 features .append (feature_val )
471473
472474 result = (
473- np .asarray (objectives ),
475+ np .asarray (objectives , dtype = np . float32 ),
474476 np .array ([tuple (features )], dtype = np .dtype (feature_dtypes )),
475477 np .asarray (constraints , dtype = np .float32 ),
476478 )
0 commit comments