Page 1 of 2

RRA Singular Matrix

Posted: Tue Jul 02, 2013 7:28 am
by andrewlapre
I've modified a model and the accompanying motion, task, actuator, and GRF files, and am trying to run the RRA tool. It gets hung up however when the messages window says it's computing the residuals and gives me these details in the Exception pop-up:

java.lang.RuntimeException: SimTK Exception thrown at SmallMatrixMixed.h:878:
Error detected by Simbody method lapackInverse(Mat<>): Matrix is singular so can't be inverted (Lapack getrf info=3).
(Required condition 'info==0' was not met.)

at org.opensim.modeling.opensimModelJNI.RRATool_run(Native Method)
at org.opensim.modeling.RRATool.run(RRATool.java:157)
at org.opensim.tracking.RRAToolModel$RRAToolWorker.construct(RRAToolModel.java:141)
at org.opensim.swingui.SwingWorker$2.run(SwingWorker.java:108)
[catch] at java.lang.Thread.run(Thread.java:662)


Does anyone have any idea what this means? I had the RRA working before I modified the model, and I'm able to do Inverse Dynamics with the modified model. Any help is appreciated!!!!

Thanks,
Andy

Re: RRA Singular Matrix

Posted: Tue Jul 02, 2013 9:07 am
by sherm
Hi, Andrew.

This message usually means that your mass or inertia properties were non-physical. You might want to check the modifications you made to see if you may have introduced a non-physical body.

Regards,
Sherm

Re: RRA Singular Matrix

Posted: Wed Nov 20, 2013 8:24 am
by daybreaklee
Hey Sherm,

This is Vincent.
I have the similar issue when I modified my pedaling model from open loop to closed loop, you mention the "non-physical", does it mean that mass or inertia of segment set to "0"? I checked my segment one by one but none of them are set to "0"(I do have soem inertia like Ixx, Iyy, Izz set to 0.001, does it matter?).
sherm wrote:Hi, Andrew.

This message usually means that your mass or inertia properties were non-physical. You might want to check the modifications you made to see if you may have introduced a non-physical body.

Regards,
Sherm

Re: RRA Singular Matrix

Posted: Wed Nov 20, 2013 10:36 am
by sherm
Hi, Vincent.

Inertias of .001 are small but not singular so shouldn't cause the "singular matrix" problem. Are you sure you are getting the same error message as Andrew did? If you didn't change mass properties when going from open to closed topology then the mass matrix is unchanged. However, adding constraints introduces additional linear algebra and can fail for different reasons. Please say more about the changes you made and post the actual error text you are seeing. The lowest-level error "matrix is singular" can apply to different matrices depending on circumstances.

Regards,
Sherm

Re: RRA Singular Matrix

Posted: Wed Nov 20, 2013 12:22 pm
by daybreaklee
Hey Sherm,

Thank you so much for your prompt reply.
You are right, the error message is pretty similar to Andrew's but not exactly the same.
I figured out that part just now but I still got stuck in CMC. I will appreciate any help from you.
I ran fast tarket CMC, it failed and message panel showed me this:
"AssemblySolver::track() attempt Failed: SimTK Exception thrown at Assembler.cpp:913:
Method Assembler::track() failed because:
Unabled to achieve required assembly error tolerance.
Assembly error tolerance achieved: 2.69636668548401e-009 required: 1e-009.
Model unable to assemble: AssemblySolver::assemble() Failed: SimTK Exception thrown at Assembler.cpp:857:
Method Assembler::assemble() failed because:
Unabled to achieve required assembly error tolerance.
Assembly error tolerance achieved: 2.69636513117177e-009 required: 1e-009.
Model relaxing constraints and trying again.
...
...
try to use slow target mode or increase starting time"

I am trying slow mode, the CMC is running through but I do not think I will get good results since it is in slow target.
My model is a pedaling. I fixed pelvis and lumbar. Pelvis links to ground, Crank links to ground also. Pedal links to Crank and also have a WeldConstraint with calcn.
If you need files to help me, I can attach everything I have for CMC.

Again, I really appreciate your time.

Vincent
sherm wrote:Hi, Vincent.

Inertias of .001 are small but not singular so shouldn't cause the "singular matrix" problem. Are you sure you are getting the same error message as Andrew did? If you didn't change mass properties when going from open to closed topology then the mass matrix is unchanged. However, adding constraints introduces additional linear algebra and can fail for different reasons. Please say more about the changes you made and post the actual error text you are seeing. The lowest-level error "matrix is singular" can apply to different matrices depending on circumstances.

Regards,
Sherm

Re: RRA Singular Matrix

Posted: Wed Nov 20, 2013 1:01 pm
by sherm
The error message says:
Unabled to achieve required assembly error tolerance.
Assembly error tolerance achieved: 2.69636513117177e-009 required: 1e-009.
Model relaxing constraints and trying again.
Assembling to 3e-9 meters (that is, all constraints are satisfied to 3 nanometers) is an extremely good assembly. However, the required tolerance was 1 nm! It is very possible that the geometry of your system is not precise enough to achieve that level of perfection -- but that should not be necessary.

You should try this with a relaxed assembly tolerance, say 1e-6 or 1e-7 (1 or 0.1 micron). Unfortunately I do not know how that is specified in OpenSim. Does someone else know?

Alternatively you could try to make your geometry perfect if you can. Dimensions would need to be specified accurate to double precision, say 15 decimal places.

Re: RRA Singular Matrix

