Find the starting lattice parameters using MILK

Until now in this tutorial we have focused on a general problem. Now we will apply what we have done to a Rietveld analysis.

The key concepts you should gain from this page:

  • How to create a surrogate model of an expensive cost function and use the surrogate model to guide the optimization.

Note, you are going to need the data and ``template.par`` from the MILK XRD tutorial. If running from the notebook, you will need this data directory and parameter file in the same location as you run the notebook.

Define cost function using MILK

In our prior problems, we defined a cost function to optimize which was a simple Python function. For using a program like MAUD which writes files to disk we need to make sure each optimizer has its own directory set up for itself. Otherwise different optimizers would be overwriting each other in the same directory.

Therefore, we are going to create a slightly more complicated cost function using the AbstractFunction class from Mystic. The analagous function to our prior cost functions is CostFunction.function below. Our CostFunction.function calls CostFunction.initialize and CostFunction.cost_function.

MILK will want to setup a directory with files that are read by MAUD. This is only called once at the beginning. Therefore, there is an CostFunciton.initialize function which is called once at the very beginning of an optimization. This initialize simply sets up the directory (e.g. copy needed files). We name the directory after the processor’s name.

Then there is the CostFunction.cost_function which sets the lattice parameters using MILK, does a refinement step, and returns the R-factor. This is called for every parameter set in the optimization.

Note, you will need to make one change below. You will need to change the path to the template.par file that is being copied below. It will exist from the MILK tutorial. You’d really want to pass this as an attribute on the class but for the sake of brevity we will edit the line here in place.

[5]:
import MILK
import multiprocess
import os
import shutil
import time
from mystic import models
from spotlight import filesystem

class CostFunction(models.AbstractFunction):

    def __init__(self, ndim=None, config=None):
        super().__init__(ndim=ndim)
        self.initialized = False
        self.config = config

    def reset(self):
        self.initialized = False

    def function(self, p):
        if not self.initialized:
            self.initialize()
            self.initialized = True
        return self.cost_function(p)

    def initialize(self):

        # get editor and maudText
        self.editor = MILK.parameterEditor.editor()
        self.editor.parseConfig(config)
        self.maudText = MILK.maud.maudText()
        self.maudText.parseConfig(config)

        # set run dir based on process name
        self.editor.run_dirs = f"opt_{multiprocess.current_process().name}"
        self.maudText.run_dirs = self.editor.run_dirs

        # create run dir
        if os.path.exists(self.editor.run_dirs):
            shutil.rmtree(self.editor.run_dirs)
        filesystem.mkdir(self.editor.run_dirs)
        filesystem.cp(["/Users/cmbiwer/src/milk/synchrotron/sequential_refinement/template.par"], dest=self.editor.run_dirs) # CHANGE THIS LINE

        # set initial phase fractions
        self.editor.set_val(key='_pd_phase_atom_', value='0.33')
        self.editor.free(key='_pd_phase_atom_', wild=[0])

    def cost_function(self, p):

        t0 = time.time()

        # set lattice parameters as values from optimization
        self.editor.set_val(key='cell_length_a', sobj="alpha", value=str(p[0]))
        self.editor.set_val(key='cell_length_c', sobj="alpha", value=str(p[1]))
        self.editor.set_val(key='cell_length_a', sobj="steel", value=str(p[2]))
        self.editor.set_val(key='cell_length_c', sobj="beta", value=str(p[3]))

        # refine
        self.maudText.refinement(itr='1', ifile=self.editor.ifile, ofile=self.editor.ofile, simple_call=True)

        # get the statistic to return to the optimizer
        self.editor.get_val(key="_refine_ls_wR_factor_all")
        stat = float(self.editor.value[0])

        print(f"Our R-factor is {stat} and it took {time.time() - t0}s to compute")

        return stat

Configure MILK

We will also need to configure MILK for our refinement. The following is an example of setting MILK to use the MILK XRD Tutorial dataset. For more documentation on the settings of these parameters, see the MILK tutorial.

[9]:
# set MILK configuration
config = {"folders": {"work_dir": "",
                      "run_dirs": "ack(wild)",
                      "sub_dir": "",
                      "wild": [0],
                      "wild_range": [[]],
          },
          "compute": {"maud_path": "",
                      "n_maud": 1,
                      "java_opt": "Xmx8G",
                      "clean_old_step_data": False,
                      "cur_step": 1,
                      "log_consol": False,
          },
          "ins": {"riet_analysis_file": "template.par",
                  "riet_analysis_fileToSave": "output.par",
                  "section_title": "Ti64_test_data",
                  "analysis_iteration_number": 4,
                  "LCLS2_detector_config_file": "",
                  "LCLS2_Cspad0_original_image": "",
                  "LCLS2_Cspad0_dark_image": "",
                  "output_plot2D_filename": "plot_",
                  "output_summed_data_filename": "all_spectra",
                  "maud_output_plot_filename": "plot1d_",
                  "output_PF_filename": "PF_",
                  "output_PF": "",
                  "append_simple_result_to": "tmp_simple_results.txt",
                  "append_result_to": "tmp_results.txt",
                  "import_phase": [],
                  "ins_file_name": "MAUDText.ins",
                  "maud_remove_all_datafiles": True,
                  "verbose": 0,
          },
          "interface": {"verbose": 0,
          },
}

