Search code examples
scheduleanylogic

Setting up multiple schedules for a ResourcePool


I am doing a simulation of a production line, which is built through Excel. Now there is one, which needs free setting of worker shifts for each machine, three shifts in total.

My idea is to create three different Schedules, representing each of the three shifts, and then in the ResourcePool, use the If statement to set up the use of each shift. As shown in the picture enter image description here

But it didn't work. If it is possable, Could you please tell me if there is something wrong with the Java statement or the idea is wrong. If possible, could you please tell me how to set multiple schedules in ResourcePool?

Additions to the question: The model is to do the evaluation of the production system and the shift of the workers is an important evaluation parameter. What I want to do is to enter the shift of the workers directly in the Excel sheet and ResourcePool recognizes and uses the corresponding Schedule.

I tried to generate the corresponding Schedule by code, but the Schedule of Resourcepool cannot be set dynamically. So I would like to try to manually input multiple Schedules into the model and then set the corresponding Schedule in ResourcePool by If statement like the image.

Thanks in advance


Solution

  • The first thing you need to know is that the location where you placed the code is a static parameter, thus it is only evaluated once, when the object is created and not checked continuously.

    This is indicated by the little popup when you hover over the button that change the entry field from code to value

    enter image description here

    If it was dynamic it would state Dynamic Value instead of Static Value

    Secondly, inside that field you must use a ternary operator, not an if statement, so that the result of the formula is a scheduled object, else you will get a "misplaced construct(s)" error

    If you changed the code to

    v_Shift == "Shift1" ? 
    s_Shift1 : v_Shift == "Shift2" ? s_Shift2 : s_Shift3
    
    

    It will work BUT:

    1. It will only be evaluated when the object is created and not again
    2. Rather not use == on Strings, always use .equals(), on Strings it might work, and sometimes it might not. You can do some research as to why ;-)

    Solution: You will have to use a function to change the schedule of the resource pool. Call this function whenever the v_Shift variable changes

    enter image description here