[rules-users] OptaPlanner Guvnor integration

Bartek bartekd100 at wp.pl
Tue Jun 25 08:12:56 EDT 2013


I get it to work. Four steps where needed:
1. Adding

  private KnowledgeBase *kBase*;//injected with Spring
....
         // Build the Solver
         SolverFactory solverFactory = new 
XmlSolverFactory("/planner/solverConfig.xml");
         RuleBase ruleBase = ((InternalKnowledgeBase) 
*kBase*).getRuleBase();
solverFactory.getSolverConfig().getScoreDirectorFactoryConfig().setRuleBase(ruleBase);

to my code to link Guvnor and solverFactory.

And spring integration with Drools:

    <drools:kbase id="knowledgeBase"/>
     <drools:kagent kbase="knowledgeBase" id="kagent" new-instance="false">
         <drools:resources>
             <drools:resource type="PKG"
                              source="${drools.url}"
                              basic-authentication="enabled"
                              username="admin"
                              password="admin"/>
         </drools:resources>
     </drools:kagent>

  <bean id="planner" class="...">
         <property name="*kBase*" ref="knowledgeBase"/>
     </bean>

2. Importing drools-planner-core-5.5.0.Final.jar in Guvnor (Upload POJO 
Model jar)
3. Adding global in Guvnor:
   global 
org.drools.planner.core.score.buildin.hardandsoft.HardAndSoftScoreHolder 
scoreHolder
4. Adding drools-planner-core-5.5.0.Final.jar to WEB-INF/lib in Guvnor 
instalation directory. Without that I still get NoClassDefFoundError 
while importing my domain in Guvnor.

Best regards

W dniu 2013-06-18 10:52, Geoffrey De Smet pisze:
>
>>
>> Is it generally good idea to try use guvnor to define scores?
> Yes, if you need that flexibility, as it allows you to change your 
> score rules through the guvnor web interface.
> However, this is mostly uncharted territory: some users have already 
> successfully done it (there are mails on this mailing list's archive),
> but there's little documentation and no example for it. Feel to do a 
> write up once you get it to work, for the next person wanting to do 
> this :)
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130625/06e07d61/attachment.html 


More information about the rules-users mailing list