Pyomo disjunction of time-series arrays; error: “… LP writer does not know how to process

I wish to implement an electrical device powered by a PV curve in the pyomo.gdp (General Disjunctive programming) extension. In per unit system, the device needs at least 50% of the PV’s peak power.So, there are two disjunct states, ON and OFF. The optimiser shall maximise the usage (power P) of the device at all hours, in the simple example simply setting it equal to P_PV.
I know the BigM method would work here, but for later, more complex work, I really need the gdp capabilities, so I wish to understand and get the gdp syntax for disjunct for time arrays running.

My main problem is how to have implement the disjuncts for the device´s ON-state and OFF-state.
I have looked at all online examples I could find:

1.) The “SolverMax” blog post on the topic of disjuncts: SolverMax Post
2.) The pyomo documentation’s examples for disjunctions: Pyomo doc examples
3.) The “SolverMax” authors have cleared out the same doubt I have at stack exchange. Of course my current approach is to adapt to their syntax using rule based disjunctions StackExchange post

I closely followed the solution approach prsented in 3. and tried hard to debug. Just, I am stuck with the error message:

"ValueError: The model ('Disjunct_ON_OFF_modes') contains the following active components that the LP writer does not know how to process:
    <class 'pyomo.gdp.disjunct.Disjunct'>:

disjunct_ON[0]
disjunct_ON[1]
...
disjunct_ON[9]
disjunct_OFF[0]
disjunct_OFF[1]
...
disjunct_OFF[10]
"

Here is my full code:

from pyomo.environ import *
import numpy as np
from pyomo.gdp import *


# GENERATING PV INPUT DATA (synthetic dummy data)--------------------------
pv_out_pu = 1*np.sin(np.pi/12 * np.arange(0,10,1)) #pu - per unit system
for i in range(len(pv_out_pu)):
    if pv_out_pu[i]<0: # night hours, zero irradiance
        pv_out_pu[i]=0 # negative values are set to zero


# Create a ConcreteModel
model = ConcreteModel("Disjunct_ON_OFF_modes")

# Define a set of indices
model.t = Set(initialize=range(10)) # 10 hours

model.P_PV = Var(model.t, bounds=(0, 1))
model.P_device = Var(model.t, bounds=(0, 1))

model.PV_CAPACITY = Param(initialize=1) #at the moment just for data type conversion
# A.- right place for general constraints?
def constr_pv_out(model, t):  # setting the model variable to the numpy value
    return model.P_PV[t] == model.PV_CAPACITY * pv_out_pu[t]
model.constr_pv_out = Constraint(model.t, rule=constr_pv_out)

def constr_P_device_by_PV(model, t):
    return model.P_device[t] <= model.P_PV[t]
model.constr_device_by_pv = Constraint(model.t, rule=constr_P_device_by_PV)


# Define disjunct_ON and disjunct_OFF as 'Disjuncts' using a rule using constraint-specific constraints
def ON_rule(d,i): # DISJUNCT ON
    #model =d.model() # not sure if needed
    d.constr1_x = Constraint(expr=model.P_device[i]>=0.5) # threshold: 50 % in per unit system needed
model.disjunct_ON = Disjunct(model.t, rule=ON_rule)

def OFF_rule(d,i): # DISJUNCT OFF
    #model =d.model()
    d.constr_x = Constraint(expr=model.P_device[i]<=0.499)
    #d.constr_device_by_pv = Constraint(expr=model.P_device[i] <= model.P_PV[i]) # B.- right place for constraints?
    #d.constr_pv = Constraint(expr=model.P_PV[i] <= model.PV_CAPACITY * pv_out_pu[i])
model.disjunct_OFF = Disjunct(model.t, rule=OFF_rule)

def ON_OFF_Disjunction_rule(model, i): # DISJUNCTION ON or OFF for each timestep
    return [model.disjunct_ON[i], model.disjunct_OFF[i]]
model.ON_OFF_Disjunction = Disjunction(model.t, rule=ON_OFF_Disjunction_rule)


def Objective_fcn(model):
    return sum(model.P_device[t] for t in model.t)
model.obj = Objective(rule=Objective_fcn, sense=maximize)

model.pprint()

# Apply transformation and solve
TransformationFactory('gdp.bigm').apply_to(model)
solver=SolverFactory('gurobi')
results = solver.solve(model, tee=True)

Also, as commented in the code, I am unsure if I have to put general constraints in each Disjunct. I believe not, it should actually only be the constraint which applies in the respective disjunct, so the 50% threshold, right?
Thanks in advance!

New contributor

user24727878 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật