So, the first argument is a function on any one passing through AD to one AD . For a passing one, we can replace something like a list to begin with. This function must be polymorphic in mode. Therefore, let it ignore it and simply do not do what the regime determines! This feature is obviously what we are optimizing. The next argument is the initial value that we pass. We will also call it a list. And the result is a list of steadily more optimized choices to improve guesswork for our purpose.
Note that AD sa is an instance of Num and Fractional for all s modes if a is equal to Num and Fractional . Therefore, just write a polymorphic function from a list of integers into a single integer, go to the initial state, and the function you provide will optimize it for you.
those. do not indicate your cost function as more double, but indicate it as polymorphic over any Num and Fractional , and let the library take care of the rest!
You may prefer to get used to this style by first trying out other, more basic functions, such as diff .
source share