Page 1 of 2

Optimizer error message

Posted: Fri Aug 07, 2015 2:56 am
by ex10192
Hi,

I was performing an Optimization and it exited with an error message. Could someone kindly tell me the meaning.

69580D60SimTK Exception thrown at InteriorPointOptimizer.cpp:261:
Optimizer failed: Ipopt: Insufficient memory (status -102)

Is it related to optimiser or my computer memory?

Thanks,

Nithin

Re: Optimizer error message

Posted: Fri Aug 07, 2015 9:13 am
by sherm
Hi, Nithin. I looked in the code and that message is generated as a result of a C++ std::bad_alloc exception, very likely meaning that the maximum available memory was already in use. This usually means there is a memory leak somewhere -- you are using up memory but never freeing it. Likely something is being allocated at every objective function evaluation during the optimization but then not freed at the end of the evaluation.

This error does not mean your computer has insufficient hardware; it is a software issue.

Regards,
Sherm

Re: Optimizer error message

Posted: Fri Aug 07, 2015 10:10 am
by ex10192
Dear Sherman,

Thank you so much for your reply, I absolutely have no idea how to solve it. I will check the objective function and hopefully find the error.

Thanks again,

Nithin

Re: Optimizer error message

Posted: Fri Aug 07, 2015 10:37 am
by chrisdembia
Do you use `new SomeObject()` in your objective function? This would be the place to start. Sometimes you need a corresponding `delete obj`, but sometimes you pass that "new" object into another object that will take ownership of it (which means it will get deleted for you).

Are you using OpenSim? There are some memory leaks in OpenSim as well, but they are minor and would not use up all your memory unless you only get that error after *many* iterations.

Re: Optimizer error message

Posted: Fri Aug 07, 2015 10:52 am
by ex10192
Dear Chris,

I have two analysis where I have used the pointers to access the members.

1. ForceReporter* reporter = new ForceReporter(&osimModel);
2. BodyKinematics* BK = new BodyKinematics(&osimModel);

then,

since I am doing a forward optimization I also have the prescribedcontroller

PrescribedController *control = new PrescribedController();
PrescribedController* controller_r = dynamic_cast<PrescribedController*>( &controllerSet.get(i) );

Apart from this I also have an event handler, and I also notice this was set to 500
opt.setLimitedMemoryHistory(500);

Thanks

Nithin

Re: Optimizer error message

Posted: Fri Aug 07, 2015 9:01 pm
by jp123909
I have the similar problem before.
delete reporter when you dont need it.
OpenSim will not delete it for us. (Tested in OpenSim3.2)

Re: Optimizer error message

Posted: Sun Aug 09, 2015 9:37 am
by chrisdembia
Jiang is right. I'm not sure how you're using those reporters, but if you don't pass them to any other object then you should delete them yourself. If you pass them to a Model, the model might delete them for you. Also, are you sure you need to dynamically allocate the reporters?

Do you add the PrescribedController to the model? If so, the Model should take care of deleting it.

The "limited memory history" is not about C++ memory management; it has to do with the operation of the optimizer algorithms.

Re: Optimizer error message

Posted: Sun Aug 09, 2015 10:07 am
by ex10192
Dear chris and Jiang,

Thanks for your replies, As per jiang's suggestion, I have added the removeAnalysis(*,true) , once I have collected the data and before the start of next iteration.

Chris,I dont pass the reporters through any other objects- so I assume that I have to remove them [ Would have been great if it was added to documentation].

I have also used delete 'obj' for a motion Prescriber I have used as per your suggestion.I have included the PrescribedController to model,so hope including too many parameters for optimization wont lead to memory leak.

Also- a doubt on the limitedmemoryHistory, I wasnt able to find documentation that mentions the upper or lower limits we could set for these optimizer algorithms, also if it was possible to pass parameters other than opensim actuators through the optimizer.

thanks again for your replies,

nithin

Re: Optimizer error message

Posted: Mon Aug 10, 2015 2:43 pm
by chrisdembia
Nithin:

I'm a little confused by your latest response. I'm not sure if you are using "motion Prescriber" and "PrescribedController" refer to the same thing, since there is also a separate concept of "prescribed motion" in OpenSim and Simbody.

I'm also not sure why having more parameters in the optimization would increase the number of memory leaks; is this just because the optimizer would likely run for longer or that you're using a larger population size?

As for your question about upper/lower limits, could you rephrase? I'm not sure what you're asking.

Re: Optimizer error message

Posted: Mon Aug 10, 2015 4:29 pm
by ex10192
Dear chris,

Really sorry for creating confusion, in my code I have prescribed a motion for a coordinate, and during each iteration I update the values. I understand that prescribed controller and motion prescriber are different concepts.

Chris, what I asked about the optimizer setting was that, we have these
eg.
opt.setMaxIterations(1000);
opt.setLimitedMemoryHistory(500);

Just wanted to know, what is the highest number of iterations we can provide or is 1000 iterations the highest setting for this optimizer or is it just a default value.

Another doubt about optimizer- Is it possible to pass parameters that are not opensim actuators for optimizing, ie, I have some shape parameters which I would like to optimize along with muscle excitations, but is it possible as most examples about optimization includes torque and muscle excitation.

Thanking you again and hope I havent caused more confusion.

Thanks