kcleung wrote:So each constraint apparently has the full list of parameters to begin with:

Potentially yes. This would be a "fix everything

constraint". In practice, the matrix is very sparse (lots of elements are zero).

kcleung wrote:though I don't get what grad() does.

Gradient. The Jacobian is this:

https://en.wikipedia.org/wiki/Jacobian_ ... eterminant
kcleung wrote:Also, the other thing I don't understand is that the code told us plist is a list of parameters (from the entire sketch?). However, each element can have more than one parameters. So at the end, if we manage to identify a subset of parameters from the plist which is unconstrained, then we will somehow need to map each unconstrained parameter to its element, am I correct?

A line has 4 parameters, P1X, P1Y, P2X, P2Y. The Jacobian has the parameters of the full sketch yes. That is why you can get the rank (linked to DoF) from the QR decomposition of the Jacobian.

Mapping:

abdullah wrote:b) You can keep track of parameters and the geometric elements to which they belong with the Geoms array in Sketch.h

All GCS is pointers, Geoms contains all the shapes and its parameters.

kcleung wrote: Then what do the rows and column of the matrix R represent?

https://en.wikipedia.org/wiki/QR_decomposition
As you already discovered, the R matrix is used to identify redundancy/conflicting, when the rank is lower than the number of constraints (i.e. some constraints are linearly dependent, so do not contribute to increasing the rank). Eigen library is nice enough to allow you to track all the columns permutations performed while doing QR, so you can identify the constraints that contributed to each row of the R matrix.

kcleung wrote:int res = solve(subSysTmp,true,alg,true);

Is the real action taken here?

If I remember correctly, that is part of the redundant/conflicting

constraint determination. The action the whole diagnose function. I imagine that once you know which constraints are redundant, the rest of the constraints contribute to the current rank (DoF). Then you can use the Eigen functionality I mentioned above to see which parameters are them constraining. I mean, I do not have a solution myself ATM. I just think this is how a solution may be reached to.

It is not an easy undertaking the one you have selected. I will cost you time to fully understand what is happening in the code and then to find a way to achieve what you want.