How to design the models in OptaPlanner in my case - optaplanner

I have been started to learn Opataplanner for sometime, I try to figure out a model design for my use case to progress the solution calculation, here is my case in real world in manufactory's production line:
There is a working order involved list of sequential processes
Each kind of machine can handle fixed types of processes.(assume machine quantity are enough)
The involved team has a number of available employees, each employee has the skills for set of processes with their different own working cost time
production line has fixed number of stations available
each station put one machine/employee or leave empty
question: how to design the model to calculate the maximum output of completion product in one day.
confusion: in the case, the single station will have one employee and one machined populated, and specified dynamic processed to be working on. but the input of factors are referred by each other and dynamic: employee => processes skill , process skill => machines
can please help to guide how to design the models?

Maybe some of the examples are close to your requirements. See their docs here. Specifically the task assignment, cheap time scheduling or project job scheduling examples.
Otherwise, follow the domain modeling guidelines.

Related

Calculating Production chain using a database (factorio)

I'm playing the game Factorio, where you build a factory.
For the time being, I made a kind-of flowchart using libreoffice calc to calculate how many machines I need to produce a certain material.
Example image from the spreadsheet
Each block has a recipe saved (blue). This recipe includes what and how much it produces and needs and how much time it takes.
It takes the demand from the previous Block (yellow) and, using the recipe, calculates how many machines (green) it needs to fulfill this demand.
Based on the amount of machines it calculates its own demands (orange).
Then the following blocks do the same, until it has reached the last block.
Doing this in a spreadsheet does work, but it is quite a tedious task.
I showed this to my dad, as I'm quite proud of what I made, and he said that maybe a database would be more suitable.
I definitely see its advantages. For example I could easily summarize the final demands of raw resources, or the total power consumption, etc.
So I got myself Microsoft Access, and I'm pretty lost now. I know the basics of Databases and some SQL-Coding, but I'm not quite sure how I would make this.
My first attempt was:
one table for machines. It includes the machines production speed and other relevant stats.
one table for recipes. Each recipe clearly states what it produces, what it needs, the amount of each, and whether or not it is a basic. Basic means that it is a raw resources, i.e. the production chain would end with this.
one table for units. Each unit has a machine, a recipe and an amount. For example I would have one unit using basic assemblers to produce iron gears. This unit also says how many machines there are, so it needs more and produces more.
I did manage to make a query that calculates the total in and outputs of all units based on their machine and recipe, as well as a total energy consumption.
However, that is nowhere near the spreadsheet I made.
For now we can probably set the Graphical overlay aside, that would probably be quite a bit overkill. However what I do want to be able to make:
enter how much I want of a certain resources
based on that entry the database would create a new table. The first entry would be the unit that produces the requested resources. The second would fulfill the firsts demand, the third fulfills the seconds demand, and so on.
So in the end I would end up with a list of units that will produce my requested resource.
I hope someone can help me. There are programs out there that already do this kind of stuff, but I want to do this myself. If this is a problem that a database isn't suited for, then please tell me so.
Thanks for any help!

Optaplanner Employee Rostering with VRPTW

I am working on a use case which is a combination between the Nurse Rostering example and a VRP problem. In isolation, I understand and can tweak both to a certain extent, but I'm not quite sure how to merge them.
To illustrate my use case further, I am trying to schedule nurses (considering skills, contract, and preferences) to patients homes, located within a 20-40 mile radius.
As an example, a nurse with the "insulin" skill would need to travel to a patient, arriving within a certain time window, perform a task for 15 mins, then travel to another patient, perform the same task, and continue until its 8 hour shift is complete. There are multiple skills and tasks to be considered.
I reviewed the Nurse Rostering example and it is a great fit for my use case, but I don't see how to modify it to account for traveling between "shift locations". The VRPTW example is again a great fit, but it does not account for skills, contracts, and preferences.
Any thoughts on how to go about modelling this problem would be highly appreciated.
Even if my answer can possibly be still too general for you to use, I would combine both models in a way more or less similar to the following :
use the nurse rostering example's model as the start point
in that model, include all intervention locations's properties; this includes at least : the intervention location data, the time window in which to intervene at the location, and the needed skill(s) needed to do the intervention locally
combine both model's constraints, not to forget at least the constraint(s) penalising a visit to a location with an insufficient skillset (sounds like a hard constraint) and the constraint(s) penalising lengthy travel times/distances.
I also suspect a more intensive usage of the shadow variables due to the combination of both models.
May still sound too vague, but that would be the direction where I would work towards.

What kind of problem is this? Is feasible with optaplanner?

