anchor.diff:      (setf (mem-aref grad_f :double i) 0d0))
     (setf (mem-aref grad_f :double (1- n)) 1d0)
     1)
  -  
  +
   (defclass sail-data ()
     ((mu :initarg :mu)
      (lightness :initarg :lightness)
  
positive.code:       (let ((nlp (createipoptproblem n x_l x_u m g_l g_u (length (jacobian-structure m n)) (length (hessian-structure n)) 0 (callback sail2d_f) (callback sail2d_g) (callback sail2d_grad_f) (callback sail2d_jac_g) (callback sail2d_h))))
  
  	;; Set options
  	(addipoptnumoption nlp "tol" 1d-9)
  	(addipoptintoption nlp "max_iter" 100)
  	(addipoptstroption nlp "mu_strategy" "adaptive")
  	;;(addipoptstroption nlp "hessian_approximation" "limited-memory")
  	(addipoptstroption nlp "jacobian_approximation" "finite-difference-values")
  	
  
negative.code:        for xfi = (second (car (last res)))
         append res)))
  
  (defun sail2d-g (x)
    (let ((rf 1.5d0)
  	(vrf 0d0)
  	(vtf 0d0)
  	(xf (second (car (last (sail2d-integrate x))))))
      (vector (- rf (aref xf 0))
  	    (- vrf (aref xf 2))
  	    (- vtf (aref xf 3)))))
  
  (defcallback sail2d_g :int ((n :int) (x :pointer) (new_x :int) (m :int) (g :pointer))
    (let ((gv (sail2d-g (from-foreign-vector x :double n))))
      (set-foreign-vector gv g :double m))
    1)
  
  (defcallback sail2d_jac_g :int ((n :int) (x :pointer) (new_x :int) (m :int) (nele_jac :int) (irow :pointer) (jcol :pointer) (values :pointer))
    (assert (null-pointer-p values)) ; always estimate Jacobian
    ;; Return Jacobian structure: m x n: 3 x n
    (set-structure (jacobian-structure m n) irow jcol)
    1)
  
  (defcallback sail2d_h :int ((n :int) (x :pointer) (new_x :int) (obj_factor :double) (m :int) (lmb :pointer) (new_lmb :int) (nele_hess :int) (irow :pointer) (jcol :pointer) (values :pointer))
    (if (null-pointer-p values)
        ;; Return Hessian structure: n x n
        (set-structure (hessian-structure n) irow jcol)
        ;; Otherwise return Hessian
        (dotimes (i nele_hess)
  	(setf (mem-aref values :double i) 0d0)))
  