Wednesday, 25 July 2012

Solver speed improvements

Over the last few days I did some investigations and improvements to the SolverRef method.

I did tests with several shapes and constraint combinations, and for each set of changes I compared the performance using a saved file and changing just one value, in the property grid. This ensured that I was comparing the performance on the same steps.
Here is one of the cases I tested:

When changing the height of the main rectangle (where the mouse cursor is) the performance of the old code is:

There are 21 calls to the Solver method, and most of the time was spent accessing array values and calculating the constraints. The main problem is that most of the matrices have the number of rows with non-zero elements equal to the number of free points, and total row/column count equal to the number of constraints.

After limiting the number of processed rows, checking for zero values used in multiplications and using the 'rough' convergence (1e-8 instead of 1e-10), the results improved significantly:

There are more improvements to be done for constraint calculation, and I want to investigate more efficient ways of doing the multiplications considering that they're most of the time sparse matrices.

No comments:

Post a Comment