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
|
||||
- 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
|
||||
- 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:
|
||||
- `model.vars.x[idx]` becomes `model[:x][idx]`
|
||||
- `model.eqs.y[idx]` becomes `model[:eq_y][idx]`
|
||||
@@ -15,7 +17,8 @@
|
||||
- `model.obj` becomes `model[:obj]`
|
||||
- `model.isf` becomes `model[:isf]`
|
||||
- `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
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ function read(file::IO)::UnitCommitmentInstance
|
||||
return from_json(JSON.parse(file, dicttype=()->DefaultOrderedDict(nothing)))
|
||||
end
|
||||
|
||||
function from_json(json; fix=true)
|
||||
function from_json(json; repair=true)
|
||||
units = Unit[]
|
||||
buses = Bus[]
|
||||
contingencies = Contingency[]
|
||||
@@ -313,8 +313,8 @@ function from_json(json; fix=true)
|
||||
reserves,
|
||||
contingencies,
|
||||
loads)
|
||||
if fix
|
||||
UnitCommitment.fix!(instance)
|
||||
if repair
|
||||
UnitCommitment.repair!(instance)
|
||||
end
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ using Printf
|
||||
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
|
||||
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.
|
||||
"""
|
||||
function fix!(instance::UnitCommitmentInstance)::Int
|
||||
function repair!(instance::UnitCommitmentInstance)::Int
|
||||
n_errors = 0
|
||||
|
||||
for g in instance.units
|
||||
|
||||
@@ -8,14 +8,14 @@ parse_case14() = JSON.parse(GZip.gzopen("../instances/test/case14.json.gz"),
|
||||
dicttype=()->DefaultOrderedDict(nothing))
|
||||
|
||||
@testset "Validation" begin
|
||||
@testset "fix!" begin
|
||||
@testset "repair!" begin
|
||||
|
||||
@testset "Cost curve should be convex" begin
|
||||
json = parse_case14()
|
||||
json["Generators"]["g1"]["Production cost curve (MW)"] = [100, 150, 200]
|
||||
json["Generators"]["g1"]["Production cost curve (\$)"] = [10, 25, 30]
|
||||
instance = UnitCommitment.from_json(json, fix=false)
|
||||
@test UnitCommitment.fix!(instance) == 4
|
||||
instance = UnitCommitment.from_json(json, repair=false)
|
||||
@test UnitCommitment.repair!(instance) == 4
|
||||
end
|
||||
|
||||
@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 (\$)"] = [100, 150]
|
||||
json["Generators"]["g1"]["Startup limit (MW)"] = 80
|
||||
instance = UnitCommitment.from_json(json, fix=false)
|
||||
@test UnitCommitment.fix!(instance) == 1
|
||||
instance = UnitCommitment.from_json(json, repair=false)
|
||||
@test UnitCommitment.repair!(instance) == 1
|
||||
end
|
||||
|
||||
@testset "Startup costs and delays must be increasing" begin
|
||||
json = parse_case14()
|
||||
json["Generators"]["g1"]["Startup costs (\$)"] = [300, 200, 100]
|
||||
json["Generators"]["g1"]["Startup delays (h)"] = [8, 4, 2]
|
||||
instance = UnitCommitment.from_json(json, fix=false)
|
||||
@test UnitCommitment.fix!(instance) == 4
|
||||
instance = UnitCommitment.from_json(json, repair=false)
|
||||
@test UnitCommitment.repair!(instance) == 4
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user