Sketcher Solver Issue

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
mopy
Posts: 20
Joined: Fri Oct 08, 2021 4:58 am

Sketcher Solver Issue

Post by mopy »

Hi,
got:
17:46:36 Important: the LevenbergMarquardt solver succeeded where the DogLeg solver had failed.

BT wants only v0.20 based reports, so I'm posting it here, just in case it's of interest.

The Log:

Code: Select all

17:46:36  Sketcher::setUpSketch()-T:0
17:46:36  Updating geometry: Error build geometry(0): Both points are equal
17:46:36  Invalid solution from DogLeg solver.
17:46:36  Important: the LevenbergMarquardt solver succeeded where the DogLeg solver had failed.
17:46:36  If you see this message please report a way of reproducing this result at
17:46:36  http://www.freecadweb.org/tracker/main_page.php
17:46:36  Sketcher::Solve()-LevenbergMarquardt-T:0
17:46:36  Sketcher::setUpSketch()-T:0
17:46:36  Updating geometry: Error build geometry(0): Both points are equal
17:46:36  Invalid solution from DogLeg solver.
17:46:36  Sketcher::Solve()-LevenbergMarquardt- Failed!! Falling back...
17:46:36  Sketcher::Solve()-BFGS- Failed!! Falling back...
17:46:36  Updating geometry: Error build geometry(0): Both points are equal
17:46:36  Invalid solution from SQP(augmented system) solver.
17:46:36  Sketcher::Solve()-SQP(augmented system)-T:0.001
17:46:36  Sketcher::setUpSketch()-T:0
17:46:36  Updating geometry: Error build geometry(0): Both points are equal
17:46:36  Invalid solution from DogLeg solver.
17:46:36  Sketcher::Solve()-LevenbergMarquardt- Failed!! Falling back...
17:46:36  Sketcher::Solve()-BFGS- Failed!! Falling back...
17:46:36  Updating geometry: Error build geometry(0): Both points are equal
17:46:36  Invalid solution from SQP(augmented system) solver.
17:46:36  Sketcher::Solve()-SQP(augmented system)-T:0
17:46:36  Recompute failed! Please check report view.
17:56:02  Save AutoRecovery file: Needed time: 2ms
Reproduce:

Code: Select all

App.getDocument('Unnamed').getObject('Sketch').addGeometry(Part.LineSegment(App.Vector(6.299129,8.703989,0),App.Vector(11.474183,5.398911,0)),False)
App.getDocument('Unnamed').getObject('Sketch').addGeometry(Part.LineSegment(App.Vector(8.299570,10.356529,0),App.Vector(15.000000,7.000000,0)),False)
App.getDocument('Unnamed').getObject('Sketch').addConstraint(Sketcher.Constraint('Parallel',0,1)) 
App.getDocument('Unnamed').getObject('Sketch').addConstraint(Sketcher.Constraint('Parallel',1,-1)) 
App.getDocument('Unnamed').getObject('Sketch').addConstraint(Sketcher.Constraint('Parallel',0,-2)) 
Version Info:

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: German/Germany (de_DE)
Last edited by mopy on Fri Oct 15, 2021 12:55 pm, edited 2 times in total.
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: Sketcher Solver Issue

Post by chrisb »

Hi and welcome to the forum!

Thanks for the report, but as far as I can see you have a flaw in your sketch: you seem to have a line of length 0 or a circle with radius 0. You should fix this, because it causes problems in further steps.

For future posts, please put the log outputs in code tags for ease of reading; and add the file showing your issue. It is always appreciated if you simplify such files as far as possible so that they still show the problem, but don't contain any additional stuff.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
mopy
Posts: 20
Joined: Fri Oct 08, 2021 4:58 am

Re: Sketcher Solver Issue

Post by mopy »

Hi,
the log shows the whole sketch. Two lines and three parallel constraints. The line of length 0 is the result of the solver. I stumbled over this, while intentionally creating a constraint conflict.
I'm looking on how to access the SolvedSketch info from Python side.

Regards,
Rolf
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: Sketcher Solver Issue

Post by chrisb »

Please add your python commands without the leading symbols. You can use "Copy command" in the console.Thus this preparatory step has to be done only once.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
mopy
Posts: 20
Joined: Fri Oct 08, 2021 4:58 am

Re: Sketcher Solver Issue

Post by mopy »

Sorry, fixed it.

Can a line of length 0 or a point be parallel to something?
It looks like that one solver thinks it's correct and in turn comes up with a solution that breaks transitivity.
openBrain
Veteran
Posts: 9031
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Sketcher Solver Issue

Post by openBrain »

mopy wrote: Fri Oct 15, 2021 1:00 pm Sorry, fixed it.

Can a line of length 0 or a point be parallel to something?
It looks like that one solver thinks it's correct and in turn comes up with a solution that breaks transitivity.
Please tell what you're trying to achieve.
Your constraints (specifically GeoId, PosID) you're using in your Python snippet have strictly no sense. ;)
mopy
Posts: 20
Joined: Fri Oct 08, 2021 4:58 am

Re: Sketcher Solver Issue

Post by mopy »

As I said, while trying to create an invalid constraint (for some testing purpose) I was asked by the code to report an issue. I've just done so.
I did look into the situation a bit. Hence my questions.
IMHO a solver to reduce the length of a line to 0 and thereby breaking transitivity is worth a look.
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: Sketcher Solver Issue

Post by chrisb »

mopy wrote: Sun Oct 10, 2021 7:25 pm the log shows the whole sketch.
The code given doesn't reproduce a sketch here. It shows a bunch of error messages though. And I think that is correct.

From what I see you try to make things parallel to x- and y-axis at the same time and I am not surprised that things go havoc.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
mopy
Posts: 20
Joined: Fri Oct 08, 2021 4:58 am

Re: Sketcher Solver Issue

Post by mopy »

Thx for taking a closer look.
In a more complex scenario it might not be that obvious that this scenario is nonsense.
I would have expected a conflicting constraint message, not a solver goin' crazy.
Attachments
TestParallelFail.FCStd
(3.95 KiB) Downloaded 43 times
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: Sketcher Solver Issue

Post by chrisb »

When I open the sketch I see the correct "Both points are equal" message. I wouldn't call that crazy.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply