diff --git a/src/generic_io.jl b/src/generic_io.jl index 6a4adad..560767f 100644 --- a/src/generic_io.jl +++ b/src/generic_io.jl @@ -189,7 +189,7 @@ function _get_core_load!(input::AbstractJulESInput, subsystems::Vector{Tuple{Sub core_loads[core] += num_elements else - println("Warning: Core $core not found in core_loads dictionary. Skipping...") + @warn("Warning: Core $core not found in core_loads dictionary. Skipping...") end end return core_loads diff --git a/src/io.jl b/src/io.jl index 77409bb..dc2100a 100644 --- a/src/io.jl +++ b/src/io.jl @@ -403,6 +403,7 @@ get_result_prices_ppp(settings::Dict)::Int = get(settings["results"], "prices_pp has_statedependentprod(settings::Dict)::Bool = get(settings, "statedependentprod", false) has_statedependentpump(settings::Dict)::Bool = get(settings, "statedependentpump", false) +has_statedependentleveling(settings::Dict)::Bool = get(settings, "statedependentleveling", false) has_headlosscost(settings::Dict)::Bool = get(settings, "headlosscost", false) has_onlyagghydro(settings::Dict)::Bool = get(settings["problems"], "onlyagghydro", false) has_keephydroramping_evp(settings::Dict)::Bool = get(settings["problems"]["endvalue"], "keep_hydroramping", false) diff --git a/src/prob_cp.jl b/src/prob_cp.jl index be3a6fe..94ee185 100644 --- a/src/prob_cp.jl +++ b/src/prob_cp.jl @@ -118,6 +118,7 @@ function update_statedependent_cp(stepnr, t) has_statedependentprod(settings["problems"]["clearing"]) && TuLiPa.statedependentprod!(db.cp.prob, db.startstates, init=init) has_statedependentpump(settings["problems"]["clearing"]) && TuLiPa.statedependentpump!(db.cp.prob, db.startstates) + has_statedependentleveling(settings["problems"]["clearing"]) && TuLiPa.statedependentleveling!(db.cp.prob, db.startstates) # Headlosscosts if has_headlosscost(settings["problems"]["clearing"]) diff --git a/src/prob_stoch.jl b/src/prob_stoch.jl index 6c65a40..8c02e2d 100644 --- a/src/prob_stoch.jl +++ b/src/prob_stoch.jl @@ -209,9 +209,9 @@ function solve_benders(stepnr::Int, subix::SubsystemIx) count == 0 && TuLiPa.clearcuts!(mp.cuts) count += 1 catch e - showerror(stdout, e, catch_backtrace()) - count == 0 && println("Retrying first iteration without cuts from last time step") - count > 0 && println("Restarting iterations without cuts from last time step") + errtxt = sprint(showerror, e, catch_backtrace()) + count == 0 && @warn("Retrying first iteration without cuts from last time step: $errtxt") + count > 0 && @warn("Restarting iterations without cuts from last time step: $errtxt") TuLiPa.clearcuts!(mp.prob, mp.cuts) cutreuse = false count = 0 @@ -221,9 +221,11 @@ function solve_benders(stepnr::Int, subix::SubsystemIx) count += 1 end count == 0 && TuLiPa.setwarmstart!(mp.prob, true) - prev_lb = lb - lb = TuLiPa.getvarvalue(mp.prob, TuLiPa.getfuturecostvarid(mp.cuts), 1) - TuLiPa.getoutgoingstates!(mp.prob, mp.states) + if count != 0 + prev_lb = lb + lb = TuLiPa.getvarvalue(mp.prob, TuLiPa.getfuturecostvarid(mp.cuts), 1) + TuLiPa.getoutgoingstates!(mp.prob, mp.states) + end end end @@ -273,7 +275,7 @@ function solve_benders(stepnr::Int, subix::SubsystemIx) end end if count == 15 - println("Warning: Benders did not converge within 15 iterations, reltol=$(reltol), ub=$(ub), lb=$(lb), step=$(stepnr), subix=$(subix)") + @warn("Warning: Benders did not converge within 15 iterations, reltol=$(reltol), ub=$(ub), lb=$(lb), step=$(stepnr), subix=$(subix)") end maintiming[5] = count @@ -351,6 +353,7 @@ end function update_statedependent_mp(stepnr::Int, prob::TuLiPa.Prob, startstates::Dict{String, Float64}, settings::Dict) has_statedependentprod(settings["problems"]["stochastic"]["master"]) && TuLiPa.statedependentprod!(prob, startstates, init=(stepnr==1)) has_statedependentpump(settings["problems"]["stochastic"]["master"]) && TuLiPa.statedependentpump!(prob, startstates) + has_statedependentleveling(settings["problems"]["stochastic"]["master"]) && TuLiPa.statedependentleveling!(prob, startstates) return end