26
26
27
27
class MonteCarlo (MonteCarlo_orig ):
28
28
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 )
37
32
33
+ def MultiRunOptimize (self , nb_run : int , nb_step : int , final_cost = 0 , max_time = - 1 ):
34
+ self ._fix_parameters_for_global_optim ()
38
35
super ().MultiRunOptimize (int (nb_run ), int (nb_step ), True , final_cost , max_time )
39
36
40
37
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 ()
49
39
super ().RunSimulatedAnnealing (int (nb_step ), True , final_cost , max_time )
50
40
51
41
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 ):
52
46
# Fix parameters that should not be optimised in a MonterCarlo run
53
47
self .SetParIsFixed (refpartype_unitcell , True );
54
48
self .SetParIsFixed (refpartype_scattdata_scale , True );
@@ -57,7 +51,6 @@ def RunParallelTempering(self, nb_step: int, final_cost=0, max_time=-1):
57
51
self .SetParIsFixed (refpartype_scattdata_background , True );
58
52
self .SetParIsFixed (refpartype_scattdata_radiation , True );
59
53
60
- super ().RunParallelTempering (int (nb_step ), True , final_cost , max_time )
61
54
62
55
def UpdateDisplay (self ):
63
56
if self .IsOptimizing ():
0 commit comments