ampl_eval_sp_g — evaluate the gradient of the objective function and the sparse Jacobian of the constraints of a given AMPL problem
[g, spjac] = ampl_eval_sp_g(asl, x)
the point where we evaluate the gradient and the Jacobian
a structure which handles the pointer to the problem
a vector which contains the value of the gradient (length: n_var)
a sparse matrix which contains the value of the transpose of the Jacobian (dimension: n_var x n_constr)
Evaluate the gradient of the objective function and the sparse Jacobian of the constraintsof a given AMPL problem. Be careful, the "Jacobian matrix" corresponds to the transpose of the reel Jacobian. It has [nb_constr x nb_var] as dimensions.
[asl, x0, bl, bu, v, cl, cu] = ampl_init('demos/data/ASL/ch03.nl'); [g, jac] = ampl_evalg(asl, x0); [spg, spjac] = ampl_eval_sp_g(asl, x0); printf('Difference between Jacobian and sparse Jacobian = %f\n', norm(jac - spjac')); ampl_free(asl); // free the memory