salvadorgarciamunoz / kipet

Development repository for Kipet.
GNU General Public License v3.0
20 stars 17 forks source link

Issue with parameter estimation involving dosing #152

Closed notesofdabbler closed 3 years ago

notesofdabbler commented 3 years ago

I was trying a fed batch reaction example. First, I tried simulating it and it worked fine (notebook). In this example, B is dosed in over 15 min and is set as a trajectory qin_B. However, when I tried to do parameter fitting for the same example (notebook), it is not fixing the trajectory for inflow qin_B. I wasn't sure if I need to do something different for parameter estimation.

kwmcbride commented 3 years ago

I have recreated your problem and think this is a bigger problem than it seems. I suspect that ParameterEstimator does not have any information regarding the fixed trajectories and therefore is overfitting the problem. I am looking into a fix for this now.

kwmcbride commented 3 years ago

I have fixed the issue. It was as I suspected. I will make a pull request for this fix now. In the mean time, you can simply add the following to the end of the create_estimator method in ReactionModel:

    self._from_trajectories(estimator)
notesofdabbler commented 3 years ago

Happy New Year. Thanks for a very quick fix. I tried adding the line you suggested and it works. Also, I noticed that each time I import KipetModel, I get the following warning message.

WARNING: DEPRECATED: The pyomo.core.base.sets module is deprecated.  Import
    Set objects from pyomo.core.base.set or pyomo.core.  (deprecated in 5.7)
    (called from <frozen importlib._bootstrap>:219)
_SetProduct not found

It doesn't impact anything currently but wanted to bring it to your attention.

kwmcbride commented 3 years ago

Happy New Year to you too. Which version of Pyomo are you using?

notesofdabbler commented 3 years ago

I am using pyomo version 5.7.1. I have also listed below the screenshot.

Screen Shot 2021-01-03 at 9 14 44 PM
kwmcbride commented 3 years ago

This is the expected behavior at the moment. In the fe_factory module it checks for _SetProduct or SetProduct depending on which version of pyomo is being used. So, there is nothing wrong, but it could be improved to avoid showing any message.

kwmcbride commented 3 years ago

Fixed in #153

kwmcbride commented 3 years ago

For your information, I have included a modified example of this problem as a new example problem in KIPET. See my branch nsd_new for more details. It replaces the fixed trajectory with a step function. This new arrangement also allows you to fit the switching time as well.