1
1
import Symbolics: ≲ , ~
2
- struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, D, P, C} < :
2
+
3
+ struct AnalysisResults
4
+ objective:: Union{Nothing, AnalysisResult}
5
+ constraints:: Union{Nothing, Vector{AnalysisResult}}
6
+ end
7
+
8
+ struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, D, P, C, M} < :
3
9
SciMLBase. AbstractOptimizationCache
4
10
f:: F
5
11
reinit_cache:: RC
@@ -12,6 +18,8 @@ struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, D, P, C} <:
12
18
data:: D
13
19
progress:: P
14
20
callback:: C
21
+ manifold:: M
22
+ analysis_results:: AnalysisResults
15
23
solver_args:: NamedTuple
16
24
end
17
25
@@ -101,32 +109,44 @@ function OptimizationCache(prob::SciMLBase.OptimizationProblem, opt, data = DEFA
101
109
end
102
110
103
111
if obj_expr != = nothing
104
- try
105
- obj_expr = obj_expr |> Symbolics. unwrap
106
- obj_expr = propagate_curvature (propagate_sign (obj_expr))
107
- @info " Objective Euclidean curvature: $(getcurvature (obj_expr)) "
108
- catch
109
- @info " No euclidean atom available"
112
+ obj_expr = obj_expr |> Symbolics. unwrap
113
+ if manifold === nothing
114
+ obj_res = analyze (obj_expr)
115
+ else
116
+ obj_res = analyze (obj_expr, manifold)
110
117
end
111
118
112
- try
113
- obj_expr = propagate_gcurvature (propagate_sign (obj_expr), manifold)
114
- @info " Objective Geodesic curvature: $(getgcurvature (obj_expr)) "
115
- catch
116
- @info " No geodesic atom available"
119
+ @info " Objective Euclidean curvature: $(obj_res. curvature) "
120
+
121
+ if obj_res. gcurvature != = nothing
122
+ @info " Objective Geodesic curvature: $(obj_res. gcurvature) "
117
123
end
124
+ else
125
+ obj_res = nothing
118
126
end
119
127
120
128
if cons_expr != = nothing
121
129
cons_expr = cons_expr .| > Symbolics. unwrap
122
- cons_expr = propagate_curvature .(propagate_sign .(cons_expr))
123
- @info " Constraints Euclidean curvature: $(getcurvature .(cons_expr)) "
130
+ if manifold === nothing
131
+ cons_res = analyze .(cons_expr)
132
+ else
133
+ cons_res = analyze .(cons_expr, Ref (manifold))
134
+ end
135
+ for i in 1 : num_cons
136
+ @info " Constraints Euclidean curvature: $(cons_res[i]. curvature) "
137
+
138
+ if cons_res[i]. gcurvature != = nothing
139
+ @info " Constraints Geodesic curvature: $(cons_res[i]. gcurvature) "
140
+ end
141
+ end
142
+ else
143
+ cons_res = nothing
124
144
end
125
145
126
146
return OptimizationCache (f, reinit_cache, prob. lb, prob. ub, prob. lcons,
127
147
prob. ucons, prob. sense,
128
- opt, data, progress, callback,
129
- merge ((; maxiters, maxtime, abstol, reltol, manifold ),
148
+ opt, data, progress, callback, manifold, AnalysisResults (obj_res, cons_res),
149
+ merge ((; maxiters, maxtime, abstol, reltol),
130
150
NamedTuple (kwargs)))
131
151
end
132
152
0 commit comments