From fc792a64f28e9025cffa6b681bfece7ea4a96572 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Wed, 1 Oct 2014 01:35:25 -0700 Subject: [PATCH] splitup is mistaken --- src/cad/gcs/GlobalSolver.java | 17 +++++++++-------- src/cad/gcs/Solver.java | 22 +++++++++++++++++----- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/cad/gcs/GlobalSolver.java b/src/cad/gcs/GlobalSolver.java index 4a5af3c1..5d721289 100644 --- a/src/cad/gcs/GlobalSolver.java +++ b/src/cad/gcs/GlobalSolver.java @@ -29,17 +29,18 @@ public class GlobalSolver { double eps = 0.0001; java.lang.System.out.println("Solve system with error: " + subSystem.value()); int count = 0; - while (subSystem.valueSquared() > eps && (count++ < 100)) { + while (subSystem.valueSquared() > eps && (count++ < 1)) { solveLM_COMMONS(subSystem); // Solver.solve_BFGS(subSystem, false); +// Solver.solve_DL(subSystem); // Solver.solve_LM(subSystem); - if (Math.abs(subSystem.valueSquared()) > eps) { -// solveWorse(subSystem, eps); - if(subSystem.constraints.size() > 1) { - Solver.SubSystem shrunk = shrink(subSystem); - globalSolve(shrunk, linearSolvedCallback); - } - } +// if (Math.abs(subSystem.valueSquared()) > eps) { +//// solveWorse(subSystem, eps); +// if(subSystem.constraints.size() > 1) { +// Solver.SubSystem shrunk = shrink(subSystem); +// globalSolve(shrunk, linearSolvedCallback); +// } +// } linearSolvedCallback.run(); } } diff --git a/src/cad/gcs/Solver.java b/src/cad/gcs/Solver.java index b1134a44..7a245c37 100644 --- a/src/cad/gcs/Solver.java +++ b/src/cad/gcs/Solver.java @@ -102,12 +102,24 @@ public class Solver { } boolean success = true; - try { - h_gn = new LUDecomposition(A).getSolver().solve(gg); - } catch (Exception ssse) { - java.lang.System.out.println(ssse.getMessage()); - success = false; + + + for (int _ = 0; _ < 1000; _++) { + try { + h_gn = new LUDecomposition(A).getSolver().solve(gg); + } catch (Exception ssse) { + mu *= 1./3.; + for (int i = 0; i < xsize; ++i) { + A.setEntry(i, i, diag_A[i] * mu); + } + if (_ == 999) { + return SolveStatus.Success; + } + continue; + } + break; } + if (success) { break; }