Skip to content

Commit

Permalink
Studies: add perturbationMin
Browse files Browse the repository at this point in the history
  • Loading branch information
frothga committed Apr 1, 2024
1 parent 9269367 commit 1b9c752
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions N2A/src/gov/sandia/n2a/ui/studies/OptimizerLM2.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -74,11 +75,12 @@ public OptimizerLM2 (Study study, List<MNode> loss, List<MNode> 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);
Expand Down Expand Up @@ -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++)
{
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1b9c752

Please sign in to comment.