From 906c2dee383a7eb72632bfbdf61916a576a5460d Mon Sep 17 00:00:00 2001 From: Bertrand Date: Sun, 21 Feb 2016 16:35:30 +0000 Subject: création de la struct f_mu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/opti.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/opti.cpp') diff --git a/src/opti.cpp b/src/opti.cpp index 702e8c2..23ddff3 100644 --- a/src/opti.cpp +++ b/src/opti.cpp @@ -1,8 +1,4 @@ -#include -#include -#include -#include -#include +#include "opti.hpp" double pos (double x){ return x>0?x:0; @@ -30,17 +26,17 @@ double f (const std::vector &X, std::vector &grad, void *params) -int main() { +std::vector argmax(double r, double T, double S0, double V, double K, int d){ - double params[5] = {0.05, 1, 50, 0.1, 45}; + double params[5] = {r, T, S0, V, K}; - nlopt::opt opt(nlopt::LN_COBYLA, 16); + nlopt::opt opt(nlopt::LN_COBYLA, d); opt.set_max_objective(f, ¶ms); opt.set_xtol_rel(1e-4); - std::vector x(16,0); + std::vector x(d,0); std::vector g(0); @@ -48,12 +44,8 @@ int main() { double maxf; nlopt::result result = opt.optimize(x, maxf); - for(int i=0; i<16; i++){ - std::cout<