Finding the starting lattice parameters of a Rietveld analysis by optimizing a surrogate model

In the prior page of the tutorial, we went over how to find the global minimum of using a surrogate model. Recall, that we constructed an interpolated model using the InterpModel and then minimized until our surrogate and cost function reached <0.001 difference.

Applying this to Rietveld analysis, the global minimum is the best fit parameters for our data. Below, we follow the same pattern using InterpModel to create an interpolated surrogate model. In the while loop we continuously update the surrogate model, find the minimum of the surrogate model, then evaluate that minimum using our actual cost function (CostFunction.function above) using MILK, and continue until we are below a threshold of agreement between the surrogate model and the actual cost function.

Recall, we introduced this approach because we were able to find a minimum with fewer calls to the actual cost function. In this case, a call to MILK may take several seconds and in an optimization algorithm calling that hundreds or thousands of times, the time can be hours.

[10]:
from mystic import tools
from mystic.solvers import diffev2
from mystic.math.legacydata import dataset, datapoint
from spotlight.bridge.ouq_models import WrapModel
from spotlight.bridge.ouq_models import InterpModel

# set random seed so we can reproduce results
tools.random_seed(0)

# set bounds for parameters to be +/-5%
target = [2.9306538, 4.6817646, 3.6026807, 3.233392]
lower_bounds = [x * 0.95 for x in target]
upper_bounds = [x * 1.05 for x in target]

# remove prior cached results
if os.path.exists("surrogate"):
    shutil.rmtree("surrogate")

# generate a sampled dataset for the model
truth = WrapModel("surrogate", CostFunction(4), nx=4, ny=None, cached=False)
bounds = list(zip(lower_bounds, upper_bounds))
data = truth.sample(bounds, pts=[2, 1, 1, 1])

# create surrogate model
surrogate = InterpModel("surrogate", nx=4, ny=None, data=truth, smooth=0.0, noise=0.0,
                        method="thin_plate", extrap=False)

# go until error < 1e-3
error = float("inf")
sign = 1.0
while error > 1e-3:

    # fit surrogate data
    surrogate.fit(data=data)

    # find minimum/maximum of surrogate
    results = diffev2(lambda x: sign * surrogate(x), bounds, npop=20,
                      bounds=bounds, gtol=500, full_output=True)

    # get minimum/maximum of actual expensive model
    xnew = results[0].tolist()
    ynew = truth(xnew)

    # compute error which is actual model value - surrogate model value
    ysur = results[1]
    error = abs(ynew - ysur)

    # print statements
    print("truth", xnew, ynew)
    print("surrogate", xnew, ysur)
    print("error", ynew - ysur, error)
    print("data", len(data))

    # add latest evaulated point with actual expensive model to be used by surrogate in fitting
    pt = datapoint(xnew, value=ynew)
    data.append(pt)

# print the best parameters
print(f"The best solution is {xnew} with Rwp {ynew}")
print(f"The reference solutions is {target}")
ratios = [x / y for x, y in zip(target, xnew)]
print(f"The ratios of to the reference values are {ratios}")
Our R-factor is 0.5236905 and it took 7.50351881980896s to compute
Our R-factor is 0.5224805 and it took 8.983762264251709s to compute
Optimization terminated successfully.
         Current function value: 0.355938
         Iterations: 519
         Function evaluations: 10400
Our R-factor is 0.13660918 and it took 9.30555510520935s to compute
truth [2.9308146307795577, 4.681764598938253, 3.6026807000821934, 3.233392000478879] 0.13660918
surrogate [2.9308146307795577, 4.681764598938253, 3.6026807000821934, 3.233392000478879] 0.35593774110718646
error -0.21932856110718646 0.21932856110718646
data 2
Optimization terminated successfully.
         Current function value: 0.136609
         Iterations: 516
         Function evaluations: 10340
Our R-factor is 0.13658616 and it took 9.485702991485596s to compute
truth [2.930790877829773, 4.681764598967135, 3.6026807000709002, 3.2333920002603103] 0.13658616
surrogate [2.930790877829773, 4.681764598967135, 3.6026807000709002, 3.2333920002603103] 0.136609048827414
error -2.2888827413997115e-05 2.2888827413997115e-05
data 3
The best solution is [2.930790877829773, 4.681764598967135, 3.6026807000709002, 3.2333920002603103] with Rwp 0.13658616
The reference solutions is [2.9306538, 4.6817646, 3.6026807, 3.233392]
The ratios of to the reference values are [0.9999532283825469, 1.0000000002206146, 0.9999999999803202, 0.9999999999194931]

An ensemble using only the cost function

As state above, the call to MILK may take several seconds. Below, we present an example of using an ensemble of optimizers in parallel with MILK to find the global minimum. Note, this will take awhile. It depends on the number of processors available on your machine. We set the number of function calls to 50 to limit the amount of time it will take.

[4]:
from mystic.solvers import LatticeSolver
from mystic.solvers import NelderMeadSimplexSolver
from mystic.termination import VTR
from pathos.pools import ProcessPool as Pool

# set the ranges
target = [2.9306538, 4.6817646, 3.6026807, 3.233392]
lower_bounds = [x * 0.95 for x in target]
upper_bounds = [x * 1.05 for x in target]

# set random seed so we can reproduce results
tools.random_seed(0)

# create a solver
solver = LatticeSolver(4, 8)

# set multi-processing pool
solver.SetMapper(Pool().map)

# since we have an search solver
# we specify what optimization algorithm to use within the search
# we tell the optimizer to not go more than 50 evaluations of our cost function
subsolver = NelderMeadSimplexSolver(4)
subsolver.SetEvaluationLimits(50, 50)
solver.SetNestedSolver(subsolver)

# set the range to search for all parameters
solver.SetStrictRanges(lower_bounds, upper_bounds)

# find the minimum
solver.Solve(CostFunction(4), VTR())

# print the best parameters
print(f"The best solution is {solver.bestSolution} with Rwp {solver.bestEnergy}")
print(f"The reference solutions is {target}")
ratios = [x / y for x, y in zip(target, solver.bestSolution)]
print(f"The ratios of to the reference values are {ratios}")
Our R-factor is 0.62775004 and it took 25.128027200698853s to compute
Our R-factor is 0.62282383 and it took 25.271618843078613s to compute
Our R-factor is 0.6246426 and it took 25.542072057724s to compute
Our R-factor is 0.62601537 and it took 25.940300941467285s to compute
Our R-factor is 0.62909144 and it took 25.969143867492676s to compute
Our R-factor is 0.62771976 and it took 25.905327081680298s to compute
Our R-factor is 0.6299428 and it took 26.132752895355225s to compute
Our R-factor is 0.62489647 and it took 26.110680103302002s to compute
Our R-factor is 0.6315842 and it took 28.788614988327026s to compute
Our R-factor is 0.6268012 and it took 28.909955739974976s to compute
Our R-factor is 0.62726223 and it took 28.60523295402527s to compute
Our R-factor is 0.62239444 and it took 29.202092170715332s to compute
Our R-factor is 0.6244521 and it took 29.22259497642517s to compute
Our R-factor is 0.62854445 and it took 28.962391138076782s to compute
Our R-factor is 0.62731254 and it took 29.01335597038269s to compute
Our R-factor is 0.63111085 and it took 29.39300775527954s to compute
Our R-factor is 0.62772155 and it took 29.795593976974487s to compute
Our R-factor is 0.62280476 and it took 30.00866389274597s to compute
Our R-factor is 0.6253105 and it took 29.78557586669922s to compute
Our R-factor is 0.6219639 and it took 29.65451216697693s to compute
Our R-factor is 0.6207021 and it took 30.169905185699463s to compute
Our R-factor is 0.62776387 and it took 30.023957014083862s to compute
Our R-factor is 0.61914897 and it took 30.169998168945312s to compute
Our R-factor is 0.62558246 and it took 30.510261058807373s to compute
Our R-factor is 0.6277215 and it took 28.235476970672607s to compute
Our R-factor is 0.6296847 and it took 28.889330863952637s to compute
Our R-factor is 0.6248709 and it took 28.31453013420105s to computeOur R-factor is 0.62462074 and it took 28.573387145996094s to compute

Our R-factor is 0.62101555 and it took 29.16654372215271s to compute
Our R-factor is 0.6299166 and it took 28.84225583076477s to compute
Our R-factor is 0.6276742 and it took 28.731493949890137s to compute
Our R-factor is 0.62991416 and it took 28.82644510269165s to compute
Our R-factor is 0.63183326 and it took 28.13518524169922s to compute
Our R-factor is 0.6259669 and it took 27.94691777229309s to compute
Our R-factor is 0.5978862 and it took 28.099269151687622s to compute
Our R-factor is 0.6233406 and it took 28.259334325790405s to compute
Our R-factor is 0.62904215 and it took 28.346415281295776s to compute
Our R-factor is 0.62598616 and it took 28.606606006622314s to compute
Our R-factor is 0.6260116 and it took 28.38180112838745s to compute
Our R-factor is 0.596247 and it took 28.248419046401978s to compute
Our R-factor is 0.62439287 and it took 28.703832149505615s to compute
Our R-factor is 0.5707121 and it took 29.010292291641235s to compute
Our R-factor is 0.62686974 and it took 29.816482067108154s to compute
Our R-factor is 0.60720766 and it took 30.030110120773315s to compute
Our R-factor is 0.62320924 and it took 29.31212282180786s to computeOur R-factor is 0.59561723 and it took 30.228066205978394s to compute

Our R-factor is 0.506816 and it took 29.505657196044922s to compute
Our R-factor is 0.61674464 and it took 30.102020025253296s to compute
Our R-factor is 0.6276685 and it took 29.8854079246521s to compute
Our R-factor is 0.6245777 and it took 29.4092538356781s to compute
Our R-factor is 0.5813932 and it took 29.152310848236084s to compute
Our R-factor is 0.61411625 and it took 30.116770029067993s to computeOur R-factor is 0.5053825 and it took 29.543763875961304s to compute

Our R-factor is 0.53299284 and it took 29.908063888549805s to compute
Our R-factor is 0.5968382 and it took 30.00417923927307s to compute
Our R-factor is 0.61414844 and it took 30.521706104278564s to compute
Our R-factor is 0.6148825 and it took 29.4566912651062s to compute
Our R-factor is 0.62430733 and it took 29.096557140350342s to compute
Our R-factor is 0.62974656 and it took 28.810867071151733s to compute
Our R-factor is 0.581268 and it took 28.283952951431274s to compute
Our R-factor is 0.50335723 and it took 29.52289581298828s to compute
Our R-factor is 0.597314 and it took 29.55278992652893s to compute
Our R-factor is 0.6203418 and it took 29.669891119003296s to compute
Our R-factor is 0.6284499 and it took 29.187716007232666s to compute
Our R-factor is 0.63120455 and it took 28.814802169799805s to compute
Our R-factor is 0.583726 and it took 28.975887775421143s to compute
Our R-factor is 0.5686507 and it took 29.586962938308716s to compute
Our R-factor is 0.6214975 and it took 29.80842900276184s to compute
Our R-factor is 0.6060333 and it took 29.194419860839844s to compute
Our R-factor is 0.60949284 and it took 29.33279013633728s to compute
Our R-factor is 0.63119304 and it took 30.145761728286743s to compute
Our R-factor is 0.5973132 and it took 30.315383195877075s to compute
Our R-factor is 0.6260943 and it took 28.539926052093506s to compute
Our R-factor is 0.44459608 and it took 28.73621702194214s to compute
Our R-factor is 0.54051113 and it took 29.095885276794434s to compute
Our R-factor is 0.6284504 and it took 28.953223943710327s to compute
Our R-factor is 0.62091875 and it took 28.761669158935547s to compute
Our R-factor is 0.58379096 and it took 28.39779305458069s to compute
Our R-factor is 0.524414 and it took 28.991307020187378s to compute
Our R-factor is 0.49530402 and it took 29.491591930389404s to compute
Our R-factor is 0.6220623 and it took 28.843047857284546s to compute
Our R-factor is 0.612329 and it took 29.013646841049194s to compute
Our R-factor is 0.59003234 and it took 28.98677897453308s to compute
Our R-factor is 0.605098 and it took 29.700284957885742s to compute
Our R-factor is 0.6268338 and it took 29.058008193969727s to compute
Our R-factor is 0.51960504 and it took 29.311029195785522s to compute
Our R-factor is 0.59769535 and it took 29.943910121917725s to compute
Our R-factor is 0.6167906 and it took 30.230716228485107s to compute
Our R-factor is 0.6286403 and it took 30.615038871765137s to compute
Our R-factor is 0.5149413 and it took 30.203970193862915s to compute
Our R-factor is 0.6185733 and it took 30.410999059677124s to compute
Our R-factor is 0.5559126 and it took 29.532055139541626s to compute
Our R-factor is 0.60688806 and it took 30.493600130081177s to compute
Our R-factor is 0.5627698 and it took 30.44427227973938s to compute
Our R-factor is 0.53858185 and it took 30.751601934432983s to compute
Our R-factor is 0.62155366 and it took 29.741541862487793s to compute
Our R-factor is 0.62652326 and it took 28.085896968841553s to compute
Our R-factor is 0.53627247 and it took 28.551371097564697s to compute
Our R-factor is 0.55493337 and it took 28.897735834121704s to compute
Our R-factor is 0.563386 and it took 27.96470880508423s to compute
Our R-factor is 0.54439175 and it took 28.928460121154785s to compute
Our R-factor is 0.62395895 and it took 27.655612230300903s to compute
Our R-factor is 0.6283384 and it took 29.033025979995728s to compute
Our R-factor is 0.49718332 and it took 29.10969305038452s to compute
Our R-factor is 0.62956667 and it took 28.34769105911255s to compute
Our R-factor is 0.6217048 and it took 28.888397216796875s to compute
Our R-factor is 0.6263268 and it took 29.569726943969727s to compute
Our R-factor is 0.6299269 and it took 29.314748764038086s to compute
Our R-factor is 0.588658 and it took 28.77377414703369s to compute
Our R-factor is 0.6093285 and it took 29.54270315170288s to compute
Our R-factor is 0.5422369 and it took 29.582297801971436s to compute
Our R-factor is 0.5603967 and it took 29.353999137878418s to compute
Our R-factor is 0.623904 and it took 29.385688066482544s to compute
Our R-factor is 0.57149005 and it took 28.649491786956787s to compute
Our R-factor is 0.58554095 and it took 29.033406019210815s to compute
Our R-factor is 0.43365213 and it took 29.682419776916504s to compute
Our R-factor is 0.60934806 and it took 29.285374879837036s to compute
Our R-factor is 0.5420738 and it took 29.89745593070984s to compute
Our R-factor is 0.5943767 and it took 29.738141298294067s to compute
Our R-factor is 0.6006289 and it took 30.29346990585327s to compute
Our R-factor is 0.6260417 and it took 28.366052865982056s to compute
Our R-factor is 0.6038816 and it took 28.739644765853882s to compute
Our R-factor is 0.592987 and it took 27.977646827697754s to compute
Our R-factor is 0.6127648 and it took 28.581695079803467s to compute
Our R-factor is 0.6306583 and it took 28.793065071105957s to compute
Our R-factor is 0.5841003 and it took 27.96793484687805s to compute
Our R-factor is 0.43987775 and it took 28.77456521987915s to compute
Our R-factor is 0.5238677 and it took 28.796834707260132s to compute
Our R-factor is 0.57103854 and it took 28.801408052444458s to compute
Our R-factor is 0.529194 and it took 29.039142847061157s to compute
Our R-factor is 0.6119143 and it took 28.593602180480957s to compute
Our R-factor is 0.4529906 and it took 28.55851101875305s to compute
Our R-factor is 0.58588296 and it took 28.5413658618927s to compute
Our R-factor is 0.5235038 and it took 29.56419038772583s to compute
Our R-factor is 0.5471492 and it took 29.079451084136963s to compute
Our R-factor is 0.29925475 and it took 30.810696840286255s to compute
Our R-factor is 0.5505663 and it took 29.22908115386963s to compute
Our R-factor is 0.6148156 and it took 29.070342779159546s to compute
Our R-factor is 0.5982137 and it took 28.688766956329346s to compute
Our R-factor is 0.62687564 and it took 29.051246166229248s to compute
Our R-factor is 0.6144637 and it took 29.190579891204834s to compute
Our R-factor is 0.60524464 and it took 29.116466999053955s to compute
Our R-factor is 0.5022469 and it took 29.28687071800232s to compute
Our R-factor is 0.5696043 and it took 30.463324785232544s to compute
Our R-factor is 0.4816528 and it took 29.674470901489258s to compute
Our R-factor is 0.5075125 and it took 30.064881086349487s to compute
Our R-factor is 0.5154543 and it took 30.070386171340942s to computeOur R-factor is 0.4379377 and it took 30.062159299850464s to compute

