Skip to content

Commit 240ff5d

Browse files
SGeeversAtVortechjackvreeken
authored andcommitted
optimization: fix expansion of residual functions
Skip expansion of residual functions if this is not possible. This might be the case when users add custom functions that cannot be expanded.
1 parent 432637f commit 240ff5d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/rtctools/optimization/collocated_integrated_optimization_problem.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,11 +898,11 @@ def _interpolate_constant_inputs(variables, raw_constant_inputs):
898898
function_options,
899899
)
900900

901+
# Expand the residual function if possible.
901902
try:
902903
dae_residual_function_integrated = dae_residual_function_integrated.expand()
903904
except RuntimeError as e:
904-
# We only expect to fail if the DAE was an external function
905-
if "'eval_sx' not defined for External" in str(e):
905+
if "'eval_sx' not defined for" in str(e):
906906
pass
907907
else:
908908
raise
@@ -933,13 +933,13 @@ def _interpolate_constant_inputs(variables, raw_constant_inputs):
933933
[dae_residual_collocated],
934934
function_options,
935935
)
936+
# Expand the residual function if possible.
936937
try:
937938
self.__dae_residual_function_collocated = (
938939
self.__dae_residual_function_collocated.expand()
939940
)
940941
except RuntimeError as e:
941-
# We only expect to fail if the DAE was an external function
942-
if "'eval_sx' not defined for External" in str(e):
942+
if "'eval_sx' not defined for" in str(e):
943943
pass
944944
else:
945945
raise

0 commit comments

Comments
 (0)