Dynamic Variable with Two Values Inside a While Loop

3 views (last 30 days)
How to express a dynamic variable with two values or more inside a while loop:
An example of what I mean by a dynamic is a time of a job in a work shop at one of the machines so (Tij) T is for Time i is the job identification number, where i=(1,2,3) as an example j is the machine identification number, where j=(1,2,3,4,5,6) as an example
So when I say: T35 is the time of the 3rd job in the 5th machine. T11 is the time of the 1st job in the 1st machine. T35 & T11 can occur at the same time, let say both occurred when time = 1:00pm
My question how create a while loop that will finish all the three (3) jobs in all the six (6) machines. Also let say each machine takes 3 minutes to complete a job and it can only treat one job at a time.
I not sure if this dynamic variable can be an array or a structure or something else.

Answers (1)

dpb
dpb on 15 Jan 2017
Don't see that you need any loop at all. Simply populate a nJobMax by nMachines array with the appropriate start time values and accumulate total duration by column given the job duration as being fixed.
If the assignment is N jobs to the machine at one time to be processed sequentially, then it's even more trivial of just being that number*duration/job plus the starting time.
The new datetime class with duration variables should make this pretty simple to code.
  6 Comments
Alaa Al-Saffar
Alaa Al-Saffar on 23 Feb 2017
Edited: dpb on 24 Feb 2017
Dear dpb
Thank you for your prompt reply and your notice, My apologies I missed typed the matrix of D It should be: D=[5 7;3 8;4 7]
In the loops the indexes return the selected value from the D matrix and substitute it in D(i,j) in the loop. for example if:
i=1,j=1
D(i,j)=D(1,1)=5
Also you are right about simulating large number of jobs! :)
I am working on optimization problem for a Job Shop Scheduling Problem, more specifically know as Hoist Scheduling Problem (HSP).
I know that matlab has a package for HSP https://www.youtube.com/watch?v=sRN6xxexn0Q But only for one hoist, my problem is with 5 hoists and it is big size problem.
I do not know if it will possible to do my HSP on MC Simulation?
So I am planning to use the variable T(i,j) as basic variable to obtain the time for each operation (Start & Finish) to build my simulation.
Of course there are other operation types (other than that start & finish), but I guess it will take time to explain all about my HSP here.
I read many Q&A on mathworks.com, but I am afraid that I have not found how to code it. I guess it has to do with (structure, or cells, or Array, and eval command).
I really want to know how code this variable as one unit that is capable to enter loops, in order to program my full algorithm.
Once again I thank you for your reply. If you any ideas, I will be happy to hear them from you. But Please I want to know how to code T(i,j). Thank you in-advance.
Best Regards Alaa
dpb
dpb on 23 Feb 2017
Well, there are any number of examples of for loops, but the power in Matlab is in the vector operations. You'll probably want an outer loop for each of the trials, but look again at the solution above without looping that solves the time issue for all machines and all times for a given sampled duration dataset without needing any loops at all.
And, forget you've even heard of eval, there "there be dragons!" :)

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!