Can I know if the constraint below can be defined as follows in Pyomo for convex optimization.


W and G are arrays of dimension M x N.

del_t = 5
M = 2 # set of active tasks
N = 4 # 4 time steps
maxP = 0.14
d = np.array([20,20]) # deadline in seconds
curr_time = 0 

## Third constraint START ##
m.c3 = []
for i in range(M):
    for k in range(N):
        if curr_time + k*del_t <= d[i] + curr_time:
            c3_exp = m.W[i+1,k+1] + m.G[i+1,k+1] <= maxP*del_t
            m.c3.append(Constraint(expr= c3_exp))
            c3_exp = m.W[i+1,k+1] + m.G[i+1,k+1] == 0
            m.c3.append(Constraint(expr= c3_exp))
## Third constraint END ##

Can I also know if the output I get below when I run this code is correct


  • $\begingroup$ Can you please provide an MWE? BTW, it seems to me that the code has not completely adopted the Pyomo environment. You still can enhance that. $\endgroup$ Mar 29 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.