0

docplex モデルに 2 次制約を追加しようとしていますが、線形として解釈され、エラー メッセージが表示されます。

以下はスクリプトからの抜粋です

二次制約は次のとおりです。

mdl.add_constraints((mdl.sum(Allocation[o,p] * Folds[o,p] for o in rangeOils) == proddf['Demand'][p] for p in rangeProd))

ここに座っています

rangeOils = range(nb_Oils)
rangeProd = range(nb_Products)

#this is our decision variable it containts a matrix of the oils and the products
Allocation = mdl.continuous_var_matrix(keys1=nb_Oils, keys2=nb_Products, lb=0)


#this is another decision variable  it contains a matrix of the folding an oil needs in a product 
Folds = mdl.continuous_var_matrix(keys1=nb_Oils, keys2=nb_Products, lb=1)


#adding demand constraint - demand must be met even after a product is folded
mdl.add_constraints((mdl.sum(Allocation[o,p] * Folds[o,p] for o in rangeOils) == proddf['Demand'][p] for p in rangeProd))

どんな助けでも大歓迎です

ここにエラーがあります

DOcplexException: Expecting linear constraint, got: x1*x155+x3*x157+x5*x159+x7*x161+x9*x163+x11*x165+x13*x167+x15*x169+x17*x171+x19*x173+x21*x175+x23*x177+x25*x179+x27*x181+x29*x183+x31*x185+x33*x187+x35*x189+x37*x191+x39*x193+x41*x195+x43*x197+x45*x199+x47*x201+x49*x203+x51*x205+x53*x207+x55*x209+x57*x211+x59*x213+x61*x215+x63*x217+x65*x219+x67*x221+x69*x223+x71*x225+x73*x227+x75*x229+x77*x231+x79*x233+x81*x235+x83*x237+x85*x239+x87*x241+x89*x243+x91*x245+x93*x247+x95*x249+x97*x251+x99*x253+x101*x255+x103*x257+x105*x259+x107*x261+x109*x263+x111*x265+x113*x267+x115*x269+x117*x271+x119*x273+x121*x275+x123*x277+x125*x279+x127*x281+x129*x283+x131*x285+x133*x287+x135*x289+x137*x291+x139*x293+x141*x295+x143*x297+x145*x299+x147*x301+x149*x303+x151*x305+x153*x307 == 500000 with type: <class 'docplex.mp.constr.QuadraticConstraint'>
4

1 に答える 1