Skip to content

Commit

Permalink
Corrected calibrate to work with solve_model!
Browse files Browse the repository at this point in the history
  • Loading branch information
mivanicERS committed Jan 29, 2025
1 parent 6d4b196 commit f0a084a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/GlobalTradeAnalysisProjectModelV7.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
module GlobalTradeAnalysisProjectModelV7

export generate_starting_values, get_sample_data, solve_model!, calculate_ev, calibrate, calculate_gdp, aggregate_data, aggregate_data_legacy
export generate_starting_values, get_sample_data, solve_model!, calculate_ev, calibrate, calculate_gdp, aggregate_data, aggregate_data_legacy, model_struct

using NamedArrays, Ipopt, JuMP, JLD2
import ComputableGeneralEquilibriumHelpers: cde, ces


mutable struct model_struct
data
sets
parameters
fixed
model
end

include("./helpers/aggComb.jl")
include("./helpers/agg.jl")

Expand Down
5 changes: 3 additions & 2 deletions src/calibrate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ function calibrate(; start_data, data, sets=sets, parameters, fixed, max_iter=10
fixed["vdpp"] = NamedArray(falses(size(data["vdpp"])), names(data["vdpp"]))
fixed["vdpp"][1, 1] = true

mod = model_struc(calibrate_start, sets, parameters, fixed, nothing)
@time begin
(; data) = solve_model(sets=sets, data=calibrate_start, parameters=parameters, fixed=fixed, max_iter=max_iter, constr_viol_tol=constr_viol_tol)
solve_model!(mod; max_iter=max_iter, constr_viol_tol=constr_viol_tol)
end

calibrated_data = deepcopy(data)
calibrated_data = deepcopy(mod.data)
return calibrated_data
end

0 comments on commit f0a084a

Please sign in to comment.