Regarding use of Max in Jump code

It looked correct. How did you compute C_ki[2, 2] to be 95? It really can be 96 according to those equations and the data you provided.

According to the solution it provides, jobs j3 and j2 should process in factory 2 in the order j3—>j2. Now according to the data provided as pij, job j3 takes 28 units of time on machine 1 and 67 units of time on machine 2 (Row 3 of pij). Therefore its completion time will be 28+67=95 units. And due date for job j3 provided as dj (3rd element) is 96. Therefore there should be an earliness of 1 unit.

This is an imprecision in your formulation. There’s nothing stopping C[2, 2] from taking the value 96 to avoid the earliness penalty.

In this case, what you typed matches your mathematical formulation, and JuMP is finding the optimal solution to that formulation. If that’s not the answer you want, then you’ll need to have another think about the formulation of your model.

Ok Sir. I will do it again. Thank you so much for your time. It is much appreciated.

image.png

Please tell me how to code this equation in Julia when there is a 'not equal’ condition in the index.

@constraint(model, [j=1:n], sum(X_jk[j, k] for k in 1:n if k != j) == 1)

(Not sure k should start at 0? X is only defined for k=1:n.)

image.png

Thanks, it worked. Now, I’m stuck in these equations. The first one is a constraint and the second one is a decision variable.

You can introduce filters on the set of constraints using the @constraint(model, [set; condition], ...) syntax, which you already used for k > l and i == m. You just need a k != j instead.

For the second part, it’s probably easiest to create X as the full dense matrix, then use

for i in 1:n
    fix(x[i, i], 0.0; force = true)
end

to essentially disable the variable. Then your sums can go over the j=k index, but nothing will happen because x[j,k] is 0.

1 Like

When I tried this, an error occurred in the following constraint.
image.png

**Jump code: @constraint(model, con1[j in 1:n], sum(X_kj[0,j]==F for j in 1:n))**

Error is rectified by doing @constraint(model, con1[j in 1:n], sum(X_kj[0,j] for j in 1:n)==F).

image.png

You don’t need to index the constraint over j:

@constraint(model, con1, sum(X_kj[0,j] for j in 1:n)==F).