In [1]:
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
from simmit import smartplus as sim
from simmit import identify as iden
import pandas as pd
import os
from shutil import copyfile

from scipy.optimize import minimize

dir = os.path.dirname(os.path.realpath('__file__'))
number = mnumber;
value = mvalue;
input_values = arma2numpy::array2vec(minput_values);
key = mkey;
ninput_files = mninput_files;
input_files = arma2numpy::py_list_to_std_vector_string(minput_files);

In [6]:
nparams = 5

param_list = iden.read_parameters(nparams)

#The array of parameters
p = np.zeros(nparams)

for param in param_list:
    param.value = (param.min_value + param.max_value)/2.0
    p[param.number] = param.value

#outputfile = dir + '/' + sim_file
#pathfile = dir + '/path.txt'

#Replace the constants
res = minimize(iden.cost_solver, p,  method='nelder-mead', options={'xtol': 1e-8, 'disp': True})
#res = minimize(sim_solver, p,  method='Powell', options={'xtol': 1e-8, 'disp': True})
#res = minimize(sim_solver, p, method='CG')
#res = minimize(sim_solver, p,  jac=None, hess=None, method='BFGS', options={'disp': True})

print(res)


Optimization terminated successfully.
         Current function value: 0.000000
         Iterations: 278
         Function evaluations: 578
 final_simplex: (array([[  3.10339954e+04,   4.56900294e+03,   6.50004710e-02,
          2.65090413e-01,   1.99999810e+03],
       [  3.10339954e+04,   4.56900294e+03,   6.50004710e-02,
          2.65090413e-01,   1.99999810e+03],
       [  3.10339954e+04,   4.56900294e+03,   6.50004710e-02,
          2.65090413e-01,   1.99999810e+03],
       [  3.10339954e+04,   4.56900294e+03,   6.50004710e-02,
          2.65090413e-01,   1.99999810e+03],
       [  3.10339954e+04,   4.56900294e+03,   6.50004710e-02,
          2.65090413e-01,   1.99999810e+03],
       [  3.10339954e+04,   4.56900294e+03,   6.50004710e-02,
          2.65090413e-01,   1.99999810e+03]]), array([  7.02717999e-12,   7.02717999e-12,   7.02717999e-12,
         7.02717999e-12,   7.02717999e-12,   7.02717999e-12]))
           fun: 7.027179987906417e-12
       message: 'Optimization terminated successfully.'
          nfev: 578
           nit: 278
        status: 0
       success: True
             x: array([  3.10339954e+04,   4.56900294e+03,   6.50004710e-02,
         2.65090413e-01,   1.99999810e+03])

In [8]:
print(param_list[0].value)
print(param_list[1].value)
print(param_list[2].value)
print(param_list[3].value)
print(param_list[4].value)


25000.0
4500.0
0.155
0.155
4500.0

In [ ]: