FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix parameters "failed to solve" bug when adding a relation constrain… · dgramop/solvespace@ad43f63 · GitHub

Repository navigation

Commit ad43f63

Browse files
authored
Fix parameters "failed to solve" bug when adding a relation constraint (solvespace#1549)
* add rel constraint expr params to same list as others > Using the windows build offered in the comments above, the solver will complain of an unsolvable constraint when adding named parameter-based constraints to multiple group's sketches after a first group's sketch already has constraints built out of named parameters. With regard to this unsolvable constraint bug, I have a fix (PR solvespace#1549 ). This is my bad. This happens because parameters created inside a relation constraint are not added to the correct list before being passed to the solver. This led to the solver being unable to solve an unused relation constraint. WLOG, say you use the default relation constraint x=5. The solver, in trying to solve x-5=0, then has 0 parameters to nudge, so it can't just set x = -5. Now if you added, say a line segment, and used this parameter, the expression in the line segment would have added the parameter to the correct list. Now the solver is actually passed x as a free variable and can solve for it. For cross-referencing, that's another can of worms and the discussion of how to approach is still ongoing iirc.
1 parent e52d37c commit ad43f63

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/constrainteq.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void ConstraintBase::Generate(IdList<Param,hParam> *l) {
255255
size_t eqpos = expression.find_first_of("=");
256256
ssassert(eqpos == expression.find_last_of("="), "There is at most one equals sign in the relation \"expression\"");
257257
ssassert(eqpos != std::string::npos, "There is at least one equals sign in the relation \"expression\"");
258-
Expr::From(expression.substr(0, eqpos), false, &SK.param, NULL)->Minus(Expr::From(expression.substr(eqpos+1, SIZE_MAX), false, &SK.param, NULL));
258+
Expr::From(expression.substr(0, eqpos), false, l, NULL)->Minus(Expr::From(expression.substr(eqpos+1, SIZE_MAX), false, l, NULL));
259259
} else if(expression != "" && expr_scaling_to_base != 0) {
260260
Expr::From(expression.c_str(), false, l, NULL)->Times(Expr::From(std::to_string(expr_scaling_to_base).c_str(), false, l, NULL));
261261
} else if(expression != "") {

‎src/system.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ SolveResult System::Solve(Group *g, int *rank, int *dof, List<hConstraint> *bad,
425425
int x;
426426
dbp("%d equations", eq.n);
427427
for(x = 0; x < eq.n; x++) {
428-
dbp(" %.3f = %s = 0", eq[x].e->Eval(), eq[x].e->Print());
428+
dbp(" %.3f = %s = 0", eq[x].e->Eval(), eq[x].e->Print().c_str());
429429
}
430430
dbp("%d parameters", param.n);
431431
for(x = 0; x < param.n; x++) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL