anchor.diff:        (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")
  +	;;(addipoptnumoption nlp "tol" 1d-9)
  +	(addipoptintoption nlp "max_iter" 1000)
  +	;;(addipoptstroption nlp "mu_strategy" "adaptive")
   	;;(addipoptstroption nlp "hessian_approximation" "limited-memory")
   	(addipoptstroption nlp "jacobian_approximation" "finite-difference-values")
   	
  
positive.code:     (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)
  
negative.code: 
  	;; Solve problem
  	(ipoptsolve nlp x (null-pointer) obj (null-pointer) mult_x_l mult_x_u (null-pointer))
  	(let* ((xv (from-foreign-vector x :double n))
  	       (f (mem-ref obj :double))
  	       (g (sail2d-g xv))
  	       (traj (sail2d-integrate xv)))
  	  (export-trajectory traj "sail2d_traj.dat")
  	  (values xv f g))
  	))))
  
  (defun export-trajectory (traj file)
    (with-open-file (s file :direction :output :if-exists :supersede)
      (loop for (tm x) in traj
         do (format s "~a ~a ~a ~a ~a~%" tm (aref x 0) (aref x 1) (aref x 2) (aref x 3)))))
  