Posted: Wed Nov 20, 2013 1:30 pm
by daybreaklee
Thanks again for your advise. I tried to figure out something in CMC_setup file but failed. however, opensim online help mentions this:

API Improvements
•We updated the Coordinate class to the new property interface, improved its documentation and memory management, and added the propertyis_free_to_satisfy_constraints to allow dependent coordinates to assume any value necessary to satisfy constraints during the assembly of a model.

I was wondering maybe setting up that flag in each unlocked Coordinate class may work.

You mentioned:"Dimensions would need to be specified accurate to double precision, say 15 decimal places."
may I ask how to set uo double precision (15 decimal)?? can you explain a little bit more? I appreciate it.

Vincent
sherm wrote:The error message says:
Unabled to achieve required assembly error tolerance.
Assembly error tolerance achieved: 2.69636513117177e-009 required: 1e-009.
Model relaxing constraints and trying again.
Assembling to 3e-9 meters (that is, all constraints are satisfied to 3 nanometers) is an extremely good assembly. However, the required tolerance was 1 nm! It is very possible that the geometry of your system is not precise enough to achieve that level of perfection -- but that should not be necessary.

You should try this with a relaxed assembly tolerance, say 1e-6 or 1e-7 (1 or 0.1 micron). Unfortunately I do not know how that is specified in OpenSim. Does someone else know?

Alternatively you could try to make your geometry perfect if you can. Dimensions would need to be specified accurate to double precision, say 15 decimal places.

Re: RRA Singular Matrix

Posted: Wed Nov 20, 2013 4:28 pm
by sherm
You mentioned:"Dimensions would need to be specified accurate to double precision, say 15 decimal places."
may I ask how to set to double precision (15 decimal)?? can you explain a little bit more?
What I mean is that in the ".osim" file where the model is defined, there are many numbers such as the locations of joints and constraints. These numbers represent lengths and angles. In an open-topology system any set of numbers represents a valid model. But in a closed-topology system there can be interrelationships among the dimensions -- for example, if you form a loop then the orientations and lengths must be such that you can actually satisfy the loop constraint. So the accuracy with which you must define your model dimensions is much more strict for closed-topology systems.

So however you calculated the dimensions in your .osim file, if you rounded off to 6 decimal places (for example) that might not be enough to satisfy the loop closure constraints to 9 decimal places. Instead, if you calculate all the dimensions to 15 decimal places and put all 15 in the .osim file, you could achieve a more precise assembly tolerance.

Re: RRA Singular Matrix

Posted: Fri Nov 22, 2013 10:55 pm
by daybreaklee
Hello Michael,

Yes, I did modify them but fast mode target still can't be performed.
I fixed pelvis, lumbar and translation of crank. CMC still crushed. Then, I tried to reduce freedom of the model so what I did was: adding the motion, and then lock some freedom like mtp_angle, subtalar_angle, knee_adduction but the Messages panel showed me this:

Model unable to assemble: AssemblySolver::assemble() Failed: SimTK Exception thrown at Assembler.cpp:842:
Method Assembler::assemble() failed because:
Optimizer failed with message: SimTK Exception thrown at InteriorPointOptimizer.cpp:261:
Optimizer failed: Ipopt: Restoration failed (status -2)
Assembly error tolerance achieved: 1.66533453693773e-016 required: 1e-009.

I do not know how to solve this restoration failing but I am looking into it. In the mean time, can you give me some advise on this when you at your best convenience??

when I switch back to slow target mode to run it, it still failed and the message is:

Setting optimizer print level to 0.
Setting optimizer convergence tolerance to 0.0001.
Setting optimizer maximum iterations to 5000.

Setting cmc controller to not use verbose printing.

Computing initial values for muscles states (activation, length)
Start time = Sat Nov 23 00:41:51 2013

CMC.computeControls: t = 0.04
CMC.computeControls: t = 0.04
SimTK Exception thrown at InteriorPointOptimizer.cpp:261:
Optimizer failed: Ipopt: Maximum iterations exceeded (status -1)
OPTIMIZATION FAILED...

CMC.computeControls: WARN- The optimizer could not find a solution at time = 0.040000.
If using the fast target, try using the slow target.
Starting at a slightly different initial time may also help.

I really appreciate your help.

Vincent
sherm wrote:
You mentioned:"Dimensions would need to be specified accurate to double precision, say 15 decimal places."
may I ask how to set to double precision (15 decimal)?? can you explain a little bit more?
What I mean is that in the ".osim" file where the model is defined, there are many numbers such as the locations of joints and constraints. These numbers represent lengths and angles. In an open-topology system any set of numbers represents a valid model. But in a closed-topology system there can be interrelationships among the dimensions -- for example, if you form a loop then the orientations and lengths must be such that you can actually satisfy the loop constraint. So the accuracy with which you must define your model dimensions is much more strict for closed-topology systems.

So however you calculated the dimensions in your .osim file, if you rounded off to 6 decimal places (for example) that might not be enough to satisfy the loop closure constraints to 9 decimal places. Instead, if you calculate all the dimensions to 15 decimal places and put all 15 in the .osim file, you could achieve a more precise assembly tolerance.

Re: RRA Singular Matrix

Posted: Sat Nov 23, 2013 12:48 pm
by sherm
Strange that you are now getting assembly to a tolerance of 1e-16 (basically perfect) yet it is saying it failed. Does anyone know what might cause that?

I'm not sure it is a good idea to lock joint angles -- I would think that doesn't provide enough freedom to solve the problem but I'm not sure.

Sherm