I have to solve a problem on a manufacturing environment where:
A number of processes with subtasks needs to be scheduled.
Each subtask need N resources that can be, raw material, workers or machines.
Some subtasks need a worker with certain skills or from a department.
Workers are organized in shifts, so it may happen that on a shift certain skill may not be available. *
A machine can fit N pieces, depending on the piece size and the capacity of the machine. *
A machine may accept pieces of different types. *
Machines can be not available on a period as maintenances can happen.
If the next piece going to the machine is different from the previous one, a new task for maintenance needs to be inserted. *
If there is no raw material of certain category it can be manufactured, so a new process to manufacture that raw material needs to be inserted before the one that needs it. *
The processes can have a deadline.
Some raw materials can be partially consumed, so for example if we have 2L of painting, a subtask require 1L of that painting.
Is this a Job Shop or any variant problem? Is it possible to do with optaplanner? Are there too many constraints for the solver?
I know that the tasks scheduling and the requirements of each subtasks can be done, my biggest concern is with the ones that I have marked with *
Thank you in advance.
In the OptaPlanner docs, look for the Design Patterns chapter and read the section on how to design a good model and also the section on assigning to time (timeslot vs time grain vs chained).
These are 2 related video's:
https://www.youtube.com/watch?v=0uAoWU8m0pE
https://www.youtube.com/watch?v=Ew6pq9nJKog

Optaplanner VRP example, multiple vehicles required per stop in same time window

We are using a customized VRP tutorial example to optimize daily routes for service engineers who travel to customers in order to execute certain repair and installation tasks. We do have time windows and we optimize 1000+ tasks for multiple weeks into the future.
Our (simplified) domain model consists of:
Engineer - the guy doing all the work
Task - a single work assignmet at a certain location
DailyRoute - an Engineer's route for given day, consists of a linked list of Tasks
As a new requirement we must now support two engineers working in parallel on the same task.
Our current plan is to implement this by creating subtasks for the second engineer and implement a rule that their arrival time must be identical to the main task.
However, this is problematic since moving one of the interdependant tasks to a different time (e.g. a different DailyRoute) will mostly violate the above constraint.
So far, we have come up with the following ideas:
Allow single task moves only to a DailyRoute on the same day as the other task's assigned route
can be done via a SelectionFilter
Use CompositeMoves to move both of the parallel tasks at once to different days
Do we need a custom MoveIteratorFactory to select the connected tasks?
Or can this be done with a CartesianProductMoveSelector instead?
Can we use nearby selection for the second move to prefer the same day as the first move's newly assigned day (is move one already done at that time)?
For two engineers working in parallel on the same task, see docs "design patterns" specifically "the delay till last pattern". There is no example, but our support services have helped implemented it a few times - it works.
For the multiple stops at the same location: I've seen users split such visits up into smaller pieces to allow optaplanner to choose which of those pieces to aggregate. It works but it's not perfect: the more fine-grained the pieces, the much bigger the search space - the more that adding a custom move that focusses on moving all pieces together might help (but I won't start out with it). Generally speaking: if the smallest vehicle has a capacity of 100, I 'd run some experiments with splitting up to half that capacity - and they try a quarter too, just to see what works best through benchmarking with optaplanner-benchmark.

What optimization algorithm is more suitable for timetable rescheduling?

I'm working on the project where university course is represented as a to-do list, where:
course owner (teacher of the course) can add tasks (containing the URL to the resource needs to be learned and two datetime fields - when to start and when to complete the task)
course subscriber (student) can mark tasks as complete or not complete and their marks are saved individually for each account.
If student marks task as complete - his account + element he marked are shown in the course activity tab for teacher where he can:
initiate a conversation in JavaScript-based chat with him
evaluate the result of the conversation
What optimization algorithm you could recommend me to use for timetable rescheduling (changing datetime fields for to-do element if student procrastinates) here?
Actually, we can use the student activity on the resource + fact that he marked the task as complete + if he clicked or not on the URL placed on the to-do element leading to the external learning material (for example Google Book).
For example, are genetic algorithms suitable for this model and what pitfalls do they have: https://medium.com/#vijinimallawaarachchi/time-table-scheduling-2207ca593b4d ?
I'm not sure I completely understand your problem but it sounds like you have a feasible timetable to begin with and you just need to improve it.
If so genetic algorithms will work very well, but I think representing everything as binary 'chromosomes' like in the link might not be practical.
There are many other ways you can represent a timetable, such as in a 2D array, or giving an event a slot number.
You could look into algorithms such as Tabu search, Simulated Annealing and Great Deluge and Hill Climbing. They are all based on similar ideas but some work better with some problems than others. For example if you have a very rough search space simulated annealing won't be the best and Hill Climbing usually only finds a local optimum.
The general architecture of the algorithms mentioned above and many other genetic algorithms and Metaheuristics is: select a neighbouring solution using a move operator (e.g. swapping the time of one or two or three events or swapping the rooms of two events etc...), check the move doesn't violate any hard constraints, use an acceptance strategy such as, simulated annealing or Great Deluge, to determine if the move is accepted. If it is keep the solution and repeat the steps until the termination criterion is met. This can be max time, number of iterations reached or improving move hasn't been found in x number of iterations.
Whilst this is running keep a log of the 'best' solution so when the algorithm is terminated you have the best solution found. You can determine what is considered 'best' based on how many soft constraints the timetable violates
Hope this helps!