File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,38 @@ function compute_single_step_cost(
3
3
y:: Vector{<:Real} ,
4
4
yhat:: Vector{<:Real} ,
5
5
)
6
+ # set forecast params as prediction output
6
7
MOI. set .(model. plan, POI. ParameterValue (), model. plan_forecast_params, yhat)
8
+ # optimize plan model
7
9
optimize! (model. plan)
8
- @assert termination_status (model. plan) == MOI. OPTIMAL " Optimization failed for PLAN model"
10
+ # check for solution and fix assess policy vars
11
+ try
12
+ set_normalized_rhs .(
13
+ model. assess[:assess_policy_fix ],
14
+ value .(plan_policy_vars (model)),
15
+ )
16
+ catch e
17
+ println (" Optimization failed for PLAN model." )
18
+ throw (e)
19
+ end
20
+ # fix assess forecast vars on observer values
9
21
fix .(assess_forecast_vars (model), y; force = true )
22
+ # fix assess policy vars on plan solution
10
23
set_normalized_rhs .(
11
24
model. assess[:assess_policy_fix ],
12
25
value .(plan_policy_vars (model)),
13
26
)
27
+ # optimize assess model
14
28
optimize! (model. assess)
15
- @assert termination_status (model. assess) == MOI. OPTIMAL " Optimization failed for ASSESS model"
16
- return objective_value (model. assess)
29
+ # check for optimization
30
+ try
31
+ return objective_value (model. assess)
32
+ catch e
33
+ println (" Optimization failed for ASSESS model" )
34
+ throw (e)
35
+ end
36
+ # should never get here
37
+ return 0
17
38
end
18
39
19
40
"""
You can’t perform that action at this time.
0 commit comments