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

[Problem] Increase the functional test coverage of the popularity contest algorithm #9683

Open
2 tasks done
abdullahtahiriyo opened this issue May 28, 2023 · 2 comments
Open
2 tasks done
Labels
WB Sketcher Related to the Sketcher Workbench

Comments

@abdullahtahiriyo
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Version

0.21 (Development)

Full version info

Any version, including any previous version.

Subproject(s) affected?

Sketcher

Problem description

There is a heuristic algorithm in the solver used to determine which constraints should be suggested to the user as conflicting or redundant. It is called "Popularity contest".

Every year we receive a couple of case where FC's proposal is wrong and we modify the algorithm. As we do not have unit tests, it is possible that by "fixing" one case we might break others. The impact of having functional unit tests can be significant.

The solution is to write functional tests using the sketches that we are provided.

#9474 (comment)
#9474 (comment)

Here there are two first candidate sketches:
https://forum.freecad.org/viewtopic.php?p=679816&sid=88c017510dd04787086a38aa296e315e#p679816

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@abdullahtahiriyo
Copy link
Contributor Author

@jbaehr

Thanks for taking a look. I could not assign it to you as requested. The system does not allow me to.

I am considering in parallel a mechanism to facilitate this creation of sketches. I will cross post here when I look into it.

@abdullahtahiriyo
Copy link
Contributor Author

@jbaehr

I have written a small utility to extract sketches to Python code:
#9684

One sketch is:

geoList = []
geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(0.000000, 0.000000, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), 65.000000), 3.926991, 8.639380))
geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(-70.304056, -14.307964, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), 65.000000), 1.186945, 1.992409))
ActiveSketch.addGeometry(geoList,False)
del geoList
constrGeoList = []
constrGeoList.append(Part.LineSegment(App.Vector(-45.961941,45.961941,0.000000),App.Vector(0.000000,0.000000,0.000000)))
constrGeoList.append(Part.LineSegment(App.Vector(0.000000,0.000000,0.000000),App.Vector(-45.961941,-45.961941,0.000000)))
ActiveSketch.addGeometry(constrGeoList,True)
del constrGeoList
geoList = []
geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(-70.304056, 14.307964, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), 65.000000), 4.290776, 5.096240))
geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(-50.000000, 0.000000, 0.000000), App.Vector(0.000000, 0.000000, 1.000000), 65.000000), 2.376910, 3.906275))
ActiveSketch.addGeometry(geoList,False)
del geoList
constraintList = []
constraintList.append(Sketcher.Constraint('Coincident', 0, 3, -1, 1))
constraintList.append(Sketcher.Constraint('Coincident', 1, 1, 0, 2))
constraintList.append(Sketcher.Constraint('Coincident', 2, 1, 0, 2))
constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 0, 3))
constraintList.append(Sketcher.Constraint('Coincident', 3, 1, 0, 3))
constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 0, 1, 0, 2, -1))
constraintList.append(Sketcher.Constraint('Coincident', 4, 2, 0, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 1, 3, 4, 3, -1))
constraintList.append(Sketcher.Constraint('Symmetric', 4, 1, 1, 2, -1))
constraintList.append(Sketcher.Constraint('Coincident', 5, 1, 1, 2))
constraintList.append(Sketcher.Constraint('Coincident', 5, 2, 4, 1))
constraintList.append(Sketcher.Constraint('DistanceY', 4, 1, 1, 2, 90.000000))
constraintList.append(Sketcher.Constraint('Radius', 5, 65.000000))
constraintList.append(Sketcher.Constraint('DistanceX', 5, 3, 0, 3, 50.000000))
constraintList.append(Sketcher.Constraint('Equal', 5, 4))
constraintList.append(Sketcher.Constraint('Equal', 4, 0))
constraintList.append(Sketcher.Constraint('Perpendicular', 2, 3))
ActiveSketch.addConstraint(constraintList)
del constraintList

The other is:

geoList = []
geoList.append(Part.LineSegment(App.Vector(-18.429153,15.262231,0.000000),App.Vector(-18.429153,-15.262231,0.000000)))
geoList.append(Part.LineSegment(App.Vector(-18.429153,-15.262231,0.000000),App.Vector(18.429153,-15.262231,0.000000)))
geoList.append(Part.LineSegment(App.Vector(18.429153,-15.262231,0.000000),App.Vector(18.429153,15.262231,0.000000)))
geoList.append(Part.LineSegment(App.Vector(18.429153,15.262231,0.000000),App.Vector(-18.429153,15.262231,0.000000)))
ActiveSketch.addGeometry(geoList,False)
del geoList
constrGeoList = []
constrGeoList.append(Part.Point(App.Vector(-0.000000,15.262231,0.000000)))
constrGeoList.append(Part.Point(App.Vector(-0.000000,-15.262231,0.000000)))
constrGeoList.append(Part.Point(App.Vector(-18.429153,-0.000000,0.000000)))
constrGeoList.append(Part.Point(App.Vector(18.429153,-0.000000,0.000000)))
ActiveSketch.addGeometry(constrGeoList,True)
del constrGeoList
constraintList = []
constraintList.append(Sketcher.Constraint('Coincident', 0, 2, 1, 1))
constraintList.append(Sketcher.Constraint('Coincident', 1, 2, 2, 1))
constraintList.append(Sketcher.Constraint('Coincident', 2, 2, 3, 1))
constraintList.append(Sketcher.Constraint('Coincident', 3, 2, 0, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 0, 2, 2, 2, -1, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 0, 1, 2, 2, 4, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 0, 2, 1, 2, 5, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 6, 1, 7, 1, -1, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 0, 2, 0, 1, 6, 1))
constraintList.append(Sketcher.Constraint('Symmetric', 2, 2, 1, 2, 7, 1))
constraintList.append(Sketcher.Constraint('PointOnObject', 5, 1, -2))
constraintList.append(Sketcher.Constraint('PointOnObject', 7, 1, -1))
constraintList.append(Sketcher.Constraint('Symmetric', 5, 1, 4, 1, -1, 1))
ActiveSketch.addConstraint(constraintList)
del constraintList

That is the output of the tool.

After pasting it into console, or a macro, one needs to ActiveSketch.solve().

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

No branches or pull requests

2 participants