mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-06 07:48:50 -06:00
Small fixes
This commit is contained in:
@@ -9,6 +9,7 @@ function build_model(
|
|||||||
graphs::Vector{Graph},
|
graphs::Vector{Graph},
|
||||||
probs::Vector{Float64};
|
probs::Vector{Float64};
|
||||||
optimizer,
|
optimizer,
|
||||||
|
method=:ef,
|
||||||
)
|
)
|
||||||
T = instance.time
|
T = instance.time
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ function build_model(
|
|||||||
upper_bound = psn[n].location.disposal_limit[psn[n].product][t],
|
upper_bound = psn[n].location.disposal_limit[psn[n].product][t],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Var: collection_dispose/
|
# Var: collection_dispose
|
||||||
@recourse(
|
@recourse(
|
||||||
model,
|
model,
|
||||||
collection_dispose[n in 1:CSN, t in 1:T],
|
collection_dispose[n in 1:CSN, t in 1:T],
|
||||||
@@ -290,7 +291,7 @@ function build_model(
|
|||||||
sum(
|
sum(
|
||||||
collection_dispose[n, t]
|
collection_dispose[n, t]
|
||||||
for n in 1:CSN
|
for n in 1:CSN
|
||||||
if csn[n].product == prod
|
if csn[n].product.name == prod.name
|
||||||
) <= prod.disposal_limit[t]
|
) <= prod.disposal_limit[t]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@@ -302,7 +303,16 @@ function build_model(
|
|||||||
for i in 1:length(graphs)
|
for i in 1:length(graphs)
|
||||||
]
|
]
|
||||||
|
|
||||||
sp = instantiate(model, ξ; optimizer)
|
if method == :ef
|
||||||
|
sp = instantiate(model, ξ; optimizer=optimizer)
|
||||||
|
elseif method == :lshaped
|
||||||
|
sp = instantiate(model, ξ; optimizer=LShaped.Optimizer)
|
||||||
|
set_optimizer_attribute(sp, MasterOptimizer(), optimizer)
|
||||||
|
set_optimizer_attribute(sp, SubProblemOptimizer(), optimizer)
|
||||||
|
set_optimizer_attribute(sp, FeasibilityStrategy(), FeasibilityCuts())
|
||||||
|
else
|
||||||
|
error("unknown method: $method")
|
||||||
|
end
|
||||||
|
|
||||||
return sp
|
return sp
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ function get_solution(
|
|||||||
marginal_costs=false,
|
marginal_costs=false,
|
||||||
)
|
)
|
||||||
value(x) = StochasticPrograms.value(x, scenario_index)
|
value(x) = StochasticPrograms.value(x, scenario_index)
|
||||||
|
ivalue(x) = StochasticPrograms.value(x)
|
||||||
shadow_price(x) = StochasticPrograms.shadow_price(x, scenario_index)
|
shadow_price(x) = StochasticPrograms.shadow_price(x, scenario_index)
|
||||||
|
|
||||||
T = instance.time
|
T = instance.time
|
||||||
@@ -26,6 +27,7 @@ function get_solution(
|
|||||||
CSN = length(csn)
|
CSN = length(csn)
|
||||||
PSN = length(psn)
|
PSN = length(psn)
|
||||||
|
|
||||||
|
flow = model[2, :flow]
|
||||||
|
|
||||||
output = OrderedDict(
|
output = OrderedDict(
|
||||||
"Plants" => OrderedDict(),
|
"Plants" => OrderedDict(),
|
||||||
@@ -106,11 +108,11 @@ function get_solution(
|
|||||||
"Capacity (tonne)" =>
|
"Capacity (tonne)" =>
|
||||||
[value(model[2, :capacity][n, t]) for t = 1:T],
|
[value(model[2, :capacity][n, t]) for t = 1:T],
|
||||||
"Opening cost (\$)" => [
|
"Opening cost (\$)" => [
|
||||||
value(model[2, :open_plant][n, t]) *
|
ivalue(model[1, :open_plant][n, t]) *
|
||||||
plant.sizes[1].opening_cost[t] for t = 1:T
|
plant.sizes[1].opening_cost[t] for t = 1:T
|
||||||
],
|
],
|
||||||
"Fixed operating cost (\$)" => [
|
"Fixed operating cost (\$)" => [
|
||||||
value(model[2, :is_open][n, t]) *
|
ivalue(model[1, :is_open][n, t]) *
|
||||||
plant.sizes[1].fixed_operating_cost[t] +
|
plant.sizes[1].fixed_operating_cost[t] +
|
||||||
value(model[2, :expansion][n, t]) *
|
value(model[2, :expansion][n, t]) *
|
||||||
slope_fix_oper_cost(plant, t) for t = 1:T
|
slope_fix_oper_cost(plant, t) for t = 1:T
|
||||||
@@ -149,7 +151,7 @@ function get_solution(
|
|||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
for a in process_node.incoming_arcs
|
for a in process_node.incoming_arcs
|
||||||
vals = [value(model[2, :flow][a.index, t]) for t = 1:T]
|
vals = [value(flow[a.index, t]) for t = 1:T]
|
||||||
if sum(vals) <= 1e-3
|
if sum(vals) <= 1e-3
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
@@ -230,7 +232,7 @@ function get_solution(
|
|||||||
end
|
end
|
||||||
|
|
||||||
for a in shipping_node.outgoing_arcs
|
for a in shipping_node.outgoing_arcs
|
||||||
vals = [value(model[2, :flow][a.index, t]) for t = 1:T]
|
vals = [value(flow[a.index, t]) for t = 1:T]
|
||||||
if sum(vals) <= 1e-3
|
if sum(vals) <= 1e-3
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user