0

I have written an optimization model that has 3 binary decision variables that are all in matrix form (X[p,s], Y[a,s], and Z[a,p]). a=associate, p=process, and s=station.

I have encountered an issue with coding a constraint for my Z variable. Z is a decision variable = 1 if associate assigned process; = 0 otherwise.

I want to write a constraint that ensures no associate is assigned more process time than they can handle. I've attempted this by writing: @constraint(m, associate_takt[a in A, p in P], sum(Z[a, p]*Pt[p] for p in P) <= takt_lim)

This is supposed to multiply every value in a row of Z by their corresponding times stored in the vector Pt. This would give a sum of process time for that row (associate) which is then checked to ensure it is less than some value "takt_lim" (process time restriction). I would like to do this for all rows (associates) in matrix Z.

I tried updating the constraint to: @constraint(m, associate_takt[a in A, p in P], sum(value.(Z[a, p])*Pt[p] for p in P) <= takt_lim) but this creates an error as the Z variables have not been optimized yet: "OptimizeNotCalled()"

1 Answers1

0

Isn't it just:

@constraint(
    m, 
    associate_takt[a in A],
    sum(Z[a, p]*Pt[p] for p in P) <= takt_lim,
)

I don't see why you need to loop over all p in P for the constraint.

Oscar Dowson
  • 2,395
  • 1
  • 5
  • 13
  • 1
    Ah, I didn't realize what the "p in P" was doing to the constraint within the brackets. This seems to be working now. Thank you!! – Brett Davis Jul 21 '22 at 10:55