Question regarding COSMO Convergence

Hi, I have a question regarding COSMO package, this is my first time using it, what steps can I take when my code does not converge(but in reality it should)? It delivers message “Max_iter_reached” and stops at a value that is much smaller than the objective value.

Thank you very much for your help!

pmax=zeros(numbuses);
SOCmax=zeros(numbuses)
wf=zeros(numbuses)
VoWS=0
VoLS=10000
ηdis=0.85
ηch=0.85
windscale=zeros(times)
include("warmstart.jl")
###########################
strategy = with_options(COSMO.NoMerge)
m = JuMP.Model(with_optimizer(COSMO.Optimizer, verbose = true, decompose = false, merge_strategy = strategy, eps_prim_inf = 1e-4, eps_dual_inf = 1e-4, max_iter = 10000 ,eps_abs = 1e-4, eps_rel = 1e-4,check_infeasibility= 1000000,rho=0.1))
@variable(m, dis[1:times, 1:numbuses])
set_start_value.(dis,dis0)
@variable(m, ch[1:times, 1:numbuses])
set_start_value.(ch,ch0)
@variable(m, SOC[1:times, 1:numbuses])
set_start_value.(SOC, SOC0)
@variable(m, g[1:times, 1:numgenerators])
set_start_value.(g, g0)
@variable(m, f[1:times, 1:numlines])
set_start_value.(f, f0)
@variable(m, θ[1:times, 1:numbuses])
set_start_value.(θ, θ0)
@variable(m, ws[1:times, 1:numbuses])
set_start_value.(ws, ws0)
@variable(m, Δl[1:times, 1:numlines])
set_start_value.(Δl, Δl0)
@variable(m, ploss[1:times, 1:numlines])
set_start_value.(ploss, ploss0)
@variable(m, bigθ[1:times, 1:numlines])
set_start_value.(bigθ, bigθ0)
@variable(m, Γ[1:times, 1:numgenerators])
set_start_value.(Γ, Γ0)
@variable(m, OC)
JuMP.set_start_value(OC, OC0)
@objective(m,Min, OC)
@constraint(m, OC==sum(c0[i] for i=1:numgenerators)+sum(sum(Γ[t,i] for t=1:times) for i=1:numgenerators)+sum(sum(VoWS*ws[t,n] for t=1:times) for n=1:numbuses)+sum(sum(VoLS*Δl[t,l] for t=1:times) for l=1:numlines))#14
#正半定矩阵
for t=1:times
    for i=1:numgenerators
        @SDconstraint(m, ([c1[i]*g[t,i]-Γ[t,i]  sqrt(c2[i])*g[t,i];sqrt(c2[i])*g[t,i]  -1]) <=zeros(2,2))#15
        @constraint(m, Pgmin[i]<=g[t,i])#2
        @constraint(m, g[t,i]<=Pgmax[i])
    end
end
for t=2:times
    for i=1:numgenerators
        @constraint(m, -RD[i]<=g[t,i]-g[t-1,i])#3
        @constraint(m, g[t,i]-g[t-1,i]<=RU[i])
    end
end
for t=1:times
    for n=1:numbuses
        @constraint(m, 0<=ws[t,n])#4
        @constraint(m, ws[t,n]<=wf[n]*windscale[t])
    end
end
for t=1:times
    for l=1:numlines
        @constraint(m, -deg2rad(15)<=θ[t,head[l]]-θ[t,tail[l]])
        @constraint(m, θ[t,head[l]]-θ[t,tail[l]]<=deg2rad(15))
        @constraint(m, f[t,l]==bl[l]*(θ[t,head[l]]-θ[t,tail[l]])+ploss[t,l])#5
        @constraint(m, -Plmax[l]-Δl[t,l]<=f[t,l])#7
        @constraint(m, f[t,l]<=Plmax[l]+Δl[t,l])
        @constraint(m, 0<=Δl[t,l])#8
        #@constraint(m, Ml[l]==[0  0; 0  0.5*gl[l]])#17
        @constraint(m, (θ[t,head[l]]-θ[t,tail[l]])^2<=bigθ[t,l])
        #@constraint(m, hatθ[t,l]==[1 θ[t,head[l]]-θ[t,tail[l]];θ[t,head[l]]-θ[t,tail[l]] bigθ[t,l]])
        @constraint(m, ploss[t,l]==tr([0  0; 0  0.5*gl[l]]*[1 θ[t,head[l]]-θ[t,tail[l]];θ[t,head[l]]-θ[t,tail[l]] bigθ[t,l]]))
        @SDconstraint(m, [1 θ[t,head[l]]-θ[t,tail[l]];θ[t,head[l]]-θ[t,tail[l]] bigθ[t,l]]>=zeros(2,2))
    end
end
for t=2:times
    for n=1:numbuses
        @constraint(m, SOC[t,n]==SOC[t-1,n]+ch[t,n]*T-dis[t,n]*T)#9
    end
end
#初始时刻SOC=0
for n=1:numbuses
    @constraint(m, SOC[1,n]==0)
end
for t=1:times
    for n=1:numbuses
        @constraint(m, 0<=ch[t,n])#10
        @constraint(m, ch[t,n]<=pmax[n])
        @constraint(m, 0<=dis[t,n])#11
        @constraint(m, dis[t,n]<=pmax[n])
        @constraint(m, 0<=SOC[t,n])#12
        @constraint(m, SOC[t,n]<=SOCmax[n])
        @constraint(m, sum(g[t,i] for i=1:numgenerators if genid[i]==n)-sum(f[t,l] for l=1:numlines if head[l]==n)+sum(f[t,l] for l=1:numlines if tail[l]==n)-ch[t,n]/ηch+dis[t,n]*ηdis+wf[n]*windscale[t]-ws[t,n]==Pd[n]*loadscale[t])#13
    end
end

optimize!(m)
optimal_objective = objective_value(m)
g_opt=value.(g)
θ_opt=value.(θ)
f_opt=value.(f)
bigθ_opt=value.(bigθ)
Δl_opt=value.(Δl)

2 Likes

Please read the first post of Please read: make it easier to help you. In particular, it’s easier to help if you can provide a minimal working example. You’re almost there, but I can’t run your code because I don’t have “warmstart.jl”.

One reason you are having trouble is that you are enforcing variable bounds as constraints. Do this instead:

@variable(m, Pgmin[i] <= g[1:times, i = 1:numgenerators] <= Pgmax[i])
1 Like