2

I am using IPOPT in MATLAB to run an optimization and I am running into some issues where it says:

 Hessian must be an n x n sparse, symmetric and lower triangular matrix 
with row indices in increasing order, where n is the number of variables.

After looking at my Hessian Matrix, I found that the non-symmetric elements it is complaining about are very close, here is an example:

H(k,j) =    2.956404205984938

H(j,k) =    2.956404205984939

Obviously these elements are close enough and there are some numerical round-off issues or something of the like. Also, when I call MATLABs issymmetric function with H as an input, I get false. Is there a way to forget about these very small differences in symmetry?

A little more info:

I am using an optimized matlabFunction to actually calculate the entire hessian (H), then I did some postprocessing before passing it to IPOPT:

H = tril(H);
H = sparse(H);

The tril command generates a lower triangular matrix, so these numeral differences should not come into play. So, the issue might be that it is complaining that the sparse command passes back increasing column indices and not increasing row indices. Is there a way to change this so that it passes back the sparse matrix in increasing row indices?

1 Answers1

3

If H is very close to symmetric but not quite, and you need to force it to be exactly symmetric, a standard way to do this would be to say H = (H+H')./2.

Sam Roberts
  • 23,951
  • 1
  • 40
  • 64