mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 08:18:51 -06:00
Rename fix!(instance) to repair!
This commit is contained in:
@@ -4,10 +4,12 @@
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Sub-hourly unit commitment
|
- Sub-hourly unit commitment
|
||||||
|
- Added function `UnitCommitment.write(filename, solution)` to simplify saving the solution to a file
|
||||||
|
- Added mathematical formulation to the documentation
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Renamed "Time (h)" parameter to "Time horizon (h)"
|
- Renamed "Time (h)" parameter to "Time horizon (h)"
|
||||||
- `UnitCommitment.build_model` now returns a plain JuMP model. The
|
- The function `UnitCommitment.build_model` now returns a plain JuMP model. The
|
||||||
struct `UnitCommitmentModel` has been completely removed. Accessing model elements can now be accomplished as follows:
|
struct `UnitCommitmentModel` has been completely removed. Accessing model elements can now be accomplished as follows:
|
||||||
- `model.vars.x[idx]` becomes `model[:x][idx]`
|
- `model.vars.x[idx]` becomes `model[:x][idx]`
|
||||||
- `model.eqs.y[idx]` becomes `model[:eq_y][idx]`
|
- `model.eqs.y[idx]` becomes `model[:eq_y][idx]`
|
||||||
@@ -15,7 +17,8 @@
|
|||||||
- `model.obj` becomes `model[:obj]`
|
- `model.obj` becomes `model[:obj]`
|
||||||
- `model.isf` becomes `model[:isf]`
|
- `model.isf` becomes `model[:isf]`
|
||||||
- `model.lodf` becomes `model[:lodf]`
|
- `model.lodf` becomes `model[:lodf]`
|
||||||
- Function `UnitCommitment.get_solution` has been renamed to `UnitCommitment.solution`
|
- The function `UnitCommitment.get_solution` has been renamed to `UnitCommitment.solution`
|
||||||
|
- The function `UnitCommitment.fix!(instance)`, which attempts to repair an invalid instance, has been renamed to `UnitCommitment.repair!(instance)`
|
||||||
|
|
||||||
## [0.1.1] - 2020-11-16
|
## [0.1.1] - 2020-11-16
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ function read(file::IO)::UnitCommitmentInstance
|
|||||||
return from_json(JSON.parse(file, dicttype=()->DefaultOrderedDict(nothing)))
|
return from_json(JSON.parse(file, dicttype=()->DefaultOrderedDict(nothing)))
|
||||||
end
|
end
|
||||||
|
|
||||||
function from_json(json; fix=true)
|
function from_json(json; repair=true)
|
||||||
units = Unit[]
|
units = Unit[]
|
||||||
buses = Bus[]
|
buses = Bus[]
|
||||||
contingencies = Contingency[]
|
contingencies = Contingency[]
|
||||||
@@ -313,8 +313,8 @@ function from_json(json; fix=true)
|
|||||||
reserves,
|
reserves,
|
||||||
contingencies,
|
contingencies,
|
||||||
loads)
|
loads)
|
||||||
if fix
|
if repair
|
||||||
UnitCommitment.fix!(instance)
|
UnitCommitment.repair!(instance)
|
||||||
end
|
end
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Printf
|
|||||||
bin(x) = [xi > 0.5 for xi in x]
|
bin(x) = [xi > 0.5 for xi in x]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
fix!(instance)
|
repair!(instance)
|
||||||
|
|
||||||
Verifies that the given unit commitment instance is valid and automatically fixes
|
Verifies that the given unit commitment instance is valid and automatically fixes
|
||||||
some validation errors if possible, issuing a warning for each error found.
|
some validation errors if possible, issuing a warning for each error found.
|
||||||
@@ -15,7 +15,7 @@ If a validation error cannot be automatically fixed, issues an exception.
|
|||||||
|
|
||||||
Returns the number of validation errors found.
|
Returns the number of validation errors found.
|
||||||
"""
|
"""
|
||||||
function fix!(instance::UnitCommitmentInstance)::Int
|
function repair!(instance::UnitCommitmentInstance)::Int
|
||||||
n_errors = 0
|
n_errors = 0
|
||||||
|
|
||||||
for g in instance.units
|
for g in instance.units
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ parse_case14() = JSON.parse(GZip.gzopen("../instances/test/case14.json.gz"),
|
|||||||
dicttype=()->DefaultOrderedDict(nothing))
|
dicttype=()->DefaultOrderedDict(nothing))
|
||||||
|
|
||||||
@testset "Validation" begin
|
@testset "Validation" begin
|
||||||
@testset "fix!" begin
|
@testset "repair!" begin
|
||||||
|
|
||||||
@testset "Cost curve should be convex" begin
|
@testset "Cost curve should be convex" begin
|
||||||
json = parse_case14()
|
json = parse_case14()
|
||||||
json["Generators"]["g1"]["Production cost curve (MW)"] = [100, 150, 200]
|
json["Generators"]["g1"]["Production cost curve (MW)"] = [100, 150, 200]
|
||||||
json["Generators"]["g1"]["Production cost curve (\$)"] = [10, 25, 30]
|
json["Generators"]["g1"]["Production cost curve (\$)"] = [10, 25, 30]
|
||||||
instance = UnitCommitment.from_json(json, fix=false)
|
instance = UnitCommitment.from_json(json, repair=false)
|
||||||
@test UnitCommitment.fix!(instance) == 4
|
@test UnitCommitment.repair!(instance) == 4
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Startup limit must be greater than Pmin" begin
|
@testset "Startup limit must be greater than Pmin" begin
|
||||||
@@ -23,16 +23,16 @@ parse_case14() = JSON.parse(GZip.gzopen("../instances/test/case14.json.gz"),
|
|||||||
json["Generators"]["g1"]["Production cost curve (MW)"] = [100, 150]
|
json["Generators"]["g1"]["Production cost curve (MW)"] = [100, 150]
|
||||||
json["Generators"]["g1"]["Production cost curve (\$)"] = [100, 150]
|
json["Generators"]["g1"]["Production cost curve (\$)"] = [100, 150]
|
||||||
json["Generators"]["g1"]["Startup limit (MW)"] = 80
|
json["Generators"]["g1"]["Startup limit (MW)"] = 80
|
||||||
instance = UnitCommitment.from_json(json, fix=false)
|
instance = UnitCommitment.from_json(json, repair=false)
|
||||||
@test UnitCommitment.fix!(instance) == 1
|
@test UnitCommitment.repair!(instance) == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Startup costs and delays must be increasing" begin
|
@testset "Startup costs and delays must be increasing" begin
|
||||||
json = parse_case14()
|
json = parse_case14()
|
||||||
json["Generators"]["g1"]["Startup costs (\$)"] = [300, 200, 100]
|
json["Generators"]["g1"]["Startup costs (\$)"] = [300, 200, 100]
|
||||||
json["Generators"]["g1"]["Startup delays (h)"] = [8, 4, 2]
|
json["Generators"]["g1"]["Startup delays (h)"] = [8, 4, 2]
|
||||||
instance = UnitCommitment.from_json(json, fix=false)
|
instance = UnitCommitment.from_json(json, repair=false)
|
||||||
@test UnitCommitment.fix!(instance) == 4
|
@test UnitCommitment.repair!(instance) == 4
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user