Commit new share package nelder_mead: Nelder-Mead algorithm for minimization without...
[maxima.git] / share / nelder_mead / nm-maxima.lisp
blobef9c0d22fc16213fb34f31a5a3e637c9c85643d9
1 (defun $nelder_mead (expr vars init)
2 (let* ((fun (coerce-float-fun expr vars))
3 (fun1 (lambda (arr)
4 (mfuncall '$apply fun `((mlist simp) ,@(loop for i across arr collect i)))))
5 (init (make-array ($length init) :initial-contents (cdr ($float init)))))
6 (multiple-value-bind
7 (xk fk fv) (neldermead:grnm-optimize fun1 init :verbose nil)
8 (declare (ignore fk fv))
9 `((mlist simp) ,@(mapcar #'(lambda (x y) `((mequal simp) ,x ,y))
10 (cdr vars)
11 (loop for i across xk collect i))))))