I'm new to OptaPlanner, and seen how some problems can be solved fairly easily by modifying from the very useful sets of example. I'm trying to figure out what is the best way to model my problem.
I have a group of deliverymen, and their job is to deliver supplies from multiple suppliers to multiple customers. The tricky part is that the customers requirements and suppliers supplies are range values that varies from month to month. And I also have the option to hire temp deliverymen if the supplies and demands of the month is too high. End result is to maximize profit for each month.
What category of optimization problem am I facing, and I'm struggling to find the best way to model this problem. Any suggestions?
Put in a number of temp deliverymen as normal deliverymen with a boolean temp=true, and have your score constraints penalize those more (I presume a higher soft weight as the soft score will be your profit).
This is basically the pickup and delivery variation of the VRP example. Some of our users have adjusted the VRP example to this already (see some of the other questions here on stackoverflow tagged with optaplanner). Basically the trick is to write a score constraint that understands that the "load" of a vehicle changes through its route (but it should always be less than its "capacity").
You can schedule 1 month (or 1 week or less or 2 months or more) at a time, but you can also do "continuous planning" (if months affect each other like in nurse rostering, but I doubt that's the case here) (if so, see the optaplanner video on youtube) to plan a window.
Related
I'm new to ORTools and I need some guidance on which algorithm to choose for this problem:
(I think it is an assignment problem, but also a mix with route optimization and VRP..)
A salesman has N shops to visit
Every shop has a service time T (ex: 30 minutes)
Shops are categorized this way:
a) Category 1 = must be visited twice a week
b) Category 2 = must be visited once a week
c) Category 3 = must be visited biweekly (every two weeks)
d) Category 4 = must be visited once a month
A shop cant be visited 2 days in a row
The salesman should work up to 9 hours (1 hour for lunch)
The salesman should visit 8 to 12 shops a day (soft constraint)
The salesman should work up to 176 hours a month
Some shops can be discarded from the solution. (prefer to keep the ones with lower category)
We have the geolocation and a time distance matrix for the shops
The objectives are:
Maximize the number of shop visited
Minimize the KMs for the salesman
This is an example of shops distribution
First of all, it seems like you're trying to solve the problem globally, i.e. to find an optimal monthly or yearly schedule for the entire problem. I suspect that might be difficult, and suggest to try relaxing the problem, say: to a daily one.
For instance, maybe for a given day, it's possible to compile a list of stores which should be visited, perhaps by order of scores. So maybe a store that was visited yesterday will not be in the list; and one that has to be visited once a week, and was visited 6 days ago would be on the top of the list.
Then, you might be able to solve using a variant of the VRP solver on that list; you can use simulation (maybe with some random element) to generate a weekly or monthly schedule based on that. It's not guaranteed to be optimal, but might be good enough.
If your problem is more complex then what the OR-Tools VRP solver can handle, you can try using the more general CP-SAT solver, which is very generic, and can handle VRP-like problems with additional constraints, e.g. Scheduling problems or other constraints.
You can also consider using other approaches here, e.g. Tabu search.
Hi and happy new year to all Optaplanner users,
we have a requirement to plan tours. These tours contain chained and time-windowed activities (deliveries) executed by a weekly changing number of trucks.
The start time of a single tour can vary and is dependent on several conditions (i.e. the goods to be delivered must be produced, before the tour can start; only a limited number of trucks can be served at the plants gates at the same time; truck must be back before starting a new tour). Means: also the order of tours can vary and time gaps between the tours of a truck can occur.
My design plan is, to annotate TourStartTime as a second planning variable in Optaplanners VRPTW-example and to assign TourStartTime to 2-hours time grains (planning horizon is 1 week and tours normally do not start during night times; so the mentioned time grains reflect a simplified calendar for possible tour starts).
The number of available trucks (from external logistic companies) can vary from week to week. Regarding this I wanted to plan with a 'unlimited' number of trucks. But the number of trucks per logistic company, that can be actually assigned with deliveries, should be controlled by a constraint (i.e. 'trucks_to_be_used_in_parallel').
Can anybody tell me, if this is a feasable design approach, or where do I have to avoid traps (ca. 1000 deliveries/week, 40-80 trucks per day) ?
Thank you
Michael
A second planning variable is possible (and might be even the best design depending on your requirements), but it will blow up the search space and maybe even custom course grained moves might become needed to get great results.
Instead, I 'd first investigate if the Truck's TourStartTime can be made a shadow variable. For example, give all trucks a unique priority number. Then make a Truck's TourStartTime a shadow variable: the soonest time a truck can leave. If there are only 3 lanes and 4 trucks want to leave, the 3 trucks with the highest priority number leave first (so get the original TourStartTime, the 4th truck gets a later one).
I am working on a VRP with the following characteristics:
The vehicle can only pick up 1 customer at one time
The vehicle picks up a customer at a location and drops off the customer at the destination
After dropping off the customer the vehicle goes on to pick up another customer
There is no depot that vehicle needs to go to in between the trips .
The vehicle makes as many trips as it can in a day to pickup/drop-off customers
At the end of day, the vehicle goes back to its designated parking station
Essentially, it's like a taxi system. It seems to me that it's a VRP with multiple trips(VRPMT) and no depot (Open VRP). I'd like to know
Does optaplanner has support for VPRMT and OVRP out of box?
If VPRMT and OVRP are not supported out of box, how easy is it to modify the existing CVRP/CVRPTW examples to make it solve OVRP and VPRMT?
Maybe I am on the wrong track and it's not even a VRP. If so, what would be the right planning problem for the taxi like system?
Many thanks in advance!
No, the examples don't include pickup and delivery or multiple trips yet
Users have done it before to add Pickup and Delivery (which is easy if multiple customers cannot be in the vehicle at the same time (otherwise it's harder and I might add an example for that way some day). Multiple trips and open VRP should by easy (although I think your parking station is a depot and you probably don't have multiple trips, just multiple customer sequentially in the same trip).
This is definitely a variant of VRP. Do note that every business has their own flavor of VRP. You'll always find some custom constraints (now or later in the development process). OptaPlanner allows you to add those custom constraints as needed.
Try this: Take the OptaPlanner VRP example, rename Depot to ParkingStation. Split up Customer's Location into pickupLocation and deliveryLocation and adjust the score rules so the soft score is the sum of:
all pickup to delivery distances
all delivery to next pickup distances
each parking to first pickup distance
each last delivery to parking distance
I'm new to optaplanner and im trying to tweak the VRP example to solve a "similar" problem... but with some differences:
We have a central depot, n customers and a fleet of one or more vehicles.
Each customer has a certain "maximum capacity" (not the same for all of them).
Same for each vehicle.
Initial conditions from the problem include:
"actual capacity" and "desired capacity" for each customer, so that:
actual capacity is >=0 and <=max capacity
desired capacity is >=0 and <=max capacity
"actual depot capacity" is the amount of items available at the depot
We want to REDISTRIBUTE some items so that each customer gets his "desired capacity".
(Tipically most items will be redistributed from one customer to another)
Hard constraints are "maximum capacity"s cannot be excedeed
Soft constraints are vehicle distance (minimize) and difference from "desired capacity" (minimize)
I started by generating a data file for the VRP example with negative customer demand (to simulate desired capacity < actual capacity) but quickly discover that constraint in drl that sums up all customers demands to satisfy vehicle capacity restriction is not what we need here.
¿Do you think that this problem is "similar enough" to worth modifying VRP example?
Yes, it's definitely worth taking the OptaPlanner VRP example (with or without the example GUI) and customizing it to these needs. Start from OptaPlanner 6.0.0.CR1 or better yet CR4 which will be released next week normally. Don't use CR3 because it might have a bug related to shadow variables in VRP.
A) Let's presume customerDemand = customerDesired - customerActual. This can be positive (need more items) and negative (need to get rid of items).
Question: How do we validate the Vehicle capacity? We can't just sum it, because it fluctuates from customer to customer. Answer: We use a shadow variable (let's call it freight) on Customer to calculate how many items the vehicle is transporting from the previous customer to the current. This is very similar to how arrivalTime works for the TimewindowedCustomer example. Then use a score constraint rule to verify freight on every customer is lower than the vehicle's maximum capacity. And also that freight is >= 0 at every customer.
Now, A) works well if there are plenty of vehicles. Even if there aren't enough items, checking the soft constraint is pointless because it's a fixed constant number (the number of items lacking). You could even decide to spread that shortage fairly over the customers and adjust their customerDesired accordingly, before scheduling.
B) However, if there aren't plenty of vehicles, relative to the number of customers, then A) might be insufficient. We 'll want to allow to deliver/pickup less than customerDemand, making it more flexible (and therefore complex :). In this case, a Customer has 2 genuine (=non-shadow) planning variables (instead of just 1): the previousStandstill (~ previous customer) and the deliveryPickup (<= demand * 2).
Lets say I have a website that sells widgets. I would like to do something similar to a tag cloud tracking best sellers. However, due to constantly aquiring and selling new widgets, I would like the sales to decay on a weekly time scale.
I'm having problems puzzling out how store and manipulate this data and have it decay properly over time so that something that was an ultra hot item 2 months ago but has since tapered off doesn't show on top of the list over the current best sellers. What would be the logic and database design for this?
Part 1: You have to have tables storing the data that you want to report on. Date/time sold is obviously key. If you need to work in decay factors, that raises the question: for how long is the data good and/or relevant? At what point in time as the "value" of the data decayed so much that you no longer care about it? When this point is reached for any given entry in the database, what do you do--keep it there but ensure it gets factored out of all subsequent computations? Or do you archive it--copy it to a "history" table and delete it from your main "sales" table? This is relevant, as it has to be factored into your decay formula (as well as your capacity planning, annual reporting requirements, and who knows what all else.)
Part 2: How much thought has been given to the decay formula that you want to use? There's no end of detail you can work into this. Options and factors to wade through include but are not limited to:
Simple age-based. Everything before the cutoff date counts as 1; everything after counts as 0. Sum and you're done.
What's the cutoff date? Precisly 14 days ago, to the minute? Midnight as of two Saturdays ago from (now)?
Does the cutoff date depend on the item that was sold? If some items are hot but some are not, does that affect things? What if you want to emphasize some things (the expensive/hard to sell ones) over others (the fluff you'd sell anyway)?
Simple age-based decays are trivial, but can be insufficient. Time to go nuclear.
Perhaps you want some kind of half-life, Dr. Freeman?
Everything sold is "worth" X, where the value of X is either always the same or varies on the item sold. And the value of X can decay over time.
Perhaps the value of X decreased by one-half every week. Or ever day. Or every month. Or (again) it may vary depending on the item.
If you do half-lifes, the value of X may never reach zero, and you're stuck tracking it forever (which is why I wrote "part 1" first). At some point, you probably need some kind of cut-off, some point after which you just don't care. X has decreased to one-tenth the intial value? Three months have passed? Either/or but the "range" depends on the inherent valud of the item?
My real point here is that how you calculate your decay rate is far more important than how you store it in the database. So long as the data's there that the formalu needs to do it's calculations, you should be good. And if you only need the last month's data to do this, you should perhaps move everything older to some kind of archive table.
you could just count the sales for the last month/week/whatever, and sort your items according to that.
if you want you can always add the total amonut of sold items into your formula.
You might have a table which contains the definitions of the pointing criterion (most sales, most this, most that, etc.), then for a given period, store in another table the attribution of points for each of the criterion defined in the criterion table. Obviously, a historical table will be used to store the score for each sellers for a given period or promotion, call it whatever you want.
Does it help a little?