diff options
| author | Bertrand <bertrand.horel@gmail.com> | 2016-02-21 16:35:30 +0000 |
|---|---|---|
| committer | Bertrand <bertrand.horel@gmail.com> | 2016-02-21 16:35:30 +0000 |
| commit | 906c2dee383a7eb72632bfbdf61916a576a5460d (patch) | |
| tree | e86bbaadc241b71b302591b64762f671d1e30940 /src/opti.cpp | |
| parent | 5ed1989db081c60c7be820a5ce58a170fd5f1f9c (diff) | |
| download | projet_C++-906c2dee383a7eb72632bfbdf61916a576a5460d.tar.gz | |
création de la struct f_mu
Diffstat (limited to 'src/opti.cpp')
| -rw-r--r-- | src/opti.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
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 <vector> -#include <nlopt.hpp> -#include <cmath> -#include <algorithm> -#include <iostream> +#include "opti.hpp" double pos (double x){ return x>0?x:0; @@ -30,17 +26,17 @@ double f (const std::vector<double> &X, std::vector<double> &grad, void *params) -int main() { +std::vector<double> 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<double> x(16,0); + std::vector<double> x(d,0); std::vector<double> 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<<x[i]<<std::endl; - } - std::cout<<"valeur à la fin : "<<maxf<<std::endl; - return 0; + return x; } |
