I am trying to write a constraint that sums the process times for each row of a matrix, Z[a,p] where Z is a binary decision variable = 1 if a is assigned p; = 0 otherwise.

I am trying to multiply the 1’s in the row by the process times Pt in order to get the sum of the process time for each a.

I originally wrote:

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

but realized this wasn’t actually extracting the binary variables so I asked on stack exchange (Julia-Jump Integer Programming Optimization model: issue with multiplying matrix by vector - Stack Overflow) and was helped to writing the constraint:

Z_value = value.(Z)

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

But this is throwing me an error: “OptimizeNotCalled()”

Here is the most distilled down version I could make of the model:

```
# Set of all available associates to work on line
A = 1:2
# Set of all work processes required to complete production on the line
P = 1:2
# Set of all process times in seconds
Pt = [8.5, 2.41]
# The takt limit for each associate working on the line (210 seconds)
takt_lim = 10
m = Model()
# Binary variable = 1 if associate a is assigned to station s; = 0 otherwise
@variable(m, Y[A, S], Bin)
# Minimize the total number of associates needed to run the line
@objective(m, Min, sum(sum(Y[a, s] for a in A) for s in S))
# All Associates must stay under the takt_lim
Z_value = value.(Z)
@constraint(m, associate_takt[a in A, p in P], sum(Z_value[a, p]*Pt[p] for p in P) <= takt_lim)
set_optimizer(m, Cbc.Optimizer)
optimize!(m)
```