Skip to content

Commit

Permalink
add max_obc_shift
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Nov 10, 2023
1 parent 3112064 commit b1223b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 3 additions & 5 deletions src/get_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -903,11 +903,9 @@ function get_irf(𝓂::ℳ;

obc_shock_idx = contains.(string.(𝓂.timings.exo),"ᵒᵇᶜ")

obc_inequalities_idx = findall(x->contains(string(x), "Χᵒᵇᶜ") , 𝓂.var)

periods_per_shock = sum(obc_shock_idx)÷length(obc_inequalities_idx)

num_shocks = length(obc_inequalities_idx)
periods_per_shock = 𝓂.max_obc_shift + 1

num_shocks = sum(obc_shock_idx)÷periods_per_shock

# Find shocks fulfilling constraint
# model = JuMP.Model(MadNLP.Optimizer)
Expand Down
5 changes: 4 additions & 1 deletion src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ macro model(𝓂,ex...)

model_ex = parse_for_loops(ex[end])

model_ex = parse_occasionally_binding_constraints(model_ex)
max_obc_shift = 40

model_ex = parse_occasionally_binding_constraints(model_ex, max_obc_shift = max_obc_shift)

obc_shock_bounds = Tuple{Symbol, Bool, Float64}[]

Expand Down Expand Up @@ -853,6 +855,7 @@ macro model(𝓂,ex...)

Expr[],
$obc_shock_bounds,
$max_obc_shift,
x->x,

solution(
Expand Down
8 changes: 3 additions & 5 deletions src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,9 @@ function plot_irf(𝓂::ℳ;

obc_shock_idx = contains.(string.(𝓂.timings.exo),"ᵒᵇᶜ")

obc_inequalities_idx = findall(x->contains(string(x), "Χᵒᵇᶜ") , 𝓂.var)

periods_per_shock = sum(obc_shock_idx)÷length(obc_inequalities_idx)

num_shocks = length(obc_inequalities_idx)
periods_per_shock = 𝓂.max_obc_shift + 1

num_shocks = sum(obc_shock_idx)÷periods_per_shock

# Find shocks fulfilling constraint
# model = JuMP.Model(MadNLP.Optimizer)
Expand Down
1 change: 1 addition & 0 deletions src/structures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ mutable struct ℳ

obc_violation_equations::Vector{Expr}
obc_shock_bounds::Vector{Tuple{Symbol, Bool, Float64}}
max_obc_shift::Int
obc_violation_function::Function

solution::solution
Expand Down

0 comments on commit b1223b1

Please sign in to comment.