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 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.