Unknown Auxiliary Input is categorical number
A MATLAB Automatic Differentiation Tool
Brought to you by:
anilvrao2,
weinstein87
Hi there,
In my function, I input a Unknown Auxiliary Input (categorical number) which is used to extract which column of matrix dynamically. But, the adigatorGenJacFile evaluate my function with random number (continuous number) and then failed to generate derivatives. How can I resolve it?
Example:
Following is my function:
Another question:
How can I allow for Inf for adigatorCreateAuxInput? Like
adigatorCreateAuxInput([Inf 1]) or even adigatorCreateAuxInput([Inf Inf])
Thanks!
Hi,
For the first question:
- Currently there is no way to turn off the random sampling mechanism - this could pose an issue for some problems where it is expected that an input will be within some bounds. I should make this an option.
- Unfortunately, even if you were to turn off that mechanism, the tool would not be able to figure out the reference using an unknown numeric object (prob = temp(:,resInd);). -This is something which is feasible to code up, but would take some work. It would amount to having subsref/subsasgn union the derivative sparsity patterns which result from all possible values of the reference indices. This would grow in complexity as the referenced variable and/or the reference index increase in size.
- The least klugey, most general, solution would be to write a wrapper for the adigator generated function which performs the reference on the Jacobian.
- If you are only using a scalar reference index which can only take on a limited number of values (2 in the example), then you may consider using an if/else statement:
Where you just want to make sure that it will run with a random number as the input.
For your second question:
- You can allow one dimension of an auxiliary object to be vectorized by identifying its size at Inf as you showed. Example
where
Matt
Last edit: Matthew J. Weinstein 2016-03-16