-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Using nonlinear expressions in multiple models? #473
Comments
Given the design of variables being tied to models, it's hard to see how this can easily work. I think Casadi enables you to mix and match pieces in this way. You basically have to pass values back and forth across the models, but there are probably way to wrap this up to make it less painful. |
What do you think about using the same model but creating different
I tried this out on a simple example and it seems to work in the sense of giving you objective values and first and second derivatives with respect to the different objective functions, but I don't know if this violates some hidden design decision I'm unaware of. |
Sneaky. It looks like this particular case is safe at the moment, but I can't guarantee that it will be in the future. Some of the evaluation callbacks refer to the original model (e.g., for nonlinear constraints), but nonlinear objectives are a special case where everything needed is saved separately in the NLPEvaluator. |
After #638 expressions will be explicitly tied to models, so closing this as wontfix. The workaround is create multiple models and set the values of the variables as needed to compute the desired derivatives. |
Is there any way to re-use nonlinear expressions between multiple models? As a simple (and kind of silly, included only for concreteness) example, suppose I had something like this problem:
Suppose, for example, that I wanted to optimize each
y_obj
separately given a value ofx
, but still wanted autodiff hessians forobj
. I would want to share the expressiony_obj[i=1:n]
between the models used for optimzing and the model used to get the full Hessian.I don't see how to do it since a variable must be bound to a single model. Is this possible in JuMP? Any recommendations for how to approach this use case?
(The example is deliberately oversimplified -- for a more complicated motivating example, you can consider a variational poisson glmm.)
The text was updated successfully, but these errors were encountered: