mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 08:18:51 -06:00
ConventionalLMP: turn warnings into errors, remove some inline comments
This commit is contained in:
@@ -64,20 +64,12 @@ function compute_lmp(
|
|||||||
::ConventionalLMP;
|
::ConventionalLMP;
|
||||||
optimizer,
|
optimizer,
|
||||||
)::OrderedDict{Tuple{String,Int},Float64}
|
)::OrderedDict{Tuple{String,Int},Float64}
|
||||||
# Validate model, the UC model must be solved beforehand
|
|
||||||
if !has_values(model)
|
if !has_values(model)
|
||||||
@error "The UC model must be solved before calculating the LMPs."
|
error("The UC model must be solved before calculating the LMPs.")
|
||||||
@error "The LMPs are NOT calculated."
|
|
||||||
return nothing
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prepare the LMP result dictionary
|
|
||||||
lmp = OrderedDict()
|
lmp = OrderedDict()
|
||||||
|
|
||||||
# Calculate LMPs
|
@info "Fixing binary variables and relaxing integrality..."
|
||||||
# Fix all binary variables to their optimal values and relax integrality
|
|
||||||
@info "Calculating LMPs..."
|
|
||||||
@info "Fixing all binary variables to their optimal values and relax integrality."
|
|
||||||
vals = Dict(v => value(v) for v in all_variables(model))
|
vals = Dict(v => value(v) for v in all_variables(model))
|
||||||
for v in all_variables(model)
|
for v in all_variables(model)
|
||||||
if is_binary(v)
|
if is_binary(v)
|
||||||
@@ -85,21 +77,16 @@ function compute_lmp(
|
|||||||
fix(v, vals[v])
|
fix(v, vals[v])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# fix!(model, model[:solution])
|
|
||||||
relax_integrality(model)
|
relax_integrality(model)
|
||||||
set_optimizer(model, optimizer)
|
set_optimizer(model, optimizer)
|
||||||
|
|
||||||
# Solve the LP
|
|
||||||
@info "Solving the LP..."
|
@info "Solving the LP..."
|
||||||
JuMP.optimize!(model)
|
JuMP.optimize!(model)
|
||||||
|
|
||||||
# Obtain dual values (LMPs) and store into the LMP dictionary
|
|
||||||
@info "Getting dual values (LMPs)..."
|
@info "Getting dual values (LMPs)..."
|
||||||
for (key, val) in model[:eq_net_injection]
|
for (key, val) in model[:eq_net_injection]
|
||||||
lmp[key] = dual(val)
|
lmp[key] = dual(val)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the LMP dictionary
|
|
||||||
@info "Calculation completed."
|
|
||||||
return lmp
|
return lmp
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user