Hello,
I could use some guidance on this. I have the following model:
COP(ΔT) = 20.3595 - 3.2061 * log2(1 + ΔT)
function baseline_model(
df::DataFrame;
A_d::Matrix{Float64},
B_d::Matrix{Float64},
)
T_a::Vector{Float64} = df.T_a
Φ_s::Vector{Float64} = df.Φ_s
z_u::Vector{Float64} = df.z_u
z_l::Vector{Float64} = df.z_l
λ_e::Vector{Float64} = df.λ_e
# MILP formulation
model = Model(Gurobi.Optimizer)
# check that all input vectors have the same length
N = length(T_a)
@assert length(Φ_s) == N
@assert length(z_u) == N
@assert length(z_l) == N
@assert length(λ_e) == N
# heating powers
@variable(model, Φ_CV[1:N] >= 0)
@variable(model, Φ_HP[1:N] >= 0)
@variable(model, Φ_h[1:N] >= 0)
@variable(model, z_CV[1:N], Bin)
@variable(model, z_HP[1:N], Bin)
# heatpump electrical power
@variable(model, P_HP[1:N] >= 0)
# gas flow
@variable(model, g[1:N] >= 0)
# slack variables for thermal comfort violations
@variable(model, t_u[1:N] >= 0)
@variable(model, t_l[1:N] >= 0)
# State variables [T_i, T_e, T_h] - [°C]
m = size(A_d, 1)
@variable(model, T[1:N, 1:m])
# named state variables
T_i = T[:, i]
T_e = T[:, e]
T_h = T[:, h]
# initial condition
T_init = [df.T_i[1], df.T_i[1], df.T_i[1]]
@constraint(model, T[1, :] == T_init)
# COP efficiency of the heat pump
@variable(model, η_COP[1:N] >= 1.0)
# make sure the envelope thermal energy is not emptied
@constraint(model, T_e[1] <= T_e[N])
for k in 1:N
# thermal efficiency
ΔT = T_h[k] - T_a[k]
# ΔT = T_h_fixed - T_a[k]
@constraint(model, η_COP[k] == COP(ΔT))
@constraint(model, Φ_HP[k] == η_COP[k] * P_HP[k])
@constraint(model, Φ_CV[k] == η_g * H_g * g[k])
# power limits
@constraint(model, Φ_HP[k] >= Φ_HP_min * z_HP[k])
@constraint(model, Φ_HP[k] <= Φ_HP_max * z_HP[k])
@constraint(model, Φ_CV[k] >= Φ_CV_min * z_CV[k])
@constraint(model, Φ_CV[k] <= Φ_CV_max * z_CV[k])
@constraint(model, 0 <= P_HP[k] <= P_HP_max)
# temp limit for T_h
@constraint(model, 15 <= T_h[k] <= 75)
# comfort violation
@constraint(model, T_i[k] - z_u[k] <= t_u[k])
@constraint(model, z_l[k] - T_i[k] <= t_l[k])
end
# heat balance
for k in 1:N-1
u_k = [T_a[k], Φ_h[k], Φ_s[k]]
@constraint(model, Φ_h[k] == Φ_CV[k] + Φ_HP[k])
@constraint(model, T[k+1, :] == A_d * T[k, :] + B_d * u_k)
end
# energy cost
@expression(model, J_c, sum(λ_e[k] * P_HP[k] * Δt + λ_g * g[k] for k in 1:N))
# discomfort cost
@expression(model, J_d, sum(c_u * t_u[k] + c_l * t_l[k] for k in 1:N))
# multi-objective
@objective(model, Min, [J_c, J_d])
optimize!(model)
@assert is_solved_and_feasible(model)
return model
end
I can solve the MILP formulation of this problem in 0.06 seconds.
I am now trying to set a baseline by solving the MINLP version of this problem. The problematic part is this formula:
COP(ΔT) = 20.3595 - 3.2061 * log2(1 + ΔT)
Which I use in the NL formulation like this:
# NL form
ΔT = T_h[k] - T_a[k]
# Linear form
# ΔT = T_h_fixed - T_a[k]
@constraint(model, η_COP[k] == COP(ΔT))
@constraint(model, Φ_HP[k] == η_COP[k] * P_HP[k])
I have been trying to solve the NL form but all the solvers I have tried seem to run forever. So either my problem formulation is wrong or I’m not using the right solver. I tried some of the suggestions in this topic: Multi-objective MINLP problem in JuMP - #12 by ashefa
Could someone please advise on what solver I should use? Thanks!