首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >微电网中电池调度的约束优化

微电网中电池调度的约束优化
EN

Stack Overflow用户
提问于 2019-07-10 10:42:10
回答 2查看 1.8K关注 0票数 3

给定输入,如电力消耗,太阳能电池板发电,价格(所有在给定的时间t),我们有一个电池,我们想要评估它应该(dis)/charge在任何特定的时间。问题可以表述如下:

Pt = price of electricity at time t

Lt = consumption of electricity at time t

Zt = charge of battery at time t (how much is in the battery)

St = Electricity generated from solar generator at time t

Qt = amount the battery (dis)/charges at time t

我们试图优化的函数是Ct = Pt *(Lt - St - Qt)

这样做的目的是尽量减少用电量。

有以下限制:

Lt - St - Qt >= 0 (our demand has to be non-negative)

Qmin <= Qt <= Qmax ( the battery can only (dis)/charge between certain values at any given time)

Zmin <= Zt <= Zmax. (the battery has to be within its capacity, i.e. you can't discharge more than the battery holders, and you can charge more than the battery can hold)

Zt+1 = Zt + Qt+1 ( this means that the battery level at the next time step is equal to the battery level at the previous time step plus the amount that was (dis)/charged from the battery)

我所面临的问题是如何在python中制定这个问题,特别是更新电池的级别。

我知道其他图书馆(Pyomo,Pulp)也存在,欢迎加入解决方案。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-07-13 22:18:00

幸运的是,我被Giorgio的回答激发了学习pyomo (我主要是用户)的动机,所以利用你的问题来确保我理解了所有的界面。我会把它贴在这里,这样以后我可以自己再找到它:

代码语言:javascript
复制
import pyomo.environ as pyomo
import numpy as np

# create model
m = pyomo.ConcreteModel()

# Problem DATA
T = 24

Zmin = 0.0
Zmax = 2.0

Qmin = -1.0
Qmax = 1.0

# Generate prices, solar output and load signals
np.random.seed(42)
P = np.random.rand(T)*5.0
S = np.random.rand(T)
L = np.random.rand(T)*2.0

# Indexes
times = range(T)
times_plus_1 = range(T+1)

# Decisions variables
m.Q = pyomo.Var(times, domain=pyomo.Reals)
m.Z = pyomo.Var(times_plus_1, domain=pyomo.NonNegativeReals)

# objective
cost = sum(P[t]*(L[t] - S[t] - m.Q[t]) for t in times)
m.cost = pyomo.Objective(expr = cost, sense=pyomo.minimize)

# constraints
m.cons = pyomo.ConstraintList()
m.cons.add(m.Z[0] == 0.5*(Zmin + Zmax))

for t in times:
    m.cons.add(pyomo.inequality(Qmin, m.Q[t], Qmax))
    m.cons.add(pyomo.inequality(Zmin, m.Z[t], Zmax))
    m.cons.add(m.Z[t+1] == m.Z[t] - m.Q[t])
    m.cons.add(L[t] - S[t] - m.Q[t] >= 0)

# solve
solver = pyomo.SolverFactory('cbc')
solver.solve(m)

# display results
print("Total cost =", m.cost(), ".")

for v in m.component_objects(pyomo.Var, active=True):
    print ("Variable component object",v)
    print ("Type of component object: ", str(type(v))[1:-1]) # Stripping <> for nbconvert
    varobject = getattr(m, str(v))
    print ("Type of object accessed via getattr: ", str(type(varobject))[1:-1])

    for index in varobject:
        print ("   ", index, varobject[index].value)
票数 4
EN

Stack Overflow用户

发布于 2019-07-11 22:50:51

根据我的经验(线性/ MIP)优化是这类应用程序的一种有效方法。在我看来(是的),Pyomo是一个很好的工具:

  • 它是用Python写的
  • 总体设计很棒
  • 它具有来自其他建模语言的最常见的特性(AMPL,GAMS.)
  • 它为大多数求解器提供了简单的接口。
  • 它维护得很好(请查看Github页面)

文档相当广泛,托管在这里:https://pyomo.readthedocs.io/en/latest/index.html

你可以在这里找到更多的资料:examples.html

另外,是对Pyomo的一个相当广泛的介绍的链接,它深入到相当高级的主题,如随机优化和双级问题。

最后,唯一具体的问题,你的情况是,你可能想把损失的充放电电池。首先,定义两个充放电的自变量(它们都是非负的),这样你就可以把电池的能量平衡写成一个约束,把时间t的能量状态( SOE )和时间上的SOE联系起来。

祝好运!

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56968971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档