Package: estim8Beta
Project Description: Estim8Estim8is a tool for parameter estimation of differential-algebraic models (DAEs) using either model formulations in Dymola (installation required) or FMU models. It uses global meta-heuristic optimization to solve parameter estimation problems, and provides methods for uncertainty quantification.InstallationThe installation viapip install estim8Betais problematic, since the required PyGMO package is not available here. If you still installed this package via PyPI make sure to add PyGMO to your environment, using:$ conda config --add channels conda-forge$ conda config --set channel_priority strict$ conda install pygmoAlternatively, estim8 can be installed via conda-forge directly:conda install -c conda-forge estim8UsageThe workflow ofestim8can be divided into 5 steps:Initializing the modelDefining Estimation PrerequisitesStarting EstimationConducting Uncertainty QunatificationVisualize Results1. Initializing the ModelTo initialize a model, use the classDymolaModel(), orFmuModel()depending on your model formulation, and initialize it:MyModel=FmuModel('MyModel')MyModel.initialize()After the initialization all information on parameters and variables of the model are retrieved, and it can be simulated by thesimulate()method:Results,Parameters=MyModel.simulate(0,20,0.1,#(t0, t_end, stepsize)parameter={"par1":10},observe=["Trajectory1","Trajectory2"],tolerance=1e-4,)Where the 3 positional arguments in the beginning form the timevector to simulate (similar to numpy.linspace()).2. Defining Estimation PrerequisitesTo conduct a parameter estimation, it is necessary to provide at least:A model as FmuModel or DymolaModelExperimental data to fit the parameters to (as pandas.DataFrame with time as index and columns as variable names. For Replicates: {'Rid1':pd.DataFrame, ..., 'RidN':pd.DataFrame} )Boundaries for the parameters to estimateA dictionary, mapping the names of the experimental data columns to the variables of the model (observation_mapping)Optional the following settings can be made:Metric for the discrepancy ('SS': Sum of squares, 'WSS' Weighted sum of squares, 'negLL': negative Log-Likelihood)ParameterMapping and Replicate IDs if multiple replicates or experiments are includedCustom time vector in case a finer discretization as 0.1 is requiredExample Code:# Data importimportpandasMyData=pandas.read_excel('MyExpermentalData.xlsx',index_col=0,header=[0,1],sheet_name=None)# Bound definitionbounds={"par1":[8,12],"par2":[0.1,0.4],}# Observation mappingobs_map={"ExpDat1":"Obs1",}After specifying the prerequisites, theEstimator()can be instantiated:MyEstimator=Estimator(MyModel,data=MyData,bounds=bounds,observation_mapping=obs_map,)3. Starting EstimationFor the estimation process there are 2 possibilities, which areestimate()andestimate_parallel(). Both return an optimal parameter vector according to the specifiedbounds, and aninfostruct:# Single Coreoptimum,info=MyEstimator.estimate(method='local',# optimization methodp0={'par1':10,'par2':0.25},# initial pntmax_iter=20,# maximum iterations)# Paralleloptimum,info=MyEstimator.estimate_parallel(method='de',# optimization methodn_workers=4,# number of parallel proc.max_iter=20,)# Parallel (PyGMOs generalized island approach)optimum,info=MyEstimator.estimate_parallel(method=['pg_de1220','pg_sga']*2,# Islandsn_workers=4,# overwritten by no. islandsmax_iter=20,)4. Uncertainty QunatificationFor UQ estim8 providesprofile_likelihood()method, and classical Monte Carlo sampling methodmc_sampling().# MC samplingMC_Samples=MyEstimator.mc_sampling(method=['pg_sea']*4,# Optimization methodn_samples=200,# No. samplesevos2reset=50,# No. Iter until RAM reset# Terminate after:no_progress=10,#10 iters w.o. progresstot_iter=200,#More than 200 itersfinal_loss=500,#If loss of 500 is reached}5. Visualize ResultsFor visualization of the results, the following automated plotting functions are available in theVisualizationmodule:FunctionArgumentsDescriptionVisualization.plot_sim()Results, observe=[]Plots simulation trajectories generated by aEstim8ModelVisualization.plot_estimates()optimum, MyEstimator, data=None, only_measured=FalsePlots simulation trajectories of optimum in comparison to experimental dataVisualization.plot_correlations()MC_Samples, thresholds=5, show_vals=FalsePlotting the correlations for parameter results of a Monte Carlo Sampling as a heatmapVisualization.plot_distribution()MC_Samples, bins=5, est=MyEstimatorCreates a corner plot showing historgrams for parameter values on the diagonal, and scatter plots between parameter pairs on the LTMVisualization.plot_many()MC_Samples, MyEstimator, observe=[]Plots all trajectories resulting from the MC samples together with the experimental dataVisualization.plot_bound_violation()Optimum, boundsShows relative location of optimum within the bounds