Machine scheduling problem - algorithm

i have a combinatoric problem as such:
You are given N testers.
Each tester is one of M different types.
Each tester can be configured to use one of P different configs.
.
You have L lots of products to test,
Each product can only be tested on specific Tester type,
Each product can only be tested by Tester configured with specific Configs. Some of the Configs can be applied on multiple products.
Any tester can change its config during production, but each change on tester config will incur additional time U .
Each lot has a lot size that determines its test-time, Q.
Now i need to come out a lot scheduling algorithm such that the time to finish testing all lots is minimum.
What are the best approaches to tackle this kind of problem ?

It can be modelled as a Job-Shop problem (JSP) with setup times where the job size is 1. Unfortunately it gets pretty hard to find an optimum when the number of jobs > 10.
There are many free solver implementations out there that contain Job-Shop as a sample problem:
If you're using C++, Gecode is good. If you're free to choose, ECLiPSe Prolog contains source code for the JSP.
If you can do with a good solution (instead of an optimal one), I suggest using a greedy algorithm (for the JSP, greedy algorithms give solutions typically within 10% of the optimum - I had some experience with this). I'm gonna think about one and get back here (the problem is what are called 'setup time constraints', i.e. the constraints coming from changing tester configuration).

Related

Need an advice about algorithm to solve quite specific Job Shop Scheduling Problem

Job Shop Scheduling Problem (JSSP): I have jobs that consist of tasks and I have machines that can perform these tasks.
I should be able to add new jobs dynamically. E.g. I have a schedule for the first 5 jobs, and when the 6th arrive - I need to be able to fit it into the schedule in the best way. It is possible to adjust existing schedule within the given flexibility constrains.
Look at the picture below.
Jobs have tasks, each task is the same type of action. Think about painting of some objects with paint spray. All the machines are the same (paint sprays), and all of the tasks are the same.
Constraint 1. Jobs have a preferred deadline for completion, but the deadline is flexible to some extent.
Edit after #tucuxi answer: Flexible deadline mean that the time of completion can be extended by some delta if necessary.
Constraint 2. Between the jobs there is resting phase. Think about drying the paint. Resting phase has minimal required duration. Resting phase can be longer or shorter if necessary.
Edit after #tucuxi answer: So there is planned time of rest Tp which is desired, but flexible value that can be increased or decreased if this allows for better scheduling. And there is minimal time of rest Tm. So Tp-Tadjustmenet>=Tm.
The machine is occupied by the job from the start to the completion.
Here goes parts that make this problem very distinct from what I have read about.
Jobs arrive in batches of several jobs. For example a batch can contain 10 jobs of the type Job_1 and 5 of Job_2. Different batches can contain different types of jobs. All the jobs from the batches should be finished as close to each other as possible. Not necessary at the same time, but we need to minimize the delay between the completion of first and last jobs from the batch.
Constraint 3. Machines are grouped. In each group only M machines can work simultaneously. Think about paint sprays that are connected to the common pressurizer that has limited performance.
The goal.
Having given description of the problem, it should be possible to solve JSSP. It should be also possible to add new jobs to the existing schedule.
Edit after #tucuxi answer: This is not a task that should be solved immediately: it is not a time-critical system. But it shouldn't be too long to irritate a human who put new tasks into the algorithm.
Question
What kind of many JSSP algorithms can help me solve this? I can implement an algorithm by myself, if there is one. The closest I found is This - Resource Constrained Project Scheduling Problem. But I was not able to comprehend how can I glue it to the JSSP solving algorithm.
Edit after #tucuxianswer: No, I haven't tried it yet.
Is there any libraries that can be used to solve this problem? Python or C# are the preferred languages, but in the end it doesn't really matter.
I appreciate any help: keyword to search for, link, reference to a book, reference to a library.
Thank you.
I doubt that there is a pre-made algorithm that solves your exact problem.
If I had to solve it, I would first:
compile datasets of inputs that I can feed into candidate solvers.
think of a metric to rank outputs, so that I can compare the candidates to see which is better.
A baseline solver could be a brute-force search: test and rate all possible job schedulings for small sample problems. This is of course infeasible for large inputs, but for small inputs it allows you to compare the outputs of more efficient solvers to a known-best answer.
Your link is to localsolver.com, which appears to provide a library for specifying problem constraints to then solve them. It is not freely available, requiring a license to use; but it would seem that your problem can be readily modeled in it. Have you tried to do so? They appear to support both C++ and Python. Other free options exist, including optaplanner (2.8k stars in github) or python-constraint (I have not looked into other languages).
Note that a good metric is crucial to choosing a good algorithm: unless you have a clear cost function to minimize, choosing "a good algorithm" is impossible. In your description of the problem, I see several places where cost is unclear (marked in italics):
job deadlines are flexible
minimal required rest times... which may be shortened
jobs from a batch should be finished as close together as possible
(not from specification): how long can you wait for an optimal vs a less-optimal-but-faster solution?

Can subset of SimCity ( BuildIt) economy expressed in Minizinc?

I would like to write a solver for scheduling production in SimCity buildit. As I am a total beginner with Minizinc ( and solvers in general - blush), I am not sure whether what I want to try makes sense at all.
In SimCity one needs to produce resources ( iron, wood, seeds, plastic, ...) first and can then use them to create products ( hammers, nails, boards ).
Resources and products may be combined to create other products ( e.g. a chair may require wood, hammer and nails ).
Resources can be produced in parallel ( each factory has e.g. 5 slots to produce any kind of resource, but no queueing ).
Products are created in topic related shops (e.g. furniture, tools, etc.) sequentially ( with a - limited length - production queue ).
Storage for resources & products is shared and limited.
What I would like to understand is whether the creation of a planner to spit out the fastest possible schedule for a list of items to be produced is possible in Minizinc at all or whether I better start explicit coding right away ?
These kinds of problems can be solved using MiniZinc, although I haven't heard of somebody solving this specific problem. Your problem seems to be closely related to the jobshop problem. This problem might provide a good baseline and there are various models for versions of this problem to start from. You can find many example models (of varying quality) in the MiniZinc benchmark repository: https://github.com/MiniZinc/minizinc-benchmarks
As Patrick Trentin pointed out, you have to keep in mind the complexity of the kinds of problems that are solved using MiniZinc. Often the time to solve them can grow exponentially or even worse. To find solution to the hard problems both the way in which the problem is modelled and the techniques the solver uses (and which solver to use) to solve the problem has be taken into account. If you are just getting started with MiniZinc I would suggest following the MiniZinc Coursera courses, which will get you started in no time: https://www.coursera.org/learn/basic-modeling

What is a solution for a TSP with multiple salesmen and no return but known vertices and end points?

I don't know if I worded that correctly and I am not sure if it is even a TSP problem but here is the scenario.
I am designing and trying to optimize a route planner for a delivery service. I have multiple drivers (salesmen) who are all picking up packages at a central depot (origin) and delivering them on their way home. Their home locations (end-points) are known and all the delivery destinations (vertices) on the map are also known. After finishing the deliveries, the drivers go home instead of coming back to the depot.
What kind of problem is this and what sort of solutions should I be looking into? I have been treating it as a multi-TSP without return but still can't determine any near optimum tours. I have also tried shortest length Hamiltonian path but i'm quickly running into a bloc once i introduce a second driver.
Any resources, algorithms and heuristics suggestions are also welcome.
Geoffrey is right. It is a Vehicle Routing Problem. However, it is not the classical capacitated (CVRP) one with a single depot, since your drivers probably start and end at home rather than at the depot. Therefore your problem becomes a bit more difficult and turns to a pickup and delivery problem (VRPPD).
In short: if your drivers just start and end at the depot, it is a CVRP. If they start and end at home, it is a VRPPD.
For the CVRP you can find a number of open source algorithms for example OptaPlanner which is written in Java (Geoffrey knows more about it) or VRPH which is a C++ lib. When it comes to VRPPD the number of available open source algorithms shrink. Probably you can do it with OptaPlanner (I am not hundred percent sure). But you can surely solve it with jsprit which I implemented in Java.
If your problem is large and you need fast response times (computation times), you might be better off turning your VRPPD into CVRP by assuming drivers to ride from home to depot first and finally from depot to home again. But this way you ll certainly loose optimization potential.
This is called the Vehicle Routing Problem (VRP).
There are many resources available on that topic, such as video's (capacitated and/or time windows) and docs.
The VRP web offers a good explanation of the different variants.
This article seems to consider exactly the same problem as you want, and calls it: "K-vehicles Windy Rural Postman Problem".
Authors: Benavent, Corber, Sanchis and Plana.
A few articles like this one call the no return condition variant with one salesman Open VRP (OVRP).
Authors: D Aksen, Z Özyurt and N Aras2.
2013 paper on VRP without return: http://www.hindawi.com/journals/tswj/2013/874349/
Authors: Tantikorn Pichpibul Ruengsak Kawtummachai.

Scheduling with variable Resources

(First of all, sorry for my english, it's not my first language)
I have a list of tasks/jobs, each task must start after a specific start time, needs to run for a certain time and has to be finished after a certain end time.
I can dynamically add and remove workers, so it is possible to execute 2 or more tasks at the same time if I have to. My Goal is to find a scheduling plan that executes each job successfully and uses the minimal amount of workers possible.
I'm currently using an EDF (http://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling) Algorithm and recursively call the function with a higher Worker Limit if it can't schedule all jobs correctly, but I think this doesn't work right because I don't have a real way to measure when I can lower the ressource limit again.
Are there any Algorithms that work for my problem, or any other clever ideas?
Thanks for your help.
A scheduling problem can often be solved very effectively by formulating it either as mixed-integer program (MIP)
http://en.wikipedia.org/wiki/Mixed_integer_programming#Integer_unknowns
or expressing it using constraint programming (CP)
http://en.wikipedia.org/wiki/Constraint_programming
For either MIP or CP, you will find both free and commercial solvers that can address your problem.
In both of these approaches, you put your effort into stating the properties that the solution must have, and the hard work of applying an appropriate algorithm is left to a specialized solver.

Constrained graph transformation in scheduling applications

I'm working on an interactive job scheduling application. Given a set of resources with corresponding capacity/availabilty profiles, a set of jobs to be executed on these resources and a set of constraints that determine job sequence and earliest/latest start/end times for jobs I want to enable the user to manually move jobs around. Essentially I want the user to be able to "grab" a node of the job network and drag that forwards/backwards in time without violating any of the constraints.
The image shows a simple example configuration. The triangular job at the end denotes the latest finish time for all jobs, the connecting lines between jobs impose an order on the jobs and the gray/green bars denote resource availabilty and load.
You can drag any of the jobs to compress the schedule. Note that jobs will change in length due to different capacity profiles.
I have implemented an ad-hock algorithm that kinda works. However there are still cases where it'll fail and violate some constraints. However, since job-shop-scheduling is a well researched field with lots of algorithms and heuristics for finding an optimal (or rather good) solution to the general NP-hard problem - I'm thinking solutions ought to exist for my easier subset. I have looked into constraint programming topics and even physics based solutions (rigid bodies connected via static joints) but so far couldn't find anything suitable. Any pointers/hints/tips/search key words for me?
I highly recommend you take a look at Mozart Oz, if your problem
deals only with integers. Oz has excellent support for finite domain
constraint specification, inference, and optimization. In your case
typically you would do the following:
Specify your constraints in a declarative manner. In this, you would
specify all the variables and their domains (say V1: 1#100, means
V1 variable can take values in the range of 1--100). Some variables
might have values directly, say V1: 99. In addition you would specify
all the constraints on the variables.
Ask the system for a solution: either any solution which satisfies
the constraints or an optimal solution. Then you would display this
solution on the UI.
Lets say the user changes the value of a variable, may be the start
time of a task. Now you can go to step 1 to post the problem to the
Oz solver. This time, solving the problem most probably will not take
as much time as earlier, as all the variables are already instantiated.
It may be the case that the user chose a inconsistent value. In that
case, the solver returns null. Then, you can take the UI to the earlier
solution.
If Oz suits your need and you like the language, then you may want to
write a constraint solver as a server which listens on a socket. This way,
you can keep the constraint solver separate from the rest of your code,
including the UI.
Hope this helps.
I would vote in favor of constraint programming for several reasons:
1) CP will quickly tell you if there is no schedule that satifies your constraints
2) It would appear that you want to give you users a feasible solution to start with but
allow them to manipulate jobs in order to improve the solution. CP is good at this too.
3) An MILP approach is usually complex and hard to formulate and you have to artificially create an objective function.
4) CP is not that difficult to learn especially for experienced programmers - it really comes more from the computer science community than the operations researchers (like me).
Good luck.
You could probably alter the Waltz constraint propagation algorithm to deal with changing constraints to quickly find out if a given solution is valid. I don't have a reference to hand, but this might point you in the right direction:
http://www.sciencedirect.com/science?_ob=ArticleURL&_udi=B6TYF-41C30BN-5&_user=809099&_rdoc=1&_fmt=&_orig=search&_sort=d&_docanchor=&view=c&_searchStrId=1102030809&_rerunOrigin=google&_acct=C000043939&_version=1&_urlVersion=0&_userid=809099&md5=696143716f0d363581a1805b34ae32d9
Have you considered using an Integer Linear Programming engine (like lp_solve)? It's quite a good fit for scheduling applications.

Resources