-
Notifications
You must be signed in to change notification settings - Fork 20
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
Support variable time with create_objective_function()
#190
Comments
Would it make sense to give an example how for form the obj_grad function for the cases
|
I think the examples are more like |
The simplest would be to use something like the following: def lambdify_function(expr, multiplication_array, take_sum):
if take_sum:
def integration_function(x):
return np.sum(x * multiplication_array)
else:
def integration_function(x):
return x * multiplication_array
return sm.lambdify(
(states, inputs, params), expr,
modules=[{int_placeholder.name: integration_function}, "numpy"],
cse=True)
...
def multiply_integrals(expr, value):
if not expr.args:
return expr
if isinstance(expr, sm.Integral):
return value * expr
return expr.func(*(multiply_integrals(arg, value) for arg in expr.args))
objective = multiply_integrals(objective, node_time_interval) |
Of course STUPID of my part to put h in the integral! |
We now have variable time step support but it will not work with the current
create_objective_function()
.The text was updated successfully, but these errors were encountered: