2626
2727class MonteCarlo (MonteCarlo_orig ):
2828
29- def MultiRunOptimize (self , nb_run : int , nb_step : int , final_cost = 0 , max_time = - 1 ):
30- # Fix parameters that should not be optimised in a MonterCarlo run
31- self .SetParIsFixed (refpartype_unitcell , True );
32- self .SetParIsFixed (refpartype_scattdata_scale , True );
33- self .SetParIsFixed (refpartype_scattdata_profile , True );
34- self .SetParIsFixed (refpartype_scattdata_corr , True );
35- self .SetParIsFixed (refpartype_scattdata_background , True );
36- self .SetParIsFixed (refpartype_scattdata_radiation , True );
29+ def Optimize (self , nb_step : int , final_cost = 0 , max_time = - 1 ):
30+ self ._fix_parameters_for_global_optim ()
31+ super ().Optimize (int (nb_step ), True , final_cost , max_time )
3732
33+ def MultiRunOptimize (self , nb_run : int , nb_step : int , final_cost = 0 , max_time = - 1 ):
34+ self ._fix_parameters_for_global_optim ()
3835 super ().MultiRunOptimize (int (nb_run ), int (nb_step ), True , final_cost , max_time )
3936
4037 def RunSimulatedAnnealing (self , nb_step : int , final_cost = 0 , max_time = - 1 ):
41- # Fix parameters that should not be optimised in a MonterCarlo run
42- self .SetParIsFixed (refpartype_unitcell , True );
43- self .SetParIsFixed (refpartype_scattdata_scale , True );
44- self .SetParIsFixed (refpartype_scattdata_profile , True );
45- self .SetParIsFixed (refpartype_scattdata_corr , True );
46- self .SetParIsFixed (refpartype_scattdata_background , True );
47- self .SetParIsFixed (refpartype_scattdata_radiation , True );
48-
38+ self ._fix_parameters_for_global_optim ()
4939 super ().RunSimulatedAnnealing (int (nb_step ), True , final_cost , max_time )
5040
5141 def RunParallelTempering (self , nb_step : int , final_cost = 0 , max_time = - 1 ):
42+ self ._fix_parameters_for_global_optim ()
43+ super ().RunParallelTempering (int (nb_step ), True , final_cost , max_time )
44+
45+ def _fix_parameters_for_global_optim (self ):
5246 # Fix parameters that should not be optimised in a MonterCarlo run
5347 self .SetParIsFixed (refpartype_unitcell , True );
5448 self .SetParIsFixed (refpartype_scattdata_scale , True );
@@ -57,7 +51,6 @@ def RunParallelTempering(self, nb_step: int, final_cost=0, max_time=-1):
5751 self .SetParIsFixed (refpartype_scattdata_background , True );
5852 self .SetParIsFixed (refpartype_scattdata_radiation , True );
5953
60- super ().RunParallelTempering (int (nb_step ), True , final_cost , max_time )
6154
6255 def UpdateDisplay (self ):
6356 if self .IsOptimizing ():
0 commit comments