From 1b9c7524b230cbf9eb387556e46195ef66354d2a Mon Sep 17 00:00:00 2001 From: Fred Rothganger Date: Mon, 1 Apr 2024 11:56:29 -0600 Subject: [PATCH] Studies: add perturbationMin --- .../sandia/n2a/ui/studies/OptimizerLM2.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/N2A/src/gov/sandia/n2a/ui/studies/OptimizerLM2.java b/N2A/src/gov/sandia/n2a/ui/studies/OptimizerLM2.java index feb9d73b..6ccae176 100644 --- a/N2A/src/gov/sandia/n2a/ui/studies/OptimizerLM2.java +++ b/N2A/src/gov/sandia/n2a/ui/studies/OptimizerLM2.java @@ -49,6 +49,7 @@ public class OptimizerLM2 extends StudyIterator protected double toleranceX; protected double toleranceG; protected double perturbation; + protected double perturbationMin; // Lower limit on absolute size of perturbation. protected String[] dummy; protected MatrixDense x; // current state vector @@ -74,11 +75,12 @@ public OptimizerLM2 (Study study, List loss, List variables) this.loss = loss; this.variables = variables; - maxIterations = study.source.getOrDefault (200, "config", "maxIterations"); - toleranceF = study.source.getOrDefault (epsilon, "config", "toleranceF"); - toleranceX = study.source.getOrDefault (epsilon, "config", "toleranceX"); - toleranceG = study.source.getOrDefault (epsilon, "config", "toleranceG"); - perturbation = study.source.getOrDefault (epsilon, "config", "perturbation"); + maxIterations = study.source.getOrDefault (200, "config", "maxIterations"); + toleranceF = study.source.getOrDefault (epsilon, "config", "toleranceF"); + toleranceX = study.source.getOrDefault (epsilon, "config", "toleranceX"); + toleranceG = study.source.getOrDefault (epsilon, "config", "toleranceG"); + perturbation = study.source.getOrDefault (epsilon, "config", "perturbation"); + perturbationMin = study.source.getOrDefault (0.0, "config", "perturbationMin"); int n = variables.size (); x = new MatrixDense (n, 1); @@ -218,7 +220,8 @@ public boolean step () { double[] series = getSeries (baseIndex + c); double h = perturbation * Math.abs (x.get (c)); - if (h == 0) h = perturbation; + if (h < perturbationMin) h = perturbationMin; + else if (h == 0) h = perturbation; double norm = 0; for (int r = 0; r < m; r++) { @@ -615,7 +618,8 @@ public void assign (MNode model) if (c == sample) { double h = perturbation * Math.abs (value); - if (h == 0) h = perturbation; + if (h < perturbationMin) h = perturbationMin; + else if (h == 0) h = perturbation; value += h; // We don't bound the perturbation. Presumably it is small enough that // if it transgresses min or max, it does not go so far that the model fails.