mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-10 02:13:58 +01:00
fix regression
This commit is contained in:
parent
8b5ce74cd3
commit
7c9b34b66c
2 changed files with 9 additions and 13 deletions
|
|
@ -15,8 +15,6 @@ import java.lang.*;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static java.lang.Math.abs;
|
||||
|
||||
public class GlobalSolver {
|
||||
|
||||
public static void globalSolve(Solver.SubSystem subSystem, Runnable linearSolvedCallback) {
|
||||
|
|
@ -28,20 +26,17 @@ public class GlobalSolver {
|
|||
// }
|
||||
|
||||
double eps = 0.0001;
|
||||
java.lang.System.out.println("Solve system with error: " + subSystem.errorSquared());
|
||||
boolean triedShrink = false;
|
||||
while (abs(subSystem.value()) > eps && !triedShrink) {
|
||||
// solveLM_COMMONS(subSystem);
|
||||
java.lang.System.out.println("Solve system with error: " + subSystem.value());
|
||||
int count = 0;
|
||||
while (subSystem.valueSquared() > eps && (count++ < 100)) {
|
||||
solveLM_COMMONS(subSystem);
|
||||
// Solver.solve_BFGS(subSystem, false);
|
||||
// Solver.solve_LM(subSystem);
|
||||
Solver.solve_BFGS(subSystem, false);
|
||||
if (abs(subSystem.value()) > eps) {
|
||||
if (Math.abs(subSystem.valueSquared()) > eps) {
|
||||
// solveWorse(subSystem, eps);
|
||||
if(subSystem.constraints.size() > 1) {
|
||||
Solver.SubSystem shrunk = shrink(subSystem);
|
||||
triedShrink = true;
|
||||
globalSolve(shrunk, linearSolvedCallback);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
linearSolvedCallback.run();
|
||||
|
|
|
|||
|
|
@ -813,7 +813,7 @@ public class Solver {
|
|||
public double value() {
|
||||
double err = 0.;
|
||||
for (Constraint c : constraints) {
|
||||
err += c.error();
|
||||
err += Math.abs(c.error());
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
|
@ -885,13 +885,14 @@ public class Solver {
|
|||
out.setEntry(i, 0, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static double dotProduct(RealMatrix m1, RealMatrix m2) {
|
||||
return new ArrayRealVector(m1.getData()[0]).dotProduct(new ArrayRealVector(m2.getData()[0]));
|
||||
}
|
||||
|
||||
|
||||
static double XconvergenceRough = 1e-8;
|
||||
static double XconvergenceFine = 1e-10;
|
||||
static double smallF = 1e-20;
|
||||
|
|
|
|||
Loading…
Reference in a new issue