I'm using pyfmi for loading the Modelica generated model in Python. Once I load the model I want to perform an optimization and parameter estimation. The issue is that for every parameter estimation (optimization iteration) the FMU needs to be loaded ususally it needs around 300-400 itterations but it is not converging because of binary loading error.Where should I look for soultions? Any hints are welcome.
def fun2optim(theta):## Funtion to optimize with the initial guess of paramameter values theta
model = load_fmu("MOdel_0IV_0curves.fmu")## LOAD THE FMU
res = model.simulate(input=foo(theta),final_time=1)
results_VV=np.array([]) ###SAVE THE OUTPUT IN ARRAY
for i in range(200,400):
out=(res[output_IV[i]])
results=out[0::5] #Dymola FMU has 5 same IV curve points
results_VV=np.append(results_VV,results)
return(results_VV)
def RMSE (theta): ## results_V are the ideal values
tt=sum(np.sqrt((fun2optim(theta)-results_V)**2).mean())
return(tt)
from scipy import optimize
res11=optimize.minimize(RMSE,thetaInit,method='nelder-mead', options={'xtol': 1e-4, 'disp': True})
After 50-60 itterations I got an error:
FMUException: Error loading the binary. Could not load the DLL: A dynamic link library (DLL) initialization routine failed.