Skip to content
Snippets Groups Projects
Commit 11925335 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

adjust fitting settings

parent de81756e
No related branches found
No related tags found
1 merge request!2078Adjust fitting settings for 'scatter2d/consecutive_fitting.py'
Pipeline #118166 passed
......@@ -7,7 +7,6 @@ space and roughly find local minimum. The second Minuit2 minimizer will continue
after that to find precise minimum location.
"""
import numpy as np
from matplotlib import pyplot as plt
import bornagain as ba
from bornagain import ba_fitmonitor, deg, angstrom, nm
......@@ -59,7 +58,7 @@ def fake_data():
simulation = get_simulation(P)
result = simulation.simulate()
return result.noisy(0.1, 0.1)
return result.noisy(0.3, 0.5)
def run_fitting():
......@@ -70,17 +69,17 @@ def run_fitting():
fit_objective = ba.FitObjective()
fit_objective.addFitPair(get_simulation, data, 1)
fit_objective.initPrint(10)
fit_objective.initPrint(30)
observer = ba_fitmonitor.PlotterGISAS()
fit_objective.initPlot(10, observer)
fit_objective.initPlot(30, observer)
"""
Setting fitting parameters with starting values.
Here we select starting values being quite far from true values
to puzzle our minimizer's as much as possible.
"""
P = ba.Parameters()
P.add("height", 1.*nm, min=0.01, max=30, step=0.05*nm)
P.add("radius", 20.*nm, min=0.01, max=30, step=0.05*nm)
P.add("height", 1.*nm, min=0.01, max=30)
P.add("radius", 20.*nm, min=0.01, max=30)
"""
Now we run first minimization round using the Genetic minimizer.
The Genetic minimizer is able to explore large parameter space
......@@ -88,7 +87,7 @@ def run_fitting():
"""
minimizer = ba.Minimizer()
minimizer.setMinimizer("Genetic", "",
"MaxIterations=2;PopSize=300;RandomSeed=1")
"MaxIterations=3;PopSize=500")
result = minimizer.minimize(fit_objective.evaluate, P)
fit_objective.finalize(result)
......
......@@ -7,7 +7,6 @@ space and roughly find local minimum. The second Minuit2 minimizer will continue
after that to find precise minimum location.
"""
import numpy as np
from matplotlib import pyplot as plt
import bornagain as ba
from bornagain import ba_fitmonitor, deg, angstrom, nm
......@@ -59,7 +58,7 @@ def fake_data():
simulation = get_simulation(P)
result = simulation.simulate()
return result.noisy(0.1, 0.1)
return result.noisy(0.3, 0.5)
def run_fitting():
......@@ -70,17 +69,17 @@ def run_fitting():
fit_objective = ba.FitObjective()
fit_objective.addFitPair(get_simulation, data, 1)
fit_objective.initPrint(10)
fit_objective.initPrint(30)
observer = ba_fitmonitor.PlotterGISAS()
plt.close() # (hide plot) fit_objective.initPlot(10, observer)
plt.close() # (hide plot) fit_objective.initPlot(30, observer)
"""
Setting fitting parameters with starting values.
Here we select starting values being quite far from true values
to puzzle our minimizer's as much as possible.
"""
P = ba.Parameters()
P.add("height", 1.*nm, min=0.01, max=30, step=0.05*nm)
P.add("radius", 20.*nm, min=0.01, max=30, step=0.05*nm)
P.add("height", 1.*nm, min=0.01, max=30)
P.add("radius", 20.*nm, min=0.01, max=30)
"""
Now we run first minimization round using the Genetic minimizer.
The Genetic minimizer is able to explore large parameter space
......@@ -88,7 +87,7 @@ def run_fitting():
"""
minimizer = ba.Minimizer()
minimizer.setMinimizer("Genetic", "",
"MaxIterations=1;PopSize=10;RandomSeed=1")
"MaxIterations=1;PopSize=10")
result = minimizer.minimize(fit_objective.evaluate, P)
fit_objective.finalize(result)
......
......@@ -7,7 +7,6 @@ space and roughly find local minimum. The second Minuit2 minimizer will continue
after that to find precise minimum location.
"""
import numpy as np
from matplotlib import pyplot as plt
import bornagain as ba
from bornagain import ba_fitmonitor, deg, angstrom, nm
......@@ -59,7 +58,7 @@ def fake_data():
simulation = get_simulation(P)
result = simulation.simulate()
return result.noisy(0.1, 0.1)
return result.noisy(0.3, 0.5)
def run_fitting():
......@@ -70,17 +69,17 @@ def run_fitting():
fit_objective = ba.FitObjective()
fit_objective.addFitPair(get_simulation, data, 1)
fit_objective.initPrint(10)
fit_objective.initPrint(30)
observer = ba_fitmonitor.PlotterGISAS()
<%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(10, observer)
<%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(30, observer)
"""
Setting fitting parameters with starting values.
Here we select starting values being quite far from true values
to puzzle our minimizer's as much as possible.
"""
P = ba.Parameters()
P.add("height", 1.*nm, min=0.01, max=30, step=0.05*nm)
P.add("radius", 20.*nm, min=0.01, max=30, step=0.05*nm)
P.add("height", 1.*nm, min=0.01, max=30)
P.add("radius", 20.*nm, min=0.01, max=30)
"""
Now we run first minimization round using the Genetic minimizer.
The Genetic minimizer is able to explore large parameter space
......@@ -89,7 +88,7 @@ def run_fitting():
minimizer = ba.Minimizer()
minimizer.setMinimizer("Genetic", "",
"<%= sm ? "MaxIterations=1;PopSize=10" :
"MaxIterations=2;PopSize=300" %>;RandomSeed=1")
"MaxIterations=3;PopSize=500" %>")
result = minimizer.minimize(fit_objective.evaluate, P)
fit_objective.finalize(result)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment