Prev | Next |
p_0 , ... , p_{np-1} ,
x_0 , ... , x_{nx-1} ,
c_0 , ... , c_{nc-1} ,
r_0 , ... , r_{no-1}
p_0, ... , p_{np-1}
is the independent dynamic parameter vector;
see n_dynamic_ind
.
The node index corresponding to
p_0
is 1
.
x_0, ... , x_{nx-1}
is the independent variable vector;
see n_variable_ind
.
The node index corresponding to
x_0
is
the index corresponding to
p_0
plus
np
.
c_0, ... , c_{nc-1}
is the constant parameter vector;
see constant_vec
.
The node index corresponding to
c_0
is
the index corresponding to
x_0
plus
nx
.
i=0,...,no-1
the sub-vector r_i
is the result vector for the i
-th operator usage;
see op_usage_vec
.
The value
no
is the number of operator usages; see
n_usage
below.
All of the arguments for an the i
-th operator are nodes
that come before the first element of
r_i
.
The node index corresponding to the first element of
r_0
is
the index corresponding to
c_0
plus
nc
.
For
i > 0
,
The node index corresponding to the first element of
r_i
is
the index corresponding to the first element of
r_{i-1}
plus
the number of results for the i-1
-th operator.
0123456789
.
0123456789+-eE.
.
Note that there can't be any white space between a leading plus
or minus sign and the rest of the number.
"
and includes all the characters until the next double quote.
The value of a string is the sequence of characters between the
double quotes.
Currently there is no support using the double quote
as part of the value of a string.
Token | Usage |
, | separates entries in a list |
: | separates name from corresponding value |
{ |
starts a list of name : value pairs |
} |
ends a list of name : value pairs |
[ | starts a list of values |
] | ends a list of values |
[ n_define, [ first_op_define, ..., last_op_define ] ]
where the non-negative integer
n_define
is the number of operator definitions in this vector.
op_define
are listed in
section json_graph_op
.
If an operator has a fixed number of arguments, one result, and
only node indices for arguments, its definition has the form
{
"op_code": op_code,
"name": name,
"n_arg": n_arg
}
Otherwise the operator definition has the form
{
"op_code": op_code,
"name": name
}
For example, the following is the
op_define
corresponding to the
add
operator:
{
"op_code": op_code,
"name": "add",
"n_arg": 2
}
op_code
value.
These values must start at one and increment by one for each operator
definition; i.e., the
op_code
for in
first_op_define
is
1
, the value in the next definition is 2
, and so on.
The order of the definitions determines the
op_code
values
used to specify operators for this computational graph.
n_arg
is present in an operator definition,
n_result
is one for every usage of the operator.
Otherwise it is specified by the operator usage.
n_arg
is present in an operator definition,
it is not in a corresponding
op_usage
which as the form
[ op_code, first_arg, ..., last_arg ]
n_arg
is not in an operator definition,
it is in a corresponding
op_usage
.
If there are no strings in a corresponding usage, it has the form
[ op_code, n_result, n_arg, [ first_arg, ..., last_arg ] ]
n_arg
is not in an operator definition,
and there are strings in a corresponding usage,
a corresponding usage has the form
[ op_code, first_str, ..., last_str, n_result, n_arg,
[ first_arg, ..., last_arg ]
]
where
first_str
...,
last_str
,
are a fixed number of strings that are part of the corresponding operator.
first_arg
, ...,
last_arg
,
are the node indices corresponding to each of the arguments for this operator.
They must be less than the node index corresponding to the first
result for this operator; see
r_i
above.
They specify which previous results (results before this operator in the graph)
correspond to each of the arguments to this operator.
As a consequence, there cannot be any cycles in the graph where
the operators are represented by arcs from the argument to the result nodes;
i.e., the graph is acyclic.
p
above); see
dynamic
.
The function can depend on these parameters,
but no derivatives are computed with respect to these parameters.
n_dynamic_ind
for the number of elements in this vector
(called
np
above).
x
above); see
x
.
The function can depend on these variable and
derivatives can be computed with respect to these variables.
n_variable_ind
for the number of element in this vector
(called
nx
above).
c
above).
These parameters can be used to define the function and cannot change.
The Json format for
constant_vec
is
[ n_constant, [ first_constant, ..., last_constant ] ]
Each of the elements of this vector,
e.g.,
first_constant
,
is a floating point number
specifying the value for the corresponding node.
n_constant
is the number of elements in this vector
(called
nc
above).
op_usage_vec
is
[ n_usage, [ first_op_usage, ..., last_op_usage ] ]
Each of the elements of this vector,
e.g.
first_op_usage
,
is an op_usage
.
n_usage
is the number of operator usages (called
no
above).
dependent_vec
is
[ n_dependent, [ first_dependent, ..., last_dependent ] ]
Each of the elements of this vector,
e.g.
first_dependent
,
is a non-negative integer
corresponding to a node index in the graph.
n_dependent
is the number of elements in this vector.
function_name
is a
string
that is used to identify
the function.
{
"function_name": function_name,
"op_define_vec": op_define_vec,
"n_dynamic_ind": n_dynamic_ind,
"n_variable_ind": n_variable_ind,
"constant_vec": constant_vec,
"op_usage_vec": op_usage_vec,
"dependent_vec": dependent_vec
}
This represents a the @(@
y = f(x, p)
@)@ where
@(@
p
@)@ is the dynamic parameter vector,
@(@
x
@)@ is the independent variable vector, and
@(@
y
@)@ is the dependent variable vector.
json_graph_op | Json AD Graph Operator Definitions |
from_json | ADFun Object Corresponding to a Json AD Graph |
to_json | Json AD Graph Corresponding to an ADFun Object |
json_get_started.cpp | Json Get Started: Example and Test |
json_sparse.cpp | Json Representation of a Sparse Matrix: Example and Test |