Skip to content

Commit

Permalink
allow setting initial sup and sub
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanxshi committed Jun 12, 2023
1 parent 69a3810 commit 4b7b561
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/policy/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ function policy(C::Integer; e...)
policy!((cutoffs, policies), (working, converged, done), C; e...)
end

function policy!((cutoffs, policies), (working, converged, done), C::Integer; scdca::Bool, obj, equalise_obj, D_j_obj = D_j(obj), zero_D_j_obj = zero_D_j(equalise_obj, falses(C)), show_time::Bool = false, emptyset = falses(C))
empty!.((working, converged, done))
int = interval(_containers(C), -Inf, Inf)
push!(working, int)
function policy!((cutoffs, policies), (working, converged, done), C::Integer; scdca::Bool, obj, equalise_obj, D_j_obj = D_j(obj), zero_D_j_obj = zero_D_j(equalise_obj, falses(C)), show_time::Bool = false, emptyset = falses(C), restart::Bool = true)
if restart
empty!.((working, converged, done))
int = interval(_containers(C), -Inf, Inf)
push!(working, int)
end

cdcp = (; scdca, obj, D_j_obj, zero_D_j_obj, equalise_obj, emptyset)

Expand Down
10 changes: 6 additions & 4 deletions src/single/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ The solver can optionally take `D_j_obj(j, J)`, a user-supplied marginal value f
See also: [`solve`](@ref), [`policy`](@ref)
"""
function solve!(Vs ; scdca::Bool, obj, D_j_obj = D_j(obj), containers = _containers(Vs))
function solve!(Vs; scdca::Bool, obj, D_j_obj = D_j(obj), containers = _containers(Vs), restart::Bool = true)
sub, sup, aux = Vs
sub = fill!(sub, false)
sup = fill!(sup, true)
aux = fill!(aux, false)
if restart
sub = fill!(sub, false)
sup = fill!(sup, true)
aux = fill!(aux, false)
end

# squeeze
(sub, sup, aux) = converge!((sub, sup, aux); D_j_obj, scdca)
Expand Down

0 comments on commit 4b7b561

Please sign in to comment.