Hello,
I want to optimize a function f(x,k_n) with x optimization variable and k(n) parameter. We iterate N times over k_n. The way that works is for each k(n) to use adigatorGenFiles4Ipopt and feed the output functions to ipopt. However, this requires to recalculate N times the gradient, jacobian, etc. I would like to know whether it is possible to generate upfront the gradient(x,k0), jacobian(x,k0), etc, and then for each iteration define funcs.gradient=funcs.gradient(x,k_n), etc, and feed funcs to ipopt. So far I get the following error message: "Struct contents reference from a non-struct array object." Hope this is clear and would be glad to get some help.
Best,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In general, adigator generated files are only valid for fixed dimensional inputs, with fixed reference/assignment input indices. If k_n is an integer which changes the dimension of the problem or is used as a reference/assignment index, then I don't know that adigator can create a file valid for any k_n. If it is just an auxiliary consant (for instance, a cost function multiplier), then it can be declared as an adigatorAuxInput and everything should work for all values of k_n, but that doesn't sound like the case.
Another thing to look into is the vectorized mode, assuming your problem is changing dimensions. In order to use this, however, generally requires you to ask adigator to differentiate a vectorized portion of the problem and write a wrapper derivative routine which takes those derivatives and completes the chain rule.
Matt W.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I want to optimize a function f(x,k_n) with x optimization variable and k(n) parameter. We iterate N times over k_n. The way that works is for each k(n) to use adigatorGenFiles4Ipopt and feed the output functions to ipopt. However, this requires to recalculate N times the gradient, jacobian, etc. I would like to know whether it is possible to generate upfront the gradient(x,k0), jacobian(x,k0), etc, and then for each iteration define funcs.gradient=funcs.gradient(x,k_n), etc, and feed funcs to ipopt. So far I get the following error message: "Struct contents reference from a non-struct array object." Hope this is clear and would be glad to get some help.
Best,
Hi Dorian,
In general, adigator generated files are only valid for fixed dimensional inputs, with fixed reference/assignment input indices. If k_n is an integer which changes the dimension of the problem or is used as a reference/assignment index, then I don't know that adigator can create a file valid for any k_n. If it is just an auxiliary consant (for instance, a cost function multiplier), then it can be declared as an adigatorAuxInput and everything should work for all values of k_n, but that doesn't sound like the case.
Another thing to look into is the vectorized mode, assuming your problem is changing dimensions. In order to use this, however, generally requires you to ask adigator to differentiate a vectorized portion of the problem and write a wrapper derivative routine which takes those derivatives and completes the chain rule.
Matt W.