Job Dictionary ============== A Job dictionary is maintained by each worker during execution of the codes list (defined in the the configuration file. The purpose of the Job dictionary is to provide a mutable object that user's can read from and write to if they are using preprocessing or postprocessing functions to make modifications between simulations in the code list. The Job dictionary is also passed to the objective function to provide information about the final state of the job. The Job dictionary will always contain several pre-populated fields containing information about the state of the job. These can be read from or even overwritten by the pre/postprocess functions. However, in the latter case caution is advised as this can certainly break the rsopt run if not done properly. Pre-populated fields are: - `inputs`: This is a dictionary of parameters and settings for the job being run. This is populated for each job before preprocess is called. Because any inputs files are written after preprocess is called this allows users to make modifications or additions to the `inputs` dictionary. This is useful setting covariables in particular. An example of covariable setting is shown below: .. code-block:: python :linenos: # Before preprocess is called let the state of J, set by rsopt be: J = {'inputs': # Our simulation function has one variable 'x' that has been assigned a value already {'x': 5.0} } .. code-block:: python :linenos: def my_preprocess(J): # Let's say we want a linear relationship between the variable 'x' which is being set by # rsopt directly and another input variable in the simulation 'y'. This can't be written # into the rsopt configuration file but we can enforce it here. If we write a value for 'y' # into J['inputs'] it will be passed to the simulation function. # Current value of x x = J['inputs']['x'] # Set y based on a linear relationship with x y = 3 * x # Create an entry for y in the Job dictionary inputs field J['inputs']['y'] = y # No return value needs to be set for pre/postprocess functions - `rand_stream`: Holds a numpy.Generator (Generators_) object for each worker. This can allow processes on the worker to generate unique, random numbers. See `seed` under :doc:`Options