[rules-users] OptaPlanner - best strategy for variable number of planning entities?

Geoffrey De Smet ge0ffrey.spam at gmail.com
Tue Mar 4 03:37:48 EST 2014


On 03-03-14 23:32, Nadim wrote:
> Hi, I'm new to OptaPlanner, and reading through the planning examples in the
> documentation left me with a question.  One problem I'm trying to model
> involves a variable number of planning entities, which I didn't really see
> addressed by any of the examples; they all seemed to me more focused on
> varying the states of planning variables for a fixed / known number of
> entities.
Yes. Although OptaPlanner has been designed to deal with a variable 
number of entities,
none of the examples do it yet and there are no generic moves for it
- so it's uncharted territory.
>
> To throw out some specifics...let's say I'm trying to optimize my attendance
> schedule for some convention.  I have a set of problem facts, the various
> events going on at the convention, with each having a time (when the event
> happens), and a worth (how much I'd like to be there for that event).
ok
> And I have a set of planning entities, the various times that I'm present at
> the convention.
Sounds weird to me.
It's sounds like you're assigning the pigeon holes to the pigeons,
instead of assigning the pigeons to the pigeon holes.
>   So, I'm trying to model the case where my key constraint is
> the total amount of time I spend at the convention...let's treat that as
> fixed.  I don't care how many separate times I go there, though I will have
> to model constraints like a minimum length per visit (very inefficient to go
> for 10 minutes at a time), and a minimum separation between visits (annoying
> / inefficient to leave, then turn right around and go back, unless I get an
> hour break).
Sounds like the nurse rostering example.
>
> Again, I didn't see a good way to just say "have any number of planning
> entities in the planning entity collection, so long as they meet the
> constraints".  So instead, I modeled the problem as a set of visits,
> calculated as the max possible visits (total conference length / minimum
> visit duration).  Then I defined each visit to have three planning
> variables:  start time, duration, and whether that visit is "active".
I wouldn't model it like this.
3 planning variables, probably each with a minute or second accuracy.
The size of search space must be crazy.
Or you're forced to write complex moves to avoid using minutes like 
10:03 if no session starts at that time.

Instead, I 'd model it like this:
For every session, I create:

@PlanningEntity
class SessionAttendance {
    Session session;
    @PlanningVariable boolean attending;
}

Based on that, your start and end times can be calculated.
Either in the score calculation itself (insertLogicals etc like in nurse 
rostering)
Or with shadow variables (like in vehicle routing and project job 
scheduling)
http://blog.athico.com/2013/06/shadow-variables-planningvariablelisten.html
Shadow variables is probably more efficient.
>    I'm
> looking forward to 6.1, where it seems there's better support for numeric
> ranges, but for now, just modeled start time as the set of integers
> representing the time range of the convention in minutes.  Finally, I
> constructed a hard score based on the constraints above, and a soft score
> that represents the sum of the worth of the events that occur during the
> visit.
>
> However, I'm not seeing it work out too well...the engine seems to spend a
> lot of time messing around with one visit, and very little time trying out
> multiple visits with different starts and durations to capture event-rich
> times.  I can certainly play around with parameters and engine
> configuration, but I thought I should first ask if I was fundamentally going
> about modeling the problem the wrong way, as I am very new to the
> OptaPlanner engine.
If you see this behavior, it can be well worth to add additional generic 
moves (such as pillarSwapMove)
and "smarter custom moves".
By default it will uses only changeMoveSelector and swapMoveSelector.

Read about "score trap" in the docs, that might also help there.

In the benchmarker, enable the mutation count statistic and best score 
statistic.
Based on those graphs, it's possible to get a better understanding of 
what's happening.
>
> Thanks in advance for any thoughts or suggestions!
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-best-strategy-for-variable-number-of-planning-entities-tp4028470.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list