Our R-factor is 0.5479538 and it took 30.819960117340088s to compute
Our R-factor is 0.49775285 and it took 30.257105112075806s to compute
Our R-factor is 0.55186707 and it took 30.197242259979248s to compute
Our R-factor is 0.5981077 and it took 29.321358919143677s to compute
Our R-factor is 0.61482227 and it took 29.55688500404358s to compute
Our R-factor is 0.560861 and it took 30.035934925079346s to compute
Our R-factor is 0.5892086 and it took 29.516735076904297s to compute
Our R-factor is 0.5797423 and it took 30.523373126983643s to compute
Our R-factor is 0.45078665 and it took 30.540236949920654s to compute
Our R-factor is 0.6029068 and it took 29.575877904891968s to compute
Our R-factor is 0.4166149 and it took 30.406354904174805s to compute
Our R-factor is 0.49816275 and it took 29.13330888748169s to compute
Our R-factor is 0.5865345 and it took 29.16377091407776s to compute
Our R-factor is 0.5113524 and it took 29.1833279132843s to compute
Our R-factor is 0.5763227 and it took 28.810581922531128s to compute
Our R-factor is 0.5399521 and it took 28.951867818832397s to compute
Our R-factor is 0.54601544 and it took 29.264461040496826s to compute
Our R-factor is 0.50147545 and it took 28.8215012550354s to compute
Our R-factor is 0.60437465 and it took 29.325860023498535s to compute
Our R-factor is 0.54453415 and it took 29.5233793258667s to compute
Our R-factor is 0.58375 and it took 29.348095893859863s to compute
Our R-factor is 0.4980939 and it took 29.567596912384033s to compute
Our R-factor is 0.619207 and it took 29.528050899505615s to compute
Our R-factor is 0.3846268 and it took 29.3579261302948s to compute
Our R-factor is 0.57534945 and it took 30.314717054367065s to compute
Our R-factor is 0.51460725 and it took 29.64922285079956s to compute
Our R-factor is 0.47906888 and it took 29.432543992996216s to compute
Our R-factor is 0.3282072 and it took 30.765944957733154s to compute
Our R-factor is 0.6161134 and it took 29.52627182006836s to compute
Our R-factor is 0.5010373 and it took 29.339104175567627s to compute
Our R-factor is 0.6214874 and it took 29.51741600036621s to compute
Our R-factor is 0.38065577 and it took 28.752537965774536s to compute
Our R-factor is 0.54016495 and it took 29.340070962905884s to compute
Our R-factor is 0.4956564 and it took 29.402257919311523s to compute
Our R-factor is 0.60354096 and it took 29.23054003715515s to compute
Our R-factor is 0.5483877 and it took 29.28533411026001s to compute
Our R-factor is 0.56910825 and it took 28.39553689956665s to compute
Our R-factor is 0.36195424 and it took 28.40061092376709s to compute
Our R-factor is 0.59907556 and it took 28.63112711906433s to compute
Our R-factor is 0.52506435 and it took 28.773516178131104s to compute
Our R-factor is 0.5367675 and it took 28.830397844314575s to compute
Our R-factor is 0.5181307 and it took 29.73271417617798s to compute
Our R-factor is 0.503186 and it took 29.080729007720947s to compute
Our R-factor is 0.44057322 and it took 28.539238214492798s to compute
Our R-factor is 0.60594976 and it took 28.411789178848267s to compute
Our R-factor is 0.50181615 and it took 28.672701835632324s to compute
Our R-factor is 0.6054846 and it took 28.512802124023438s to compute
Our R-factor is 0.5067289 and it took 28.820454359054565s to compute
Our R-factor is 0.55682147 and it took 28.5817129611969s to compute
Our R-factor is 0.5545878 and it took 29.17987823486328s to compute
Our R-factor is 0.5142865 and it took 29.60423994064331s to compute
Our R-factor is 0.4498208 and it took 28.97372317314148s to compute
Our R-factor is 0.5443647 and it took 28.7829167842865s to compute
Our R-factor is 0.44033614 and it took 28.546669006347656s to compute
Our R-factor is 0.55521667 and it took 28.339375019073486s to compute
Our R-factor is 0.34427315 and it took 28.565850973129272s to compute
Our R-factor is 0.48500934 and it took 29.33595108985901s to compute
Our R-factor is 0.52394915 and it took 29.117679119110107s to compute
Our R-factor is 0.48796496 and it took 29.73242425918579s to compute
Our R-factor is 0.5733134 and it took 28.524786949157715s to compute
Our R-factor is 0.52001303 and it took 28.705615997314453s to compute
Our R-factor is 0.5447907 and it took 28.52015709877014s to compute
Our R-factor is 0.60645014 and it took 28.346781015396118s to compute
Our R-factor is 0.4734843 and it took 28.724669933319092s to compute
Our R-factor is 0.5024691 and it took 28.56515884399414s to compute
Our R-factor is 0.48965707 and it took 29.48036503791809s to compute
Our R-factor is 0.43395633 and it took 28.333112955093384s to compute
Our R-factor is 0.41658336 and it took 28.849782943725586s to compute
Our R-factor is 0.5962438 and it took 28.073536157608032s to compute
Our R-factor is 0.449264 and it took 28.712158918380737s to compute
Our R-factor is 0.54030764 and it took 29.34589123725891s to compute
Our R-factor is 0.2739932 and it took 28.769949913024902s to compute
Our R-factor is 0.4894739 and it took 28.600828886032104s to compute
Our R-factor is 0.53436005 and it took 29.636754989624023s to compute
Our R-factor is 0.24462822 and it took 29.160379886627197s to compute
Our R-factor is 0.47297135 and it took 28.653953075408936s to compute
Our R-factor is 0.511842 and it took 28.60996389389038s to compute
Our R-factor is 0.5758358 and it took 29.189774751663208s to compute
Our R-factor is 0.5005287 and it took 28.67188811302185s to compute
Our R-factor is 0.61476624 and it took 29.772809982299805s to compute
Our R-factor is 0.53524226 and it took 29.740422248840332s to compute
Our R-factor is 0.5173379 and it took 29.588597059249878s to compute
Our R-factor is 0.22323205 and it took 28.73630714416504s to compute
Our R-factor is 0.28208342 and it took 29.120906829833984s to compute
Our R-factor is 0.50139225 and it took 28.65343403816223s to compute
Our R-factor is 0.37886643 and it took 28.935538053512573s to compute
Our R-factor is 0.29983065 and it took 30.258904933929443s to compute
Our R-factor is 0.5321148 and it took 30.133737802505493s to compute
Our R-factor is 0.48298502 and it took 29.03914189338684s to compute
Our R-factor is 0.5058743 and it took 28.561774015426636s to compute
Our R-factor is 0.4797361 and it took 28.442381143569946s to compute
Our R-factor is 0.27507955 and it took 29.829578161239624s to compute
Our R-factor is 0.44775927 and it took 30.263264179229736s to compute
Our R-factor is 0.5237698 and it took 29.983269214630127s to compute
Our R-factor is 0.3520383 and it took 29.902167797088623s to compute
Our R-factor is 0.56512624 and it took 29.882758855819702s to compute
Our R-factor is 0.5080494 and it took 29.926796197891235s to compute
Our R-factor is 0.3996992 and it took 29.278870105743408s to compute
Our R-factor is 0.5810925 and it took 30.11130428314209s to compute
Our R-factor is 0.44461071 and it took 28.778246879577637s to compute
Our R-factor is 0.5273767 and it took 29.023586988449097s to compute
Our R-factor is 0.32259303 and it took 28.993775129318237s to compute
Our R-factor is 0.42134672 and it took 29.70705270767212s to compute
Our R-factor is 0.52756023 and it took 29.872174978256226s to compute
Our R-factor is 0.48553777 and it took 29.567596197128296s to compute
Our R-factor is 0.49279436 and it took 28.90676784515381s to compute
Our R-factor is 0.33966607 and it took 29.587658882141113s to compute
Our R-factor is 0.47517842 and it took 29.304221868515015s to compute
Our R-factor is 0.60375994 and it took 28.76660704612732s to compute
Our R-factor is 0.43422464 and it took 28.91904878616333s to compute
Our R-factor is 0.23635815 and it took 28.38459610939026s to compute
Our R-factor is 0.5781557 and it took 28.469520092010498s to compute
Our R-factor is 0.48411295 and it took 29.07943081855774s to compute
Our R-factor is 0.50386655 and it took 29.118063926696777s to compute
Our R-factor is 0.534787 and it took 28.68597912788391s to compute
Our R-factor is 0.261113 and it took 29.13106393814087s to compute
Our R-factor is 0.44087327 and it took 28.68517804145813s to compute
Our R-factor is 0.51994365 and it took 28.567540884017944s to compute
Our R-factor is 0.36844844 and it took 28.339592933654785s to compute
Our R-factor is 0.5215006 and it took 28.683155059814453s to compute
Our R-factor is 0.4961588 and it took 28.539287090301514s to compute
Our R-factor is 0.49197665 and it took 28.526795864105225s to compute
Our R-factor is 0.3531078 and it took 28.51505184173584s to compute
Our R-factor is 0.37709814 and it took 29.676110982894897s to compute
Our R-factor is 0.4105328 and it took 28.842631101608276s to compute
Our R-factor is 0.24496852 and it took 29.205298900604248s to compute
Our R-factor is 0.23676187 and it took 29.01106309890747s to compute
Our R-factor is 0.5420601 and it took 29.139240264892578s to compute
Our R-factor is 0.48272574 and it took 30.148274898529053s to compute
Our R-factor is 0.50152457 and it took 29.430565118789673s to compute
Our R-factor is 0.39121068 and it took 29.50572919845581s to compute
Our R-factor is 0.22023804 and it took 28.33665418624878s to compute
Our R-factor is 0.36792734 and it took 29.192101001739502s to compute
Our R-factor is 0.3931655 and it took 28.951630115509033s to compute
Our R-factor is 0.37108004 and it took 29.59480905532837s to compute
Our R-factor is 0.52385926 and it took 28.762287855148315s to compute
Our R-factor is 0.46865636 and it took 28.84364080429077s to compute
Our R-factor is 0.49986428 and it took 28.474801063537598s to compute
Our R-factor is 0.33662987 and it took 29.34213423728943s to compute
Our R-factor is 0.36844343 and it took 29.452206134796143s to compute
Our R-factor is 0.4114385 and it took 28.347438097000122s to compute
Our R-factor is 0.27133945 and it took 28.482587814331055s to compute
Our R-factor is 0.5158822 and it took 27.278573751449585s to compute
Our R-factor is 0.23330346 and it took 27.31041193008423s to compute
Our R-factor is 0.45228383 and it took 26.190855979919434s to compute
Our R-factor is 0.4949748 and it took 26.5853271484375s to compute
Our R-factor is 0.3568251 and it took 27.631306648254395s to compute
Our R-factor is 0.2095148 and it took 26.631211042404175s to compute
Our R-factor is 0.41901907 and it took 26.109824895858765s to compute
Our R-factor is 0.35744673 and it took 25.42659878730774s to compute
Our R-factor is 0.49947026 and it took 25.510010957717896s to compute
Our R-factor is 0.47567877 and it took 25.722702264785767s to compute
Our R-factor is 0.50756955 and it took 25.656721115112305s to compute
Our R-factor is 0.24735741 and it took 25.436062812805176s to compute
Our R-factor is 0.19410008 and it took 26.389316082000732s to compute
Our R-factor is 0.28641564 and it took 26.138800859451294s to compute
Our R-factor is 0.18934932 and it took 25.46109104156494s to compute
Our R-factor is 0.5131154 and it took 25.40590214729309s to compute
Our R-factor is 0.49891624 and it took 25.56454610824585s to compute
Our R-factor is 0.48638558 and it took 26.543360948562622s to compute
Our R-factor is 0.46044418 and it took 25.447449207305908s to compute
Our R-factor is 0.32127696 and it took 25.781051874160767s to compute
Our R-factor is 0.44567287 and it took 25.983015298843384s to compute
Our R-factor is 0.38674602 and it took 25.616847276687622s to compute
Our R-factor is 0.51715297 and it took 25.777014017105103s to compute
Our R-factor is 0.4743324 and it took 25.667582988739014s to compute
Our R-factor is 0.49686223 and it took 25.571962118148804s to compute
Our R-factor is 0.1960259 and it took 26.170419931411743s to compute
Our R-factor is 0.3370772 and it took 24.954432010650635s to compute
Our R-factor is 0.26597366 and it took 25.66850781440735s to compute
Our R-factor is 0.16598308 and it took 25.485452890396118s to compute
Our R-factor is 0.47675386 and it took 25.709342002868652s to compute
Our R-factor is 0.46580204 and it took 25.56955075263977s to compute
Our R-factor is 0.48469555 and it took 25.58913779258728s to compute
Our R-factor is 0.23728654 and it took 26.362583875656128s to compute
Our R-factor is 0.18528064 and it took 26.342742204666138s to compute
Our R-factor is 0.26257274 and it took 25.665924787521362s to compute
Our R-factor is 0.20398599 and it took 25.08614706993103s to compute
Our R-factor is 0.35069218 and it took 25.242268323898315s to compute
Our R-factor is 0.43451476 and it took 24.722688913345337s to compute
Our R-factor is 0.48445722 and it took 24.093523025512695s to compute
Our R-factor is 0.30755916 and it took 23.61744999885559s to compute
Our R-factor is 0.29627857 and it took 23.718385219573975s to compute
Our R-factor is 0.25264576 and it took 21.67530107498169s to compute
Our R-factor is 0.4185566 and it took 21.500870943069458s to compute
Our R-factor is 0.37828887 and it took 22.068238973617554s to compute
Our R-factor is 0.5083194 and it took 22.38411283493042s to compute
Our R-factor is 0.19488437 and it took 22.549330234527588s to compute
Our R-factor is 0.18072525 and it took 20.76915693283081s to compute
Our R-factor is 0.16835932 and it took 22.518574237823486s to compute
Our R-factor is 0.3567286 and it took 22.377551078796387s to compute
Our R-factor is 0.41115522 and it took 22.90767788887024s to compute
Our R-factor is 0.48445526 and it took 22.649582147598267s to compute
Our R-factor is 0.22717415 and it took 21.142162084579468s to compute
Our R-factor is 0.1761076 and it took 21.223651885986328s to compute
Our R-factor is 0.6112907 and it took 18.19326686859131s to compute
Our R-factor is 0.24173915 and it took 19.168083906173706s to compute
Our R-factor is 0.21850164 and it took 18.542307138442993s to compute
Our R-factor is 0.29008642 and it took 18.07184100151062s to compute
Our R-factor is 0.26578674 and it took 18.940290689468384s to compute
Our R-factor is 0.4614298 and it took 14.95068907737732s to compute
Our R-factor is 0.16925067 and it took 15.142583847045898s to compute
Our R-factor is 0.30975264 and it took 14.472164154052734s to compute
Our R-factor is 0.16099322 and it took 13.695120811462402s to compute
Our R-factor is 0.21920975 and it took 8.973176717758179s to compute
Our R-factor is 0.2635125 and it took 8.21333622932434s to compute
Our R-factor is 0.15503924 and it took 6.111812114715576s to compute
The best solution is [2.93097711 4.68672942 3.60531948 3.30091662] with Rwp 0.15503924
The reference solutions is [2.9306538, 4.6817646, 3.6026807, 3.233392]
The ratios of to the reference values are [0.9998896937429909, 0.9989406648886187, 0.9992680865168723, 0.979543676635183]

This concludes the whirlwind tutorial of applying ensembles of optimizers to Rietveld analysis.