|
From: | Pavel Hofman |
Subject: | Re: Independent parameters in nonlin_residmin |
Date: | Wed, 19 Dec 2018 22:46:33 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 |
Hi Olaf,Thanks a lot for your expert reply, I very much appreciate your help. Honestly, I am just a beginner with optimization functions and do not know exactly the internal procedure, please excuse my ignorance.
This is the problem - I need my function be called/asked/queried as few times as possible. Each two pairs of parameters (i.e. quadruples) affect only their corresponding 2 items in the residual array.
You talk about the plabel cell array with index of parameter whose partial derivative is currently computed - in my case the ideal solution would query/compute partial derivatives of all the quadruples (e.g. 10 quandruples) at once.
The function calculates FFT which generates values for all the frequencies at once. If the function is called for each frequency separately, the other frequency bins are still being determined and subsequently dropped/forgotten. Actually my problem is not the actual FFT calculation (light CPU load), but collecting samples for the FFT which cannot be sped up as the incoming sample rate is constant and limited.
Or if I could postpone returning the function result until all the params are asked about in the iteration cycle, and then call the actual determining code. I looked at the user_interaction setting, perhaps some multithreaded code blocking at the function until all the params are queried, then running the determination code and returning corresponding values to their respective threads... probably unfeasible.
Thanks a lot for your patience. Best regards, Pavel.
Hi Pavel, nonlin_residmin can't prevent your function from computing all residuals, your function itself has to prevent unnecessary computations. Your function needs some information for this -- this information is passed to it by nonlin_residmin. The following explanation assumes that you use the default gradient function of nonlin_residmin (the feature is not yet implemented for complex step derivatives). In your function, check (e.g. with nargin()) if it is called with a second argument. This will be the case if the function is called for gradient determination. The second argument will be a structure with a field "plabels". plabels{1}{1} should be the number of the parameter (its index in the parameter vector) whose partial derivative is currently computed. Your function doesn't need to compute residuals which are unaffected by this parameter, it can return a constant value for them. Olaf
[Prev in Thread] | Current Thread | [Next in Thread] |