diff --git a/web/app/constr/constraints.js b/web/app/constr/constraints.js index 00dfbf81..f0067857 100644 --- a/web/app/constr/constraints.js +++ b/web/app/constr/constraints.js @@ -64,6 +64,23 @@ TCAD.constraints.ConstantWrapper = function(constr, mask) { } }; +TCAD.constraints.Weighted = function(constr, weight) { + + this.params = constr.params; + + this.error = function() { + return constr.error() * weight; + }; + + this.gradient = function(out) { + constr.gradient(out); + for (var i = 0; i < out.length; i++) { + out[i] *= weight; + } + } +}; + + TCAD.constraints.EqualsTo = function(params, value) { this.params = params; diff --git a/web/app/constr/solver.js b/web/app/constr/solver.js index 3286fe74..48f153c8 100644 --- a/web/app/constr/solver.js +++ b/web/app/constr/solver.js @@ -87,7 +87,7 @@ TCAD.parametric.System.prototype.calcResidual = function(r) { err *= 0.5; return err; -} +}; TCAD.parametric.System.prototype.calcGrad_ = function(out) { var i; @@ -200,7 +200,7 @@ 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.EqualsTo([locked[i]], locked[i].get())); + _locked.push(new TCAD.constraints.Weighted(new TCAD.constraints.EqualsTo([locked[i]], locked[i].get()), 0.1)); } return _locked; }; @@ -209,7 +209,7 @@ TCAD.parametric.prepare = function(constrs, locked, alg) { // this.lock1(constrs, locked); 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); diff --git a/web/app/parametric.js b/web/app/parametric.js index 690054ca..c1fec5e0 100644 --- a/web/app/parametric.js +++ b/web/app/parametric.js @@ -252,7 +252,7 @@ TCAD.TWO.ParametricManager.prototype.prepare = function(locked, alg) { } for (i = 0; i < this.system.length; ++i) { var c = this.system[i]; - if (c.NAME === 'equal' && c.coincident === true) { + if (c.NAME === 'equal' && c.coincident === true && false) { //Disable it var found = false; //if (!peq(c.p1, c.p2)) continue; var p0 = c.p1.id;