I am trying to suppress all text output to the screen when running ID from the Matlab API. I have tried using the getVerboseLevel/setVerboseLevel methods as in the following code, but it does not work. Can anyone help identify what I might be doing wrong? --Thanks, Bill
%API calls to run ID from Matlab
import org.opensim.modeling.*
idTool = InverseDynamicsTool(IDSetup_File);
IDModel = Model(Model_File);
IDModel.initSystem();
%only process 1 frame of data each iteration for efficiency
idTool.setStartTime(CurrTime);
idTool.setEndTime(CurrTime);
%Suppress output text to screen during ID
vLevel=idTool.getVerboseLevel();
vLevel.swigToEnum(0);
idTool.setVerboseLevel(vLevel);
idTool.run();
Turn off text to screen during API calls to Inverse Dynamics
- William Thompson
- Posts: 17
- Joined: Mon Jun 25, 2012 7:07 pm
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Turn off text to screen during API calls to Inverse Dynamics
What version of OpenSim are you using? I don't see anything displayed in the MATLAB Command Window with the Tools in OpenSim 4.0. Regardless, have you tried MATLAB's "evalc()" function?
- William Thompson
- Posts: 17
- Joined: Mon Jun 25, 2012 7:07 pm
Re: Turn off text to screen during API calls to Inverse Dynamics
Thanks, Tom, evalc() works, but I am not seeing much improvement in speed in my optimizer code. So i will look for other ways to speed things up.
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: Turn off text to screen during API calls to Inverse Dynamics
Printing to the MATLAB Command Window is not likely to be taking much time (unless you're printing a lot of text). Also note that eval() has some overhead (see https://www.mathworks.com/help/matlab/m ... ation.html). If you're trying to improve the speed of your optimization code, you might check things like the following:evalc() works, but I am not seeing much improvement in speed in my optimizer code.
- avoid unnecessary calls to initSystem() (if possible, create the underlying System once and pass the State around)
- avoid unnecessarily creating and destroying OpenSim objects (e.g., within the objective function)
You might try using MATLAB's tic/toc functions to track down the most expensive lines of code.