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},
|
||||
probs::Vector{Float64};
|
||||
optimizer,
|
||||
method=:ef,
|
||||
)
|
||||
T = instance.time
|
||||
|
||||
@@ -95,7 +96,7 @@ function build_model(
|
||||
upper_bound = psn[n].location.disposal_limit[psn[n].product][t],
|
||||
)
|
||||
|
||||
# Var: collection_dispose/
|
||||
# Var: collection_dispose
|
||||
@recourse(
|
||||
model,
|
||||
collection_dispose[n in 1:CSN, t in 1:T],
|
||||
@@ -290,7 +291,7 @@ function build_model(
|
||||
sum(
|
||||
collection_dispose[n, t]
|
||||
for n in 1:CSN
|
||||
if csn[n].product == prod
|
||||
if csn[n].product.name == prod.name
|
||||
) <= prod.disposal_limit[t]
|
||||
)
|
||||
end
|
||||
@@ -302,7 +303,16 @@ function build_model(
|
||||
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
|
||||
end
|
||||
|
||||
@@ -12,6 +12,7 @@ function get_solution(
|
||||
marginal_costs=false,
|
||||
)
|
||||
value(x) = StochasticPrograms.value(x, scenario_index)
|
||||
ivalue(x) = StochasticPrograms.value(x)
|
||||
shadow_price(x) = StochasticPrograms.shadow_price(x, scenario_index)
|
||||
|
||||
T = instance.time
|
||||
@@ -26,6 +27,7 @@ function get_solution(
|
||||
CSN = length(csn)
|
||||
PSN = length(psn)
|
||||
|
||||
flow = model[2, :flow]
|
||||
|
||||
output = OrderedDict(
|
||||
"Plants" => OrderedDict(),
|
||||
@@ -106,11 +108,11 @@ function get_solution(
|
||||
"Capacity (tonne)" =>
|
||||
[value(model[2, :capacity][n, t]) for t = 1:T],
|
||||
"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
|
||||
],
|
||||
"Fixed operating cost (\$)" => [
|
||||
value(model[2, :is_open][n, t]) *
|
||||
ivalue(model[1, :is_open][n, t]) *
|
||||
plant.sizes[1].fixed_operating_cost[t] +
|
||||
value(model[2, :expansion][n, t]) *
|
||||
slope_fix_oper_cost(plant, t) for t = 1:T
|
||||
@@ -149,7 +151,7 @@ function get_solution(
|
||||
|
||||
# Inputs
|
||||
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
|
||||
continue
|
||||
end
|
||||
@@ -230,7 +232,7 @@ function get_solution(
|
||||
end
|
||||
|
||||
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
|
||||
continue
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user