diff --git a/.gitignore b/.gitignore index 7ebea6a4..ce217752 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ /out/ /.idea/ *.iml +*.ipr +*.iws # Package Files # *.jar diff --git a/web/app/canvas.js b/web/app/canvas.js index 19b38c5a..1159aeec 100644 --- a/web/app/canvas.js +++ b/web/app/canvas.js @@ -792,8 +792,8 @@ TCAD.TWO.DragTool.prototype.solveRequest = function(fineLevel) { && this.obj.parent._class === 'TCAD.TWO.Arc') { if (this.obj.id != this.obj.parent.c.id) { - locked.push(this.obj.parent.c._x); - locked.push(this.obj.parent.c._y); + // locked.push(this.obj.parent.c._x); + // locked.push(this.obj.parent.c._y); } } } else { diff --git a/web/app/constr/solver.js b/web/app/constr/solver.js index 597b5914..7c93c203 100644 --- a/web/app/constr/solver.js +++ b/web/app/constr/solver.js @@ -200,16 +200,18 @@ TCAD.parametric.lock1 = function(constrs, locked) { TCAD.parametric.lock2Equals2 = function(constrs, locked) { var _locked = []; for (var i = 0; i < locked.length; ++i) { - _locked.push(new TCAD.constraints.Weighted(new TCAD.constraints.EqualsTo([locked[i]], locked[i].get()), 0.1)); + _locked.push(new TCAD.constraints.Weighted(new TCAD.constraints.EqualsTo([locked[i]], locked[i].get()), 1)); } return _locked; }; +TCAD.parametric._alg = 5; + TCAD.parametric.prepare = function(constrs, locked, aux, alg) { this.lock1(constrs, aux); var lockingConstrs = this.lock2Equals2(constrs, locked); -// Array.prototype.push.apply( constrs, lockingConstrs ); + Array.prototype.push.apply( constrs, lockingConstrs ); var sys = new TCAD.parametric.System(constrs); @@ -231,7 +233,7 @@ TCAD.parametric.prepare = function(constrs, locked, aux, alg) { sys.setParams(point); return sys.makeJacobian(); }; - alg = 5; + alg = TCAD.parametric._alg; function solve(fineLevel) { if (constrs.length == 0) return; @@ -252,7 +254,10 @@ TCAD.parametric.prepare = function(constrs, locked, aux, alg) { TCAD.math.solve_UNCMIN(sys); break; case 5: - optim.dog_leg(sys); + if (optim.dog_leg(sys) !== 0) { + TCAD.parametric._alg = alg = -5; + solve(fineLevel); + } break; } return sys; @@ -260,9 +265,10 @@ TCAD.parametric.prepare = function(constrs, locked, aux, alg) { var opt = new LMOptimizer(sys.getParams(), arr(sys.constraints.length), model, jacobian); var eps; + fineLevel = 1; switch (fineLevel) { case 1: - eps = 0.01; + eps = 0.001; opt.init0(eps, eps, eps); break; case 2: diff --git a/web/app/math/noptim.js b/web/app/math/noptim.js index 19226af7..78de33d4 100644 --- a/web/app/math/noptim.js +++ b/web/app/math/noptim.js @@ -358,10 +358,10 @@ optim.dog_leg = function(subsys) { var alpha=0.; var nu=2.; var iter=0, stop=0, reduce=0; - while (!stop) { + while (stop === 0) { // check if finished - if (fx_inf <= tolf) // Success + if (fx_inf <= tolf || err <= tolf) // Success stop = 1; else if (g_inf <= tolg) stop = 2; diff --git a/web/app/parametric.js b/web/app/parametric.js index 630872d6..1c05a6cb 100644 --- a/web/app/parametric.js +++ b/web/app/parametric.js @@ -746,6 +746,8 @@ TCAD.TWO.Constraints.RR = function(arc1, arc2) { }; TCAD.TWO.Constraints.RR.prototype.NAME = 'RR'; +TCAD.TWO.Constraints.RR.prototype.reducible = true; + TCAD.TWO.Constraints.RR.prototype.getSolveData = function() { return [['equal', [this.arc1.r, this.arc2.r], []]];