Skip to content

Commit

Permalink
add cut refs vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Rosemberg committed Nov 30, 2019
1 parent 6971243 commit 895a5b9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/plugins/bellman_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ function transfer_cuts(model::PolicyGraph{T},oldmodel::PolicyGraph{T}) where {T}
node_name_parser = _node_name_parser
cuts = Dict{String, Any}[]
for (node_name, node) in oldmodel.nodes
if !haskey(model[node_name].ext, :cut_refs)
model[node_name].ext[:cut_refs] = []
end
if node.objective_state !== nothing
error("Unable to write cuts to file because model contains " *
"objective states.")
Expand All @@ -530,8 +533,12 @@ function transfer_cuts(model::PolicyGraph{T},oldmodel::PolicyGraph{T}) where {T}
"risk_set_cuts" => Vector{Float64}[]
)
nscuts = size(node.bellman_function.global_theta.cut_oracle.cuts,1)
for i = model.ext[:naddcuts]+1:nscuts
for i = 1:nscuts
cut = node.bellman_function.global_theta.cut_oracle.cuts[i]
if cut.constraint_ref in model[node_name].ext[:cut_refs]
continue;
end
push!(model[node_name].ext[:cut_refs], cut.constraint_ref)
cut_coef_aux = copy(cut.coefficients)
for (ky,val) in cut_coef_aux
cut_coef_aux[ky] = val
Expand All @@ -541,7 +548,8 @@ function transfer_cuts(model::PolicyGraph{T},oldmodel::PolicyGraph{T}) where {T}
"coefficients" => cut_coef_aux
))
end
model.ext[:naddcuts] = nscuts
#model.ext[:naddcuts] = nscuts
model.ext[:naddcuts] = model.ext[:naddcuts]+1
for (i, theta) in enumerate(node.bellman_function.local_thetas)
for cut in theta.cut_oracle.cuts
cut_coef_aux = copy(cut.coefficients)
Expand Down

0 comments on commit 895a5b9

Please sign in to comment.