Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Classify the change according to the following categories:
### Deprecated
### Removed

## dict-type
### Fixed
- Added dicttype arg to _JSON.parsefile_ (solves _MethodError_ when the parsed JSON file is passed to the next function (e.g. `Scenario`) as a _JSON.Object_ but expecting _Dict_)
Comment thread
hdunham marked this conversation as resolved.

## v0.59.2
### Fixed
- Restrictive validation to let CHP heuristic sizing parameters (avg heating and cooling values) be zero
Expand Down
2 changes: 1 addition & 1 deletion src/core/pv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ function get_pv_defaults_size_class()
throw(ErrorException("pv_defaults.json not found at path: $pv_defaults_path"))
end

pv_defaults_all = JSON.parsefile(pv_defaults_path)
pv_defaults_all = JSON.parsefile(pv_defaults_path, dicttype = Dict{String, Any})
return pv_defaults_all["size_classes"]
end

Expand Down
6 changes: 3 additions & 3 deletions src/core/reopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Solve the model using the `Scenario` defined in JSON file stored at the file pat
function run_reopt(m::JuMP.AbstractModel, fp::String)

try
s = Scenario(JSON.parsefile(fp))
s = Scenario(JSON.parsefile(fp, dicttype = Dict{String, Any}))
run_reopt(m, REoptInputs(s))
Comment thread
hdunham marked this conversation as resolved.
catch e
if isnothing(e) # Error thrown by REopt
Expand Down Expand Up @@ -99,7 +99,7 @@ Solve the `Scenario` and `BAUScenario` in parallel using the first two (empty) m
JSON file at the filepath `fp`.
"""
function run_reopt(ms::AbstractArray{T, 1}, fp::String) where T <: JuMP.AbstractModel
d = JSON.parsefile(fp)
d = JSON.parsefile(fp, dicttype = Dict{String, Any})
run_reopt(ms, d)
end

Expand Down Expand Up @@ -172,7 +172,7 @@ Add variables and constraints for REopt model.
`fp` is used to load in JSON file to construct REoptInputs.
"""
function build_reopt!(m::JuMP.AbstractModel, fp::String)
s = Scenario(JSON.parsefile(fp))
s = Scenario(JSON.parsefile(fp, dicttype = Dict{String, Any}))
build_reopt!(m, REoptInputs(s))
nothing
end
Expand Down
4 changes: 2 additions & 2 deletions src/core/reopt_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ end
Use `fp` to load in JSON scenario:
```
function REoptInputs(fp::String)
s = Scenario(JSON.parsefile(fp))
s = Scenario(JSON.parsefile(fp, dicttype = Dict{String, Any}))
REoptInputs(s)
end
```
Useful if you want to manually modify REoptInputs before solving the model.
"""
function REoptInputs(fp::String)
s = Scenario(JSON.parsefile(fp))
s = Scenario(JSON.parsefile(fp, dicttype = Dict{String, Any}))
REoptInputs(s)
end

Expand Down
3 changes: 1 addition & 2 deletions src/core/scenario.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ function Scenario(d::Dict; flex_hvac_from_json=false)
else
settings = Settings()
end

site = Site(;dictkeys_tosymbols(d["Site"])...)

# Check that only PV, electric storage, and generator are modeled for off-grid
Expand Down Expand Up @@ -1077,7 +1076,7 @@ end
Consruct Scenario from filepath `fp` to JSON with keys aligned with the `Scenario(d::Dict)` method.
"""
function Scenario(fp::String)
Scenario(JSON.parsefile(fp); flex_hvac_from_json=true)
Scenario(JSON.parsefile(fp, dicttype = Dict{String, Any}); flex_hvac_from_json=true)
end


Expand Down
2 changes: 1 addition & 1 deletion src/mpc/inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end


function MPCInputs(fp::String)
s = MPCScenario(JSON.parsefile(fp))
s = MPCScenario(JSON.parsefile(fp, dicttype = Dict{String, Any}))
MPCInputs(s)
end

Expand Down
2 changes: 1 addition & 1 deletion src/mpc/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Solve the model predictive control problem using the `MPCScenario` defined in th
Returns a Dict of results with keys matching those in the `MPCScenario`.
"""
function run_mpc(m::JuMP.AbstractModel, fp::String)
s = MPCScenario(JSON.parsefile(fp))
s = MPCScenario(JSON.parsefile(fp, dicttype = Dict{String, Any}))
run_mpc(m, MPCInputs(s))
end

Expand Down
Loading