0

I want to formulate a flexible job shop scheduling problem with MIP instead of CP.

If there is an array indicating number of operations of each job.

num_op = [3, 2, 5]

And Xijk is the decision variable indicating if the j-th operation of job i is processed on machine k or not.

My question is that I don't know how t initiate the 3-D array with different number of operations of each job.

I wrote this dvar boolean x[i in Jobs][j in][k in Machs];, and I don't know to how to complete it.

Please help me. Thanks!!

1 Answer 1

1

If I understand your example correctly then your definition of num_op indicates that you have three different jobs, the first job has 3 operations, the second has 2 and the last job has 5 operations. That would mean that the second dimension of Xijk has to change depending on the first dimension. Such a flexible array size is not possible with CPLEX.

Here is an alternative:

  • Define M to be the maximum number of operations (5 in your case).
  • Define dvar boolean x[i in Jobs][j in 1..M][k in Machs];
  • Explicitly fix all variables to 0 that correspond to non-existing operations: forall (i in Jobs, j in 1..M, k in Machs) if (j > num_op[i]) X[i][j][k] == 0;

The last step is even optional: You can define the variables for non-existing operations but just not use them anywhere in your model (this may give a warning for unused variables, though).

Another option is to create a tuple tuple { int i; int j; int k }, then create a tuple set that contains all the valid combinations of i, j, k and index X by this tuple set.

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

6 Comments

Can I ask you another problem? Since my M will be an array, how to implement it into dvar boolean x[i in Jobs][j in 1..M][k in Machs];?In other words, I want it to be a jagged 3D array. And, Can I use tuple as a decision variable? Thank you so much for helping me.
I am not quite sure how M could be an array (it denotes the maximum value in num_op, so it should be a number). But in any case, if M is an array you can write j in M instead of j in 1..M. You cannot use a tuple as decision variable, but you can use tuples to index decision varibiables. That is probably what you want here,
I wrote this:int nbOps[1..3]=[3,2,5]; dvar boolean x[Jobs][j in nbOps][Mchs];But the error says I cannot use int[range] with "in".
Because in my problem, there is different number of operations in each job, and each operation can choose machine among its candidate machine set. As a result, I need the variable Xijk to denote if the j-th operation of job i is processed on machine k or not. Different job i has different number of operations. j depends on job i. Is there any method for me to model this Xijk? Thank you so much.
Why do you want (or need) to model this with a 3D array? Using a simple array indexed by a set of tuples is much simpler in practice and usually makes it much easier to write your constraints correctly and also easier to interpret the results. One of the biggest obstacles to writing good (i.e. correct and readable) models is being stuck in a mental expectation and approach of thinking of these models in terms of 2D, 3D or higher arrays.
|

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.