Author: bugman Date: Tue Jul 22 13:36:33 2014 New Revision: 24600 URL: http://svn.gna.org/viewcvs/relax?rev=24600&view=rev Log: Major change to the grid search user function. The minimise.grid_search user function now accepts the skip_preset flag. When True, the grid search will skip any parameters with a preset value. This allows the user to set parameters via the value.set user function and then have these parameters skipped in the grid search. The new skip_preset argument is passed into the pipe_control.minimise.grid_setup() function in the backend. This then sets both the grid lower and upper bounds to the preset parameter value and sets the number of increments to 1 for that parameter so that it is essentially skipped in the grid search. Modified: branches/zooming_grid_search/pipe_control/minimise.py branches/zooming_grid_search/user_functions/minimisation.py Modified: branches/zooming_grid_search/pipe_control/minimise.py URL: http://svn.gna.org/viewcvs/relax/branches/zooming_grid_search/pipe_control/minimise.py?rev=24600&r1=24599&r2=24600&view=diff ============================================================================== --- branches/zooming_grid_search/pipe_control/minimise.py (original) +++ branches/zooming_grid_search/pipe_control/minimise.py Tue Jul 22 13:36:33 2014 @@ -137,7 +137,7 @@ processor.run_queue() -def grid_search(lower=None, upper=None, inc=None, verbosity=1, constraints=True): +def grid_search(lower=None, upper=None, inc=None, verbosity=1, constraints=True, skip_preset=True): """The grid search function. @keyword lower: The lower bounds of the grid search which must be equal to the number of parameters in the model. @@ -150,6 +150,8 @@ @type verbosity: int @keyword constraints: If True, constraints are applied during the grid search (elinating parts of the grid). If False, no constraints are used. @type constraints: bool + @keyword skip_preset: This argument, when True, allows any parameter which already has a value set to be skipped in the grid search. + @type skip_preset: bool """ # Test if the current data pipe exists. @@ -162,7 +164,7 @@ api.overfit_deselect() # Determine the model specific grid bounds, and allow for the zooming grid search, and check the inc argument. - model_lower, model_upper, model_inc = grid_setup(lower, upper, inc, verbosity=verbosity) + model_lower, model_upper, model_inc = grid_setup(lower, upper, inc, verbosity=verbosity, skip_preset=skip_preset) # Create the scaling matrix. scaling_matrix = assemble_scaling_matrix() @@ -202,19 +204,21 @@ processor.run_queue() -def grid_setup(lower=None, upper=None, inc=None, verbosity=1): +def grid_setup(lower=None, upper=None, inc=None, verbosity=1, skip_preset=True): """Determine the per-model grid bounds, allowing for the zooming grid search. - @keyword lower: The user supplied lower bounds of the grid search which must be equal to the number of parameters in the model. - @type lower: list of numbers - @keyword upper: The user supplied upper bounds of the grid search which must be equal to the number of parameters in the model. - @type upper: list of numbers - @keyword inc: The user supplied grid search increments. - @type inc: int or list of int - @keyword verbosity: The amount of information to print. The higher the value, the greater the verbosity. - @type verbosity: int - @return: The per-model grid upper and lower bounds. The first dimension of each structure corresponds to the model, the second the model parameters. - @rtype: tuple of lists of lists of float, lists of lists of float, list of lists of int + @keyword lower: The user supplied lower bounds of the grid search which must be equal to the number of parameters in the model. + @type lower: list of numbers + @keyword upper: The user supplied upper bounds of the grid search which must be equal to the number of parameters in the model. + @type upper: list of numbers + @keyword inc: The user supplied grid search increments. + @type inc: int or list of int + @keyword verbosity: The amount of information to print. The higher the value, the greater the verbosity. + @type verbosity: int + @keyword skip_preset: This argument, when True, allows any parameter which already has a value set to be skipped in the grid search. + @type skip_preset: bool + @return: The per-model grid upper and lower bounds. The first dimension of each structure corresponds to the model, the second the model parameters. + @rtype: tuple of lists of lists of float, lists of lists of float, list of lists of int """ # The specific analysis API object and parameter object. @@ -290,7 +294,11 @@ else: upper_i = param_object.grid_upper(names[i], model_info=model_info) - # The scaling factor. + # Skip preset values. + if skip_preset and values[i] != None: + lower_i = values[i] + upper_i = values[i] + model_inc[-1][i] = 1 # Scale the bounds. scaling = param_object.scaling(names[i], model_info=model_info) Modified: branches/zooming_grid_search/user_functions/minimisation.py URL: http://svn.gna.org/viewcvs/relax/branches/zooming_grid_search/user_functions/minimisation.py?rev=24600&r1=24599&r2=24600&view=diff ============================================================================== --- branches/zooming_grid_search/user_functions/minimisation.py (original) +++ branches/zooming_grid_search/user_functions/minimisation.py Tue Jul 22 13:36:33 2014 @@ -97,6 +97,13 @@ py_type = "bool", desc_short = "constraints flag", desc = "A boolean flag specifying whether the parameters should be constrained. The default is to turn constraints on (constraints=True)." +) +uf.add_keyarg( + name = "skip_preset", + default = True, + py_type = "bool", + desc_short = "skip preset parameter flag", + desc = "This argument, when True, allows any parameter which already has a value set to be skipped in the grid search." ) # Description. uf.desc.append(Desc_container())