Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link resources #16

Open
GijsHuis opened this issue Feb 23, 2017 · 2 comments
Open

Link resources #16

GijsHuis opened this issue Feb 23, 2017 · 2 comments

Comments

@GijsHuis
Copy link

Hi,

I'm currently investigating if pyschedule can help me generate a planning for machines and tools. For optimal result the tools and machines should be linked for as long as possible but because of more tools than machines and timing of orders tool changes are needed.

I didn't find an direct way to make such a link. I tried several tings with idle time tasks for the tools with a connected change task for tool and machine. But had the idea that the required option didn't functioned.

I hope that you can tell me if what i did makes sense and if there is an option I missed.

Thanks in advance,

from pyschedule import Scenario, solvers, plotters
import random

class Order:
    def __init__(self, delTime, prodTime, tool):
        #time in days
        self.delTime = delTime
        self.prodTime = prodTime
        self.tool = tool 

def genOrders(nOrders, meanDelTime, meanProdTime):
    orders = []
    for i in range(nOrders):
        orders.append(Order(int(random.normalvariate(meanDelTime,5)),int(random.normalvariate(meanProdTime,1)),random.randint(0,4)))
    return orders
        
scen = Scenario('factory_simple', horizon = 25)

machs = [scen.Resource('Mach_%d' % i) for i in range(3)]
tools = []
tasks = []

for i in range(5):
    tools.append(scen.Resource('Tool_%d"' % i, size=2))

    #tool change
    tasks.append(scen.Task('TC_%d' % i))
    tasks[-1].required= False
    tasks[-1] += [machs[0]|machs[1]|machs[2],tools[-1]]
    #tool idle
    tasks.append(scen.Task('Idle_%d' % i,length = 2))
    tasks[-1] += tools[-1]
    tasks[-1].required= False
    #after idle time tool change
    scen += tasks[-1]  <= tasks[-2]


orders = genOrders(10,25,3)
for i, order in enumerate(orders):      
    tasks.append(scen.Task('Order_%d'%i,length = order.prodTime))
    scen += tasks[-1] < order.delTime      
    tasks[-1] += [machs[0]|machs[1]|machs[2],tools[order.tool]]
                 
         
# Solve and print solution
scen.use_makespan_objective()
#scen.use_flowtime_objective()
solvers.mip.solve(scen,msg=1)

# Print the solution
print(scen.solution())    

plotters.matplotlib.plot(scen,fig_size=(15,10))
@timnon
Copy link
Owner

timnon commented May 21, 2018

Sorry for the late reply

Interesting problem, i dont think this is possible at the moment. You can of course manually add this to the internal mechanics.

Thinking about some "natural" way to add this: there probably should be the option to dynamically adjust task attributes depending on the resources they are scheduled on. E.g. if a task T is scheduled on some recource with name R, then T.R = 1. This could then used in combination with capacity constraints to bound the number of switches ...

@timnon
Copy link
Owner

timnon commented May 21, 2018

Update, one thing that might work is to declare every combination of machine and tool as a resource. This would blow up the resources, since 3 machines and 10 tool would result in 30 resources. However, this might be a good option if either the number of machines or tools is relatively small.

Then you need to ensure that every resource that contains a particular machine or tool is only used once in each time step. This could be done by having "filler" tasks that block everything except one resource.

Finally, you can use capacity constraints to limit the number of switches on one resource, let me know if you are still interested...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants