[rules-users] Fwd: Retrieving constraints based on a manual solution
Geoffrey De Smet
ge0ffrey.spam at gmail.com
Mon Jan 7 03:17:51 EST 2013
Op 07-01-13 09:08, Reinis schreef:
> Hello Sreeni,
>
> > 2. in scenario b, I do not want to run the solver for best solution.
>
> This is what I interpret from your question:
> 1. you have some sort of working solution that is manually optimized to
> some degree (by human?);
> 2. you are willing to determine what constraints are still violated
> based on a rule base you created with drools but WITHOUT changing the
> actual manual working solution and WITHOUT running solver for multiple
> times;
>
> If this interpretation is correct, there is a way in drools planner to
> calculate score once and iterate working memory looking for constraint
> occurrences. WARNING, this API is intended to be internal and thus
> subject to a likely change:
>
> ScoreDirector scoreDirector =
> solver.getScoreDirectorFactory().buildScoreDirector();
> scoreDirector.setWorkingSolution(schedule);
> scoreDirector.calculateScore(); <- only once, causes working
> memory to fire all rules but does not involve solver "search loop"
The part above is documented in the manual. Look for guiScoreDirector.
>
> WorkingMemory workingMemory = ((DroolsScoreDirector)
> scoreDirector).getWorkingMemory();
> Iterator<ConstraintOccurrence> it =
> (Iterator<ConstraintOccurrence>) workingMemory
> .iterateObjects(new
> ClassObjectFilter(ConstraintOccurrence.class));
> while (it.hasNext()) {
> //here you collect constraint occurrences and prepare your
> report
> }
That part isn't documented in the manual, but it works :)
>
> Hope this helps, for a complete example of the usage of this (internal!)
> api see drools planner examples from Geoffrey on Git.
Also look into "immovable entities" (see manual). You 'll need that if
you want to combine scenario a and b.
>
> br
> Reinis
>
> On 01/07/2013 04:38 AM, Sreeni Maheshwaram wrote:
>> Hi,
>>
>> Could you please advise:
>>
>> I am using the Drools Planner (5.5) to a) optimize the solution
>> and get best
>> solution b) allow the manual solution and resolve the conflicts,
>> based on
>> the business requirement.
>>
>> 1. scenario a is straight forward. I could run the solver, get
>> the best
>> solution, set it to the ScoreDirector as working solution, get the
>> constraints from the working memory.
>>
>> 2. in scenario b, I do not want to run the solver for best
>> solution. When I
>> set the manual solution as a working solution on the
>> ScoreDirector, I could
>> not get the constraints.
>>
>> As a work around, either I have to run the solver in scenario b
>> for some
>> time to get the constraints, which I can not afford and I do not
>> think the
>> constraints relate to the manual solution.
>>
>> Is there a way to get cosntraints based on the manual solution without
>> running the solver?
>>
>> regards,
>> Sreeni
>>
>>
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/Retrieving-constraints-based-on-a-manual-solution-tp4021357.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>
>>
>>
>>
>> --
>> Thanks, Sreeni M
>>
>>
>>
>> --
>> Thanks, Sreeni M
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
> _______________________________________________
> 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