Pezetter
Pezetter

Reputation: 2862

OptaPlanner overconstrained planning - virtual values

I am working on an Optaplanner implementation where we want to support overconstrained planning.

IE, a hospital with 9 beds at one time should serve 9 patients, when there are 9 OR more patients that need a bed...

The docs mention using "virtual values" to indicate what resources are lacking, but no where is there an example of, either in plain text or code, what a "virtual value" is. At least, that I can find.

https://www.optaplanner.org/docs/optaplanner/latest/repeated-planning/repeated-planning.html#overconstrainedPlanningWithVirtualValues

For my current use case,

We have a task planning entity And a nullable timeslot planning variable.

Currently, we have a medium penalty for any task without a timeslot. As solving runs, the medium penalty increases (gets closer to zero). However, it always seems to stop short at -3 to -1. Perhaps due to our other constraints. When investigating the solution after solving "finishes", it appears to be missing timeslots that would work.

So, i'm looking for an explanation of what a "virtual value" is, and if any examples exist. Also, if any constrained planning code examples exist in general.

Upvotes: 1

Views: 212

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

If you use a virtual value, then don't use nullable=true. In both cases you add a medium constraint (using HardMediumSoftScore for example):

nullable=true

Does the best it can to maximize utilization. Works well if unassigned entities are someone else's problem (or service is simply denied to those entities).

No virtual values. Add a medium constraint to penalize the number of entities assigned to null. It will then maximize the number of assignments without breaking the hard constraints. Hard and soft constraints do not count for unassigned entities.

virtual values

Works well if unassigned entities are your problem, for example if you need to solve it by hiring freelance employees, rent beds off-site, etc.

Add virtual values (beds for example). Do an estimate of the number of needed virtual values somehow (domain specific formula), double that and add so many. Add a medium constraint to penalize the number of entities assigned to a virtual value. Hard (and soft?) constraints count for entities assigned to virtual values.

Upvotes: 2

Related Questions