-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ODEModel with constraints gives error #282
Comments
Constraints should not always be of the same type as their parent model apparently. As a workaround, could you try to create a constraint like this? cons = Model.as_constraint(sf.Eq(a+b, 0.055), ode_model)
constraints = [cons] I'm unable to try it myself at the moment, unfortunately. As an aside, this is not the best way of solving this: you're better of expressing |
Hm, that gives a key error: import numpy as np
import symfit as sf
tdata = np.array([10, 26, 44, 70, 120])
adata = 10e-4 * np.array([44, 34, 27, 20, 14])
a, b, t = sf.variables('a, b, t')
k = sf.Parameter('k', 0.1)
a0 = 54 * 10e-4
model_dict = {
sf.D(a, t): - k * a**2,
sf.D(b, t): k * a**2,
}
ode_model = sf.ODEModel(model_dict, initial={t: 0.0, a: a0, b: 0.0})
cons = sf.Model.as_constraint(sf.Eq(a, 0.055-b), ode_model)
constraints = [cons]
fit = sf.Fit(ode_model, t=tdata, a=adata, b=None, constraints=constraints)
fit_result = fit.execute()
print(fit_result)
(And yes, this is a toy problem. The real problem is related to this: #284 |
…Add initial parameters to connectivity_mapping Fixes tBuLi#282
…Add initial parameters to connectivity_mapping Fixes tBuLi#282
Adding constraints to the fitting of an ODEModel raises an error,
__init__() missing 1 required positional argument: 'initial'
Taking the simple coupled ODE model from the docs and adding an equality constraint to the variables (one that will necessarily be true anyways) gives the following output:
The text was updated successfully, but these errors were encountered: