Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling redundant constraints #444

Open
zevv opened this issue Jan 29, 2024 · 6 comments
Open

Handling redundant constraints #444

zevv opened this issue Jan 29, 2024 · 6 comments

Comments

@zevv
Copy link

zevv commented Jan 29, 2024

Every now and then I run into the problem where the solver tells me I have redundant constraints; no constraints are specifically marked, so the only way to solve this for me is to remove them one by one until I find the offending combination.

This is quite cumbersome, and I'm sure I'm doing something wrong here. What's the proper way to handle this situation?

@HummerSee451437
Copy link

I have the same problem. Did you find a solution by any chance?

@zevv
Copy link
Author

zevv commented Jun 30, 2024

No, I still remove them one by one until I find the offending combination :)

@hlorus
Copy link
Owner

hlorus commented Jun 30, 2024

We're limited by the capability of the solver which doesn't mark the offending constraints unfortunately. There was a recent addition to avoid creating the same constraints multiple times at least, see:
1476235

@zevv
Copy link
Author

zevv commented Jun 30, 2024

Is this something we could bring up with the solvespace people? I don't know a single thing about the CAD sketcher implementation, but I guess it would be a sensible feature for a solver to offer this kind of feedback on a failure.

@zevv
Copy link
Author

zevv commented Jun 30, 2024

I just tried Solvespace for the first time, using it is a breeze because I already know how to use CAD sketcher :)

However, Solvespace actually is able to indicate the source of redundant constraints, it tells me to "remove any of these to fix this" and shows a list of the constraints causing the conflict. This suggests that the info is available in solvespace itself, so the question would be how to get that out and propagate it to CAD sketcher, right?

In solvespace the case SolveResult::REDUNDANT_OKAY: is handled and the list of problematic constraints is dumped:

    for(int i = 0; i < g->solved.remove.n; i++) {                          
        hConstraint hc = g->solved.remove[i];                                  
        Constraint *c = SK.constraint.FindByIdNoOops(hc); 
        if(!c) continue;                               
                                                    
        Printf(false, "%Bp   %Fl%Ll%D%f%h%s%E",
            (i & 1) ? 'd' : 'a',
            c->h.v, (&TextWindow::ScreenSelectConstraint),     
            (&TextWindow::ScreenHoverConstraint),
            c->DescriptionString().c_str());                                      
    }                                                                                

This suggests the required info should be available at this point, but I'm not sure if this is all available through the Python binding of course.

@hlorus
Copy link
Owner

hlorus commented Jun 30, 2024

Solvespace unfortunately doesn't ship python bindings. We're using this python library by realthunder which has some memory improvements but also seems to be pinne to a rather old version of solvespace.
The solver does already provide a list of failed constraints (which CAD Sketcher uses and paints in red). Redundant constraints don't seem to be communicated, maybe it was added in a later version of the solver or is just not exposed in the python bi dings we're using.
@vespakoen was looking into adding official solvespace python bindings a while back, this would obviously be the perfect solution but i guess his efforts never made it into the trunk. Here's some more info on the topic: #320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants