0

I'm working on creating a dictionary of constraints for a large SCED power problem for minimization. However, I'm being given a ValueError saying an unknown type is passed despite only using Optimize.LinearConstraints at present. When I change to NonlinearConstraints (shown below), indicating that 'NonlinearConstraint' object has no attribute 'A'.

I have a feeling it's due to recursive elements, as even using a single constraint as I've defined them returns the same error

Any idea how I can create the recursive linear constraints?

##EDIT

I've been told to copy the code and provide a bit more context. "gen_supply_seg" is a three dimensional array that, depending on different points in time, has different constraints

def con2a():
    for t in range(len(LOAD)):
        for g in range(len(GEN)):
            nlc2a = optimize.NonlinearConstraint(gen_supply_seg[t,g,1],lb=0,ub=P2Max[g])
            return(nlc2a)

def con2b():
    for t in range(len(LOAD)):
        for g in range(len(GEN)):
            nlc2b = optimize.NonlinearConstraint(gen_supply_seg[t,g,2],lb=0,ub=P3Max[g])
            return (nlc2b)

def con2c():
    for t in range(len(LOAD)):
        for g in range(len(GEN)):
            nlc2c = optimize.NonlinearConstraint(gen_supply_seg[t,g,3],lb=0,ub=P4Max[g])
            return (nlc2c)
con2a = con2a()
con2b = con2b()
con2c = con2c()

These constraints are then added to a set like shown

cons = (con2a,
        con2b,
        con2c)
  • Welcome to SO! [Please don't upload images of your code](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question). Instead, provide a minimal code snippet that we can copy-paste in order to help you. No one is willing to type out your code. – joni Jun 28 '22 at 07:49
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 28 '22 at 08:20

0 Answers0