## 2 Materials and Methods
The fitting (optimization) process, whose simplified flow is shown on Figure 2, treats the model as a \"black box\" and varies the fittable parameters according to some algorithm, calling each time the compute method, in an attempt to find the global minimum in the least squares sense. As GISAXS models are complex and non-linear, it is not reasonable to pick \"one best\" optimization algorithm. Therefore, in accordance with the generic nature of the application, we have opted for the following approach: GisaxStudio provides a number of different optimization algorithms, and the user can try them all and decide to use those that perform best for their model. Thus, for the time being, the following eight optimization algorithms are included: BobyQA, Bounded Hooke and Jeeves, CMA-ES, Hooke and Jeeves, Nelder-Mead, Powell, Simulated Annealing, and Steady State GA (Figure 2). New algorithms can be easily added, much like the GISAXS model procedure described above: it is simply a matter of implementing the assigned interface and registering the algorithm; the application will then pick up the algorithm and include it in the fitting process. GisaxStudio instantiates the selected model's class and retrieves the parameter objects from that instance, which is then inspected via reflection to dynamically build the parameters dialog GUI. This dialog presents the last used values or default values, if it is being used for the first time. After the user sets the initial parameter values and selects the optimization algorithms (e.g., N = 4 in the Figure 2), the application creates N threads, one for each algorithm, provides them with copies of the model and parameters object, and starts the multi-threaded optimization. The main thread receives notifications from the optimization threads and waits for them to finish or to be interrupted by the user. The results are saved in the database as they arrive. Finally, when all the threads are finished,  
Figure 2: Fitting procedure in GisaxStudio: after the user selects the model and assigns initial values of the corresponding model, the application spawns N threads (corresponding to the number of chosen optimization algorithms) and initiates a multi-threaded optimization. When all the threads are finished (or interrupted by the user), the application visualizes the resulting winning algorithms. the best optimization result is selected, and a new tab with the visualizations of the winning algorithm, i.e., parameters, is automatically created. GisaxStudio features a project organization where one project, defined and named by the user, comprises of an arbitrary number of GISAXS images, which are stored in the projects/images subfolder of the application. All other data is stored in a JDBC-compliant (Java DataBase Connectivity) relational database: metadata about the images, regions of interest (ROIs), fits and parameters, results obtained with fits, etc. By default, the portable in-memory H2 Database Engine is used [42], although, any other JDBC-compliant database could be used. Note that a shared environment could also be easily configured by pointing the GisaxStudio to the shared database example, such as PostgreSQL in a local network or shared file system for images. However, for the sake of the simplicity, the default setup is single-user. Such setup allows for portability by simply copying the GisaxStudio folder, which usually contains images and database subfolders, to another computer, even if that computer features a different operating system.