There are many algorithms to optimize a function f(x) given by . Their run time is assessed by counting the number of times they evaluate f, the gradient of f, and the second gradient of f. Your task is to make a function that computes (and counts the number and type of function calls) for the function defined by
for a given value of n. Extend your function from part A to also compute the gradient and hessian when requested. The modification should follow relevant portions of part A. In addition
- The driver should read a sequence from standard in (as always redirectable from a file)
- i1 i2 i3 vectorfileformat
- i1 i2 i3 vectorfileformat
- i1 i2 i3 vectorfileformat
- ...
- The integers (i1 i2 i3 - which are either 0 or 1) indicate to compute f, and/or Df, and/or DDf respectively with 0 indicating compute and 1 indicating do not compute.
- Modify your procedure from part A to take three additional integer arguments (stored and passed as a typedef array of three integers) which computes and stores the requested values. For {1,1,1} the function should return the current counts of f, Df, and DDf evaluations in the typedef intgre structure.
- The output from the driver in main should be a list of the requested values (in the standard vector/matrix format we defined in class) printed to standard out followed by the total number of times each of f, Df, and DDf are called followed by a runtime in milli seconds.
- The function should be implemented in a separate file.
- You are not allowed to use global variables
- The code should be able to be run as "MyProg < in > out"
- You need to use either implicit rules or automatic variables in your makefile.
- Main should be brief and well documented.
- We will be exchanging this code.
- As always ask in class if you do not understand what the specifications say.
- There was a request for some test values for the input vector x.vec I get f=0.113663 and the gradient and hessian are in the files GradF.vec, and HessianF.mat respectively