-
Notifications
You must be signed in to change notification settings - Fork 2
/
jacobian.py
44 lines (34 loc) · 1.43 KB
/
jacobian.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np
from g_dfovec_1d import g_dfovec_1d
def jacobian(m, n, x, nprob):
"""
This subroutine computes the Jacobian of the nonlinear equations
defining the benchmark problems in
Benchmarking Derivative-Free Optimization Algorithms
Jorge J. More' and Stefan M. Wild
SIAM J. Optimization, Vol. 20 (1), pp.172-191, 2009.
The latest version of this subroutine is always available at
https://github.com/POptUS/BenDFO/
The dependencies of this function are based on a Python translation of
the Matlab AD software "adimat" on a modified form of the dfovec function
from
http://www.mcs.anl.gov/~more/dfo/
See the instructions of dfovec.m for additional details on these
nonlinear benchmark problems (and appropriate values of m and n).
J is an output array of size m-by-n, with J(i,j) denoting the
derivative (evaluated at x) of the ith equation with respect to
the jth variable.
fvec returns the usual dfovec
m and n are positive integer input variables. n must not
exceed m.
x is an input array of length n.
nprob is a positive integer input variable which defines the
number of the problem. nprob must not exceed 22.
"""
t = 0
g_t = 1
J = np.zeros((m, n))
for ind in range(n):
g_fvec, fvec = g_dfovec_1d(g_t, t, ind, m, n, np.zeros(x.shape), x, nprob)
J[:, ind] = g_fvec
return J